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,32 @@
|
|
|
1
|
+
import { OPENCODE } from '../opencode/name.js';
|
|
2
|
+
import { PROVIDERS } from './providers.js';
|
|
3
|
+
/**
|
|
4
|
+
* The providers of OpenCode a folder may be signed in to (BTN-984), as the keys of its `auth.json` and the prefixes of
|
|
5
|
+
* its models: `openai` — a ChatGPT sign-in or an OpenAI key, `opencode` — no sign-in or a Zen key. The order picks one
|
|
6
|
+
* for a folder signed in to several. A page-safe list.
|
|
7
|
+
*/
|
|
8
|
+
export const OPENCODE_VENDORS = ['openai', 'anthropic', 'openrouter', 'github-copilot', 'opencode-go', 'opencode'];
|
|
9
|
+
/** OpenCode's own models: a folder with no sign-in, or with none of `OPENCODE_VENDORS`. */
|
|
10
|
+
export const FREE_VENDOR = 'opencode';
|
|
11
|
+
/**
|
|
12
|
+
* The keys of `models`: a provider, and for OpenCode a slot of each of its providers (`opencode/openai`), so a model
|
|
13
|
+
* picked for one sign-in stays when the account is switched to another and back.
|
|
14
|
+
*/
|
|
15
|
+
export const MODEL_SLOTS = PROVIDERS.flatMap((provider) => provider === OPENCODE ? OPENCODE_VENDORS.map((vendor) => `${OPENCODE}/${vendor}`) : [provider]);
|
|
16
|
+
export const isModelSlot = (key) => MODEL_SLOTS.includes(key);
|
|
17
|
+
/** The provider of OpenCode a folder signed in to these (its `auth.json` keys, `subscriptionType`) runs models of. */
|
|
18
|
+
export function vendorOf(names) {
|
|
19
|
+
return OPENCODE_VENDORS.find((vendor) => names.includes(vendor)) ?? FREE_VENDOR;
|
|
20
|
+
}
|
|
21
|
+
/** The key of `models` for a session of the provider on a folder of this OpenCode provider; `null` — not known. */
|
|
22
|
+
export function modelSlot(provider, vendor) {
|
|
23
|
+
return provider === OPENCODE ? `${OPENCODE}/${vendor ?? FREE_VENDOR}` : provider;
|
|
24
|
+
}
|
|
25
|
+
/** The provider a key of `models` is of. */
|
|
26
|
+
export const slotProvider = (slot) => slot.split('/')[0];
|
|
27
|
+
export const modelOf = (models, provider, vendor) => models[modelSlot(provider, vendor)];
|
|
28
|
+
/** The slot an OpenCode model of a config from before the slots goes to: by its prefix, else OpenCode's own. */
|
|
29
|
+
export function slotOfModel(model) {
|
|
30
|
+
const prefix = model.trim().split('/')[0];
|
|
31
|
+
return modelSlot(OPENCODE, model.includes('/') && OPENCODE_VENDORS.includes(prefix) ? prefix : FREE_VENDOR);
|
|
32
|
+
}
|
|
@@ -2,12 +2,38 @@ import { execFile } from 'node:child_process';
|
|
|
2
2
|
import { promisify } from 'node:util';
|
|
3
3
|
const run = promisify(execFile);
|
|
4
4
|
const QUERY_TIMEOUT_MS = 5_000;
|
|
5
|
+
const KILL_TIMEOUT_MS = 5_000;
|
|
6
|
+
const STOP_POLL_MS = 500;
|
|
7
|
+
/**
|
|
8
|
+
* Stops a detached turn and waits for its pid to go. A turn that outlives `termMs` after `SIGTERM` (one frozen by
|
|
9
|
+
* `SIGSTOP`, EKR-64) gets `SIGKILL` to a fresh tree, but only while `stillOurs` confirms the pid is still the turn's
|
|
10
|
+
* own (BTN-760). False when the pid outlived both waits or stopped being the turn's.
|
|
11
|
+
*/
|
|
12
|
+
export async function stopTree(pid, stillOurs, waits) {
|
|
13
|
+
const { termMs, killMs = KILL_TIMEOUT_MS, pollMs = STOP_POLL_MS } = waits;
|
|
14
|
+
await killTree(pid);
|
|
15
|
+
if (await gone(pid, termMs, pollMs))
|
|
16
|
+
return true;
|
|
17
|
+
if (!(await stillOurs()))
|
|
18
|
+
return false;
|
|
19
|
+
await killTree(pid, 'SIGKILL');
|
|
20
|
+
return gone(pid, killMs, pollMs);
|
|
21
|
+
}
|
|
22
|
+
async function gone(pid, timeoutMs, pollMs) {
|
|
23
|
+
const deadline = Date.now() + timeoutMs;
|
|
24
|
+
while (isAlive(pid)) {
|
|
25
|
+
if (Date.now() > deadline)
|
|
26
|
+
return false;
|
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, pollMs));
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
5
31
|
/**
|
|
6
32
|
* Kills a detached turn with its children: on Windows a shell wrapper dies alone and leaves the agent running. On Unix
|
|
7
33
|
* an agent may run a tool's command in a session of its own, out of the turn's group (BTN-643): the turn's descendants
|
|
8
34
|
* are found by parent from one snapshot taken right before the kill, and their groups are signalled too.
|
|
9
35
|
*/
|
|
10
|
-
export async function killTree(pid) {
|
|
36
|
+
export async function killTree(pid, kind = 'SIGTERM') {
|
|
11
37
|
if (process.platform === 'win32') {
|
|
12
38
|
await run('taskkill', ['/PID', String(pid), '/T', '/F'], { windowsHide: true }).catch(() => undefined);
|
|
13
39
|
return;
|
|
@@ -15,11 +41,11 @@ export async function killTree(pid) {
|
|
|
15
41
|
const table = await processTable();
|
|
16
42
|
const { groups, pids } = table === undefined ? { groups: [pid], pids: [] } : treeTargets(table, pid, process.pid);
|
|
17
43
|
for (const group of groups) {
|
|
18
|
-
if (!signal(-group) && group === pid)
|
|
19
|
-
signal(pid);
|
|
44
|
+
if (!signal(-group, kind) && group === pid)
|
|
45
|
+
signal(pid, kind);
|
|
20
46
|
}
|
|
21
47
|
for (const loose of pids)
|
|
22
|
-
signal(loose);
|
|
48
|
+
signal(loose, kind);
|
|
23
49
|
}
|
|
24
50
|
/** The groups to signal and the descendants to signal alone: those sharing the service's own group. */
|
|
25
51
|
export function treeTargets(table, root, self) {
|
|
@@ -56,9 +82,9 @@ async function processTable() {
|
|
|
56
82
|
return undefined;
|
|
57
83
|
}
|
|
58
84
|
}
|
|
59
|
-
function signal(target) {
|
|
85
|
+
function signal(target, kind) {
|
|
60
86
|
try {
|
|
61
|
-
process.kill(target,
|
|
87
|
+
process.kill(target, kind);
|
|
62
88
|
return true;
|
|
63
89
|
}
|
|
64
90
|
catch {
|
|
@@ -6,9 +6,10 @@ export const INSTRUCTION_FILES = ['CLAUDE.md', 'AGENTS.md'];
|
|
|
6
6
|
/** The folders of a repository that hold skills, one skill per subfolder with its `SKILL.md`. */
|
|
7
7
|
export const SKILL_FOLDERS = ['.claude/skills', '.agents/skills', '.codex/skills', '.github/skills', '.opencode/skills'];
|
|
8
8
|
// A lone file reaches every agent: Codex and OpenCode take CLAUDE.md without an AGENTS.md (Codex by Even Keel's
|
|
9
|
-
// `project_doc_fallback_filenames`)
|
|
9
|
+
// `project_doc_fallback_filenames`); Claude Code reads a lone AGENTS.md by itself (CLI 2.1.309 and up, 2026-11-08),
|
|
10
|
+
// and Even Keel passes it only where a CLAUDE.md above the folder keeps the CLI from it (`agentsFallback`, BTN-869).
|
|
10
11
|
const READS = {
|
|
11
|
-
[CLAUDE]: { own: 'CLAUDE.md', fallbackPassed:
|
|
12
|
+
[CLAUDE]: { own: 'CLAUDE.md', fallbackPassed: false, skills: ['.claude/skills'], passed: [], plugins: 'all' },
|
|
12
13
|
[CODEX]: { own: 'AGENTS.md', fallbackPassed: true, skills: ['.agents/skills', '.codex/skills'], passed: [], plugins: 'all' },
|
|
13
14
|
[OPENCODE]: { own: 'AGENTS.md', fallbackPassed: false, skills: ['.opencode/skills'], passed: ['.claude/skills', '.agents/skills'], plugins: 'skills' },
|
|
14
15
|
[COPILOT]: { own: null, fallbackPassed: false, skills: ['.github/skills', '.agents/skills', '.claude/skills'], passed: [], plugins: 'all' },
|
|
@@ -4,7 +4,7 @@ import { COPILOT } from '../copilot/name.js';
|
|
|
4
4
|
import { OPENCODE } from '../opencode/name.js';
|
|
5
5
|
/**
|
|
6
6
|
* The providers a session may run on, by the agents' names in `src/agent/adapters.ts`: the keys of `provider`, `models`,
|
|
7
|
-
* `accounts` and `execution` in the config and the
|
|
7
|
+
* `accounts` and `execution` in the config and the provider of a task's run. A page-safe list, without the adapters.
|
|
8
8
|
*/
|
|
9
9
|
export const PROVIDERS = [CLAUDE, CODEX, OPENCODE, COPILOT];
|
|
10
10
|
/** The providers Even Keel keeps a copy of the checked CLI for, the keys of `cli`: every one since BTN-347. */
|
|
@@ -25,6 +25,23 @@ export const NO_SIGN_IN = 'none';
|
|
|
25
25
|
* sessions run (BTN-353, `transportOf`): `auto` by the account's kind, or `claude --bg` or the Agent SDK for every one.
|
|
26
26
|
*/
|
|
27
27
|
export const EXECUTION_MODES = { [CLAUDE]: ['auto', 'bg', 'sdk'], [CODEX]: ['sandbox', 'bypass'] };
|
|
28
|
+
/**
|
|
29
|
+
* OpenCode's `--variant` and Copilot's `--reasoning-effort` (BTN-1071): the levels of the whole CLI, while the ones a
|
|
30
|
+
* model has are only the CLI's own knowledge (OpenCode's `variants` of a model, `opencode models --verbose`). A level
|
|
31
|
+
* the model lacks is the CLI's to handle.
|
|
32
|
+
*/
|
|
33
|
+
const MODEL_EFFORTS = ['none', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max'];
|
|
34
|
+
/**
|
|
35
|
+
* The effort levels a task's run may name by provider (BTN-983), lowest first, as the CLI takes them: Claude Code's
|
|
36
|
+
* `--effort`, Codex's `model_reasoning_effort`, OpenCode's and Copilot's `MODEL_EFFORTS`. A provider not listed takes
|
|
37
|
+
* none: the card has no field for it and its sessions get no flag.
|
|
38
|
+
*/
|
|
39
|
+
export const EFFORTS = {
|
|
40
|
+
[CLAUDE]: ['low', 'medium', 'high', 'xhigh', 'max'],
|
|
41
|
+
[CODEX]: ['minimal', 'low', 'medium', 'high', 'xhigh'],
|
|
42
|
+
[OPENCODE]: MODEL_EFFORTS,
|
|
43
|
+
[COPILOT]: MODEL_EFFORTS,
|
|
44
|
+
};
|
|
28
45
|
/**
|
|
29
46
|
* Which CLI a provider's sessions run on (`cli`, BTN-250), the default first: `system` — the one installed on the
|
|
30
47
|
* machine, on whatever version it updated to, `checked` — Even Keel's own copy of the version it was last checked
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { runGit } from '../git/run.js';
|
|
3
|
+
import { hungEntry } from '../sessions/silence.js';
|
|
4
|
+
import { TranscriptFold } from '../sessions/transcript.js';
|
|
5
|
+
export const SCRIPT_PID = 4242;
|
|
6
|
+
const FEED_SIZE = 30;
|
|
7
|
+
/** Captured before a scenario fakes the timers: `settled` polls in real time. */
|
|
8
|
+
const realTimeout = globalThis.setTimeout;
|
|
9
|
+
/** What a parked turn waits for; the scenario opens it. */
|
|
10
|
+
export class Gate {
|
|
11
|
+
passed;
|
|
12
|
+
open;
|
|
13
|
+
constructor() {
|
|
14
|
+
this.passed = new Promise((resolve) => (this.open = resolve));
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A provider-neutral agent whose sessions play a script: each launch or resume of a task's session runs the task's
|
|
19
|
+
* next turn. The turns do real git in the folder the chain gave; what the session ends with is put into its summary
|
|
20
|
+
* the way an adapter's transcript reading would. The e2e tests drive it (`src/e2e/agent.fixture.ts`) and the demo plays
|
|
21
|
+
* its scenario on it (`src/demo/agent.ts`).
|
|
22
|
+
*/
|
|
23
|
+
export class ScriptedAgent {
|
|
24
|
+
repo;
|
|
25
|
+
address;
|
|
26
|
+
title;
|
|
27
|
+
mode = 'script';
|
|
28
|
+
calls = [];
|
|
29
|
+
known = new Map();
|
|
30
|
+
scripts = new Map();
|
|
31
|
+
running = new Set();
|
|
32
|
+
parked = 0;
|
|
33
|
+
onLimits;
|
|
34
|
+
constructor(
|
|
35
|
+
/** The project checkout of a session's folder. */
|
|
36
|
+
repo,
|
|
37
|
+
/** The service's address, for the chat's mail; none — a turn asks for no mail. */
|
|
38
|
+
address, title = 'Script') {
|
|
39
|
+
this.repo = repo;
|
|
40
|
+
this.address = address;
|
|
41
|
+
this.title = title;
|
|
42
|
+
}
|
|
43
|
+
/** The turns the task's sessions play, in order, across launches and resumes. */
|
|
44
|
+
script(task, ...turns) {
|
|
45
|
+
this.scripts.set(task, [...(this.scripts.get(task) ?? []), ...turns]);
|
|
46
|
+
}
|
|
47
|
+
/** The adapter to register in `AGENTS`. */
|
|
48
|
+
adapter() {
|
|
49
|
+
return {
|
|
50
|
+
title: this.title,
|
|
51
|
+
checked: '1.0.0',
|
|
52
|
+
latest: async () => '1.0.0',
|
|
53
|
+
setup: (options) => {
|
|
54
|
+
this.setUp(options);
|
|
55
|
+
return this;
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
setUp(options) {
|
|
60
|
+
this.onLimits = options.onLimits;
|
|
61
|
+
}
|
|
62
|
+
/** Waits for every turn under way but the parked ones. */
|
|
63
|
+
async settled() {
|
|
64
|
+
while (this.running.size > this.parked)
|
|
65
|
+
await new Promise((resolve) => realTimeout(resolve, 5));
|
|
66
|
+
}
|
|
67
|
+
/** The sessions of a task, oldest first. */
|
|
68
|
+
sessionsOf(task) {
|
|
69
|
+
return [...this.known.values()].filter((session) => session.entry.name === task).map((session) => session.entry);
|
|
70
|
+
}
|
|
71
|
+
env() {
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
74
|
+
async launch(home, start) {
|
|
75
|
+
const sessionId = randomUUID();
|
|
76
|
+
const summary = new TranscriptFold().summary();
|
|
77
|
+
const entry = { id: sessionId, cwd: start.cwd, kind: 'script', startedAt: Date.now(), sessionId, name: start.name, account: home.key };
|
|
78
|
+
this.known.set(sessionId, { entry, summary: { ...summary, workdir: start.cwd }, lines: [], plays: 0, prompt: start.prompt, turn: 0, wroteAt: Date.now(), mcp: start.mcp ?? [] });
|
|
79
|
+
this.calls.push({ kind: 'launch', task: start.name, sessionId, cwd: start.cwd, prompt: start.prompt, provider: home.agent, account: home.key, model: start.model, ...(start.effort !== undefined && { effort: start.effort }) });
|
|
80
|
+
this.play(sessionId, start.prompt);
|
|
81
|
+
return sessionId;
|
|
82
|
+
}
|
|
83
|
+
async resume(home, session, start) {
|
|
84
|
+
const known = this.known.get(session.sessionId);
|
|
85
|
+
if (known === undefined)
|
|
86
|
+
throw new Error(`script: no session ${session.sessionId}`);
|
|
87
|
+
known.mcp = start.mcp ?? [];
|
|
88
|
+
this.calls.push({ kind: 'resume', task: start.name, sessionId: session.sessionId, cwd: start.cwd, prompt: start.prompt, provider: home.agent, account: home.key, model: start.model, ...(start.effort !== undefined && { effort: start.effort }) });
|
|
89
|
+
this.play(session.sessionId, start.prompt);
|
|
90
|
+
return session.sessionId;
|
|
91
|
+
}
|
|
92
|
+
async stop(home, session) {
|
|
93
|
+
const known = this.known.get(session.sessionId);
|
|
94
|
+
if (known === undefined)
|
|
95
|
+
return;
|
|
96
|
+
known.turn++;
|
|
97
|
+
this.calls.push({ kind: 'stop', task: known.entry.name ?? '', sessionId: session.sessionId, cwd: known.entry.cwd, prompt: '', provider: home.agent, account: home.key, model: null });
|
|
98
|
+
const { pid: _, resting: __, status: ___, ask: ____, ...rest } = known.entry;
|
|
99
|
+
known.entry = { ...rest, state: 'stopped' };
|
|
100
|
+
this.changed();
|
|
101
|
+
}
|
|
102
|
+
async sessions(home) {
|
|
103
|
+
return this.listed(home);
|
|
104
|
+
}
|
|
105
|
+
listed(home) {
|
|
106
|
+
// A busy turn carries the time of its last write, as the adapters' transcript reading gives it (`TurnActivity`).
|
|
107
|
+
return [...this.known.values()].filter((session) => session.entry.account === home.key).map((session) => hungEntry({ ...session.entry }, session.wroteAt, Date.now()));
|
|
108
|
+
}
|
|
109
|
+
tail(_home, agent) {
|
|
110
|
+
const session = () => this.known.get(agent.sessionId);
|
|
111
|
+
return {
|
|
112
|
+
path: undefined,
|
|
113
|
+
follow: () => { },
|
|
114
|
+
read: async () => { },
|
|
115
|
+
summary: () => session()?.summary ?? new TranscriptFold().summary(),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
async record() {
|
|
119
|
+
return undefined;
|
|
120
|
+
}
|
|
121
|
+
async feed(_home, _sessionId, _after) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
async transcripts(home) {
|
|
125
|
+
return this.listed(home).map((entry) => entry.sessionId);
|
|
126
|
+
}
|
|
127
|
+
async authStatus(home) {
|
|
128
|
+
return { loggedIn: true, authMethod: 'claude.ai', email: `${home.key}@example.com`, orgName: null, subscriptionType: 'max' };
|
|
129
|
+
}
|
|
130
|
+
login() {
|
|
131
|
+
throw new Error('script: no sign-in');
|
|
132
|
+
}
|
|
133
|
+
async logout() { }
|
|
134
|
+
/** The turn the session plays next; `undefined` — the script has none left. */
|
|
135
|
+
nextTurn(session) {
|
|
136
|
+
return this.scripts.get(session.entry.name)?.shift();
|
|
137
|
+
}
|
|
138
|
+
/** A session's listing or transcript changed. */
|
|
139
|
+
changed() { }
|
|
140
|
+
/** Plays the session's last turn again, as a session the service found mid-turn after its restart goes on. */
|
|
141
|
+
replay(sessionId) {
|
|
142
|
+
const session = this.known.get(sessionId);
|
|
143
|
+
session.plays--;
|
|
144
|
+
this.play(sessionId, session.prompt);
|
|
145
|
+
}
|
|
146
|
+
play(sessionId, prompt) {
|
|
147
|
+
const session = this.known.get(sessionId);
|
|
148
|
+
const task = session.entry.name;
|
|
149
|
+
const turn = this.nextTurn(session);
|
|
150
|
+
if (turn === undefined)
|
|
151
|
+
throw new Error(`script: ${task} has no turn left`);
|
|
152
|
+
session.plays++;
|
|
153
|
+
session.prompt = prompt;
|
|
154
|
+
const id = ++session.turn;
|
|
155
|
+
session.wroteAt = Date.now();
|
|
156
|
+
let background = false;
|
|
157
|
+
const at = () => new Date().toISOString();
|
|
158
|
+
session.entry = { ...session.entry, pid: SCRIPT_PID, status: 'busy', state: 'working', resting: false };
|
|
159
|
+
delete session.entry.ask;
|
|
160
|
+
session.summary = { ...session.summary, apiError: null, checkpoint: null, noChanges: null, pullRequest: null, ask: null, asking: false, lastActivityAt: at(), turn: { startedAt: at(), tool: null } };
|
|
161
|
+
this.changed();
|
|
162
|
+
const cwd = session.entry.cwd;
|
|
163
|
+
const waiting = async (until) => {
|
|
164
|
+
this.parked++;
|
|
165
|
+
try {
|
|
166
|
+
await until;
|
|
167
|
+
}
|
|
168
|
+
finally {
|
|
169
|
+
this.parked--;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
const context = {
|
|
173
|
+
task,
|
|
174
|
+
sessionId,
|
|
175
|
+
cwd,
|
|
176
|
+
prompt,
|
|
177
|
+
repo: this.repo(cwd),
|
|
178
|
+
git: async (...args) => {
|
|
179
|
+
const result = await runGit(cwd, args);
|
|
180
|
+
if (result.code !== 0)
|
|
181
|
+
throw new Error(`script: git ${args.join(' ')} in ${cwd}: ${result.out}`);
|
|
182
|
+
return result.out;
|
|
183
|
+
},
|
|
184
|
+
park: (gate) => waiting(gate.passed),
|
|
185
|
+
pause: (ms) => waiting(new Promise((resolve) => setTimeout(resolve, ms))),
|
|
186
|
+
live: () => session.turn === id && this.known.get(sessionId) === session,
|
|
187
|
+
show: (step) => {
|
|
188
|
+
if (session.turn !== id)
|
|
189
|
+
return;
|
|
190
|
+
this.writeLine(session, { at: at(), kind: step.tool === undefined ? 'text' : 'tool', text: step.text, ...(step.tool === undefined ? {} : { name: step.tool }) }, step);
|
|
191
|
+
},
|
|
192
|
+
mail: async (event) => {
|
|
193
|
+
if (this.address === undefined)
|
|
194
|
+
throw new Error('script: no address for the mail');
|
|
195
|
+
const { host, port } = this.address();
|
|
196
|
+
const response = await fetch(`http://${host}:${port}/api/sessions/${sessionId}/mail`, {
|
|
197
|
+
method: 'POST',
|
|
198
|
+
headers: { 'content-type': 'application/json' },
|
|
199
|
+
body: JSON.stringify({ event }),
|
|
200
|
+
});
|
|
201
|
+
if (!response.ok)
|
|
202
|
+
throw new Error(`script: mail on ${event}: ${response.status}`);
|
|
203
|
+
return (await response.json()).message;
|
|
204
|
+
},
|
|
205
|
+
reportCheck: async () => {
|
|
206
|
+
if (this.address === undefined)
|
|
207
|
+
throw new Error('script: no address for the check report');
|
|
208
|
+
const { host, port } = this.address();
|
|
209
|
+
const url = `http://${host}:${port}/api/sessions/${sessionId}/check`;
|
|
210
|
+
const asked = await fetch(url);
|
|
211
|
+
if (!asked.ok)
|
|
212
|
+
throw new Error(`script: check asked: ${asked.status}`);
|
|
213
|
+
const { commands } = (await asked.json());
|
|
214
|
+
const tree = (await runGit(cwd, ['rev-parse', 'HEAD^{tree}'])).out.trim();
|
|
215
|
+
const response = await fetch(url, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ tree, commands }) });
|
|
216
|
+
if (!response.ok)
|
|
217
|
+
throw new Error(`script: check report: ${response.status}`);
|
|
218
|
+
},
|
|
219
|
+
background: () => void (background = true),
|
|
220
|
+
limits: (reported) => this.onLimits?.(session.entry.account, reported),
|
|
221
|
+
tool: async (server, name, args) => {
|
|
222
|
+
const url = session.mcp.find((each) => each.name === server)?.url;
|
|
223
|
+
if (url === undefined)
|
|
224
|
+
throw new Error(`script: the session has no server ${server}`);
|
|
225
|
+
const response = await fetch(url, {
|
|
226
|
+
method: 'POST',
|
|
227
|
+
headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
|
|
228
|
+
body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name, arguments: args } }),
|
|
229
|
+
});
|
|
230
|
+
if (!response.ok)
|
|
231
|
+
throw new Error(`script: ${server}/${name}: ${response.status}`);
|
|
232
|
+
const { result } = (await response.json());
|
|
233
|
+
const text = result.content.map((each) => each.text).join('\n');
|
|
234
|
+
if (result.isError === true)
|
|
235
|
+
throw new Error(`script: ${server}/${name} refused: ${text}`);
|
|
236
|
+
return text;
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
const running = turn(context)
|
|
240
|
+
.catch((error) => {
|
|
241
|
+
console.error(`script: ${task}: ${error instanceof Error ? error.message : String(error)}`);
|
|
242
|
+
return { crash: true };
|
|
243
|
+
})
|
|
244
|
+
.then((end) => {
|
|
245
|
+
if (session.turn !== id)
|
|
246
|
+
return;
|
|
247
|
+
this.end(session, end, at());
|
|
248
|
+
if (background && session.entry.resting === true)
|
|
249
|
+
session.entry = { ...session.entry, pid: SCRIPT_PID, status: 'shell', resting: false };
|
|
250
|
+
this.changed();
|
|
251
|
+
})
|
|
252
|
+
.finally(() => this.running.delete(running));
|
|
253
|
+
this.running.add(running);
|
|
254
|
+
}
|
|
255
|
+
/** A line of the transcript, with what a step says about the stage and the context. */
|
|
256
|
+
writeLine(session, line, step = {}) {
|
|
257
|
+
session.lines.push(line);
|
|
258
|
+
session.wroteAt = Date.now();
|
|
259
|
+
const tool = line.kind === 'tool' ? line : null;
|
|
260
|
+
session.summary = {
|
|
261
|
+
...session.summary,
|
|
262
|
+
feed: session.lines.slice(-FEED_SIZE),
|
|
263
|
+
action: line,
|
|
264
|
+
stage: step.stage ?? session.summary.stage,
|
|
265
|
+
contextTokens: step.context ?? session.summary.contextTokens,
|
|
266
|
+
lastActivityAt: line.at,
|
|
267
|
+
turn: session.summary.turn === null ? null : { ...session.summary.turn, tool: tool === null ? null : tool.text },
|
|
268
|
+
};
|
|
269
|
+
this.changed();
|
|
270
|
+
}
|
|
271
|
+
end(session, end, at) {
|
|
272
|
+
const { pid: _, ...rest } = session.entry;
|
|
273
|
+
const resting = { ...rest, resting: true, status: 'idle', state: 'done' };
|
|
274
|
+
const said = (text) => {
|
|
275
|
+
this.writeLine(session, { at, kind: 'text', text });
|
|
276
|
+
return { ...session.summary, lastMessage: text, lastReplyAt: at, lastActivityAt: at };
|
|
277
|
+
};
|
|
278
|
+
if ('crash' in end) {
|
|
279
|
+
const { resting: __, status: ___, ...gone } = rest;
|
|
280
|
+
session.entry = { ...gone, state: 'failed' };
|
|
281
|
+
}
|
|
282
|
+
else if ('ask' in end) {
|
|
283
|
+
const options = (end.options ?? ['Yes', 'No']).map((label) => ({ label, description: '' }));
|
|
284
|
+
const ask = { id: `ask-${randomUUID()}`, questions: [{ question: end.ask, header: 'Question', multiSelect: false, options }] };
|
|
285
|
+
session.entry = { ...session.entry, status: 'waiting', state: 'blocked', ask };
|
|
286
|
+
session.summary = { ...said(end.ask), ask, asking: true };
|
|
287
|
+
}
|
|
288
|
+
else if ('limit' in end) {
|
|
289
|
+
session.entry = resting;
|
|
290
|
+
session.summary = { ...said(end.limit), apiError: { kind: 'limit', text: end.limit, at } };
|
|
291
|
+
}
|
|
292
|
+
else if ('credit' in end) {
|
|
293
|
+
session.entry = resting;
|
|
294
|
+
session.summary = { ...said(end.credit), apiError: { kind: 'credit', text: end.credit, at } };
|
|
295
|
+
}
|
|
296
|
+
else if ('fail' in end) {
|
|
297
|
+
session.entry = resting;
|
|
298
|
+
session.lines.push({ at, kind: 'error', text: end.fail });
|
|
299
|
+
const feed = [...session.summary.feed, { at, kind: 'error', text: end.fail }];
|
|
300
|
+
session.summary = { ...session.summary, feed, lastActivityAt: at, apiError: { kind: 'error', text: end.fail, at } };
|
|
301
|
+
}
|
|
302
|
+
else if ('checkpoint' in end) {
|
|
303
|
+
session.entry = resting;
|
|
304
|
+
session.summary = { ...said(`CHECKPOINT: ${end.checkpoint}`), checkpoint: end.checkpoint };
|
|
305
|
+
}
|
|
306
|
+
else if ('noChanges' in end) {
|
|
307
|
+
session.entry = resting;
|
|
308
|
+
session.summary = { ...said(`NO CHANGES: ${end.noChanges}`), noChanges: end.noChanges };
|
|
309
|
+
}
|
|
310
|
+
else if ('pullRequest' in end) {
|
|
311
|
+
session.entry = resting;
|
|
312
|
+
session.summary = { ...said(`PULL REQUEST: ${end.pullRequest}`), pullRequest: end.pullRequest };
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
session.entry = resting;
|
|
316
|
+
session.summary = said(end.say);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
// The context window each account's sessions get on a model, as the agent itself reports it (BTN-187). Asking
|
|
2
2
|
// takes a CLI call, so answers are separated by launch settings and kept until the CLI or account settings change.
|
|
3
|
+
// They are kept through a restart too (BTN-946): a new start shows the saved window and asks only for a changed stamp.
|
|
3
4
|
export class ContextWindows {
|
|
4
5
|
options;
|
|
5
6
|
known = new Map();
|
|
6
7
|
asking = new Map();
|
|
8
|
+
/** The probes waiting for their turn: one CLI call at a time, so a start's burst does not time out in the folder's queue. */
|
|
9
|
+
turns = [];
|
|
10
|
+
probing = false;
|
|
7
11
|
constructor(options) {
|
|
8
12
|
this.options = options;
|
|
13
|
+
for (const saved of options.saved ?? []) {
|
|
14
|
+
// Checked at the first peek: the stamp may have changed while the service was down.
|
|
15
|
+
this.known.set(keyOf(saved.account, saved.model, saved.settings ?? undefined), { stamp: saved.stamp, window: saved.window, checkedAt: -Infinity });
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
/** The window for the account, model and original launch settings; `null` — not measured yet. */
|
|
11
19
|
peek(account, model, task, settings) {
|
|
12
|
-
const key =
|
|
20
|
+
const key = keyOf(account, model, settings);
|
|
13
21
|
const known = this.known.get(key);
|
|
14
22
|
if ((known === undefined || this.now() - known.checkedAt >= this.options.recheckMs) && !this.asking.has(key)) {
|
|
15
23
|
const asked = this.ask(key, account, model, task, known, settings).finally(() => this.asking.delete(key));
|
|
@@ -25,15 +33,39 @@ export class ContextWindows {
|
|
|
25
33
|
async ask(key, account, model, task, known, settings) {
|
|
26
34
|
try {
|
|
27
35
|
const stamp = await this.options.stamp(account);
|
|
28
|
-
|
|
29
|
-
|
|
36
|
+
if (known?.stamp === stamp) {
|
|
37
|
+
this.known.set(key, { stamp, window: known.window, checkedAt: this.now() });
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const window = await this.inTurn(() => this.options.probe(account, model, task, settings));
|
|
41
|
+
const measuredAt = this.now();
|
|
42
|
+
this.known.set(key, { stamp, window, checkedAt: measuredAt });
|
|
43
|
+
this.options.save?.({ account, model, settings: settings ?? null, stamp, window, measuredAt });
|
|
30
44
|
}
|
|
31
45
|
catch (error) {
|
|
32
46
|
this.known.set(key, { stamp: null, window: known?.window ?? null, checkedAt: this.now() });
|
|
33
47
|
this.options.onError(error);
|
|
34
48
|
}
|
|
35
49
|
}
|
|
50
|
+
async inTurn(call) {
|
|
51
|
+
if (this.probing)
|
|
52
|
+
await new Promise((turn) => this.turns.push(turn));
|
|
53
|
+
this.probing = true;
|
|
54
|
+
try {
|
|
55
|
+
return await call();
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
const next = this.turns.shift();
|
|
59
|
+
if (next === undefined)
|
|
60
|
+
this.probing = false;
|
|
61
|
+
else
|
|
62
|
+
next();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
36
65
|
now() {
|
|
37
66
|
return (this.options.now ?? Date.now)();
|
|
38
67
|
}
|
|
39
68
|
}
|
|
69
|
+
function keyOf(account, model, settings) {
|
|
70
|
+
return JSON.stringify([account, model, settings]);
|
|
71
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const LIMIT = 60;
|
|
2
|
+
const FILE_TOOLS = { Read: 'file_path', Edit: 'file_path', MultiEdit: 'file_path', Write: 'file_path', NotebookEdit: 'notebook_path' };
|
|
3
|
+
/** The tools whose own words describe the call; a shell command without a description shows only the tool. */
|
|
4
|
+
const DESCRIBED = { Bash: 'description', PowerShell: 'description', Agent: 'description', Task: 'description', Skill: 'skill' };
|
|
5
|
+
/**
|
|
6
|
+
* What the README badge says of a tool call (BTN-915): the tool and, where it is safe to publish, its short description —
|
|
7
|
+
* a file path inside the repository, a command's own description, a skill. A path outside the repository, a bare command,
|
|
8
|
+
* a pattern, a query or an MCP call show only the tool: nothing private leaves the machine.
|
|
9
|
+
*/
|
|
10
|
+
export function badgeActionOf(name, input, cwd) {
|
|
11
|
+
const mcp = /^mcp__(.+?)__(.+)$/.exec(name);
|
|
12
|
+
const tool = mcp ? mcp[2] : name;
|
|
13
|
+
const brief = mcp ? null : briefOf(name, input, cwd);
|
|
14
|
+
const text = brief === null ? tool : `${tool} ${brief}`;
|
|
15
|
+
return { tool, text: text.length > LIMIT ? `${text.slice(0, LIMIT - 1).trimEnd()}…` : text };
|
|
16
|
+
}
|
|
17
|
+
function briefOf(name, input, cwd) {
|
|
18
|
+
const fileKey = FILE_TOOLS[name];
|
|
19
|
+
if (fileKey !== undefined)
|
|
20
|
+
return typeof input[fileKey] === 'string' ? insideRepo(input[fileKey], cwd) : null;
|
|
21
|
+
const key = DESCRIBED[name];
|
|
22
|
+
const value = key === undefined ? undefined : input[key];
|
|
23
|
+
if (typeof value !== 'string')
|
|
24
|
+
return null;
|
|
25
|
+
const flat = value.replace(/\s+/g, ' ').trim();
|
|
26
|
+
return flat === '' ? null : flat;
|
|
27
|
+
}
|
|
28
|
+
/** The path relative to the repository, `null` for one outside it. */
|
|
29
|
+
export function insideRepo(file, cwd) {
|
|
30
|
+
const path = file.replace(/\\/g, '/');
|
|
31
|
+
const absolute = /^([a-zA-Z]:)?\//.test(path);
|
|
32
|
+
if (!absolute)
|
|
33
|
+
return path.split('/').includes('..') || path === '' ? null : path.replace(/^\.\//, '');
|
|
34
|
+
if (cwd === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
const root = `${cwd.replace(/\\/g, '/').replace(/\/$/, '')}/`;
|
|
37
|
+
if (!path.toLowerCase().startsWith(root.toLowerCase()))
|
|
38
|
+
return null;
|
|
39
|
+
const rest = path.slice(root.length);
|
|
40
|
+
return rest === '' || rest.split('/').includes('..') ? null : rest;
|
|
41
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { notice } from '../notice/notice.js';
|
|
2
|
+
import { isBadgeSlug, isHttp } from './settings.js';
|
|
3
|
+
const TIMEOUT_MS = 10_000;
|
|
4
|
+
/**
|
|
5
|
+
* The badge dialog's "Check" (BTN-917): a push of the project's state to the Worker, then a read of its picture, so
|
|
6
|
+
* the answer says which of the address, the secret and the Worker's version is wrong.
|
|
7
|
+
*/
|
|
8
|
+
export async function checkBadge(target, deps) {
|
|
9
|
+
const url = target.url.trim().replace(/\/+$/, '');
|
|
10
|
+
const slug = target.slug.trim();
|
|
11
|
+
if (!isHttp(url))
|
|
12
|
+
return failed(notice('badge.url', {}));
|
|
13
|
+
if (!isBadgeSlug(slug))
|
|
14
|
+
return failed(notice('badge.slug', {}));
|
|
15
|
+
const secret = deps.secret?.trim();
|
|
16
|
+
if (secret === undefined || secret === '')
|
|
17
|
+
return failed(notice('badge.noSecret', {}));
|
|
18
|
+
try {
|
|
19
|
+
const answer = await deps.post(`${url}/push/${encodeURIComponent(slug)}`, secret, JSON.stringify({ ...deps.state, at: new Date(deps.now()).toISOString() }));
|
|
20
|
+
if (!answer.ok)
|
|
21
|
+
return failed(pushRefusal(answer.status));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
return unreachable(error);
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
const picture = await deps.get(`${url}/${encodeURIComponent(slug)}.svg?theme=dark`);
|
|
28
|
+
if (picture.status !== 200)
|
|
29
|
+
return failed(notice('badge.imageStatus', { status: picture.status }));
|
|
30
|
+
if (!picture.type.includes('svg'))
|
|
31
|
+
return failed(notice('badge.notSvg', {}));
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
return unreachable(error);
|
|
35
|
+
}
|
|
36
|
+
return { ok: true, notice: notice('badge.checked', {}) };
|
|
37
|
+
}
|
|
38
|
+
function pushRefusal(status) {
|
|
39
|
+
if (status === 401)
|
|
40
|
+
return notice('badge.refused', {});
|
|
41
|
+
if (status === 404)
|
|
42
|
+
return notice('badge.notWorker', {});
|
|
43
|
+
if (status === 400)
|
|
44
|
+
return notice('badge.rejected', {});
|
|
45
|
+
return notice('badge.pushStatus', { status });
|
|
46
|
+
}
|
|
47
|
+
const failed = (reason) => ({ ok: false, notice: reason });
|
|
48
|
+
/** `fetch` throws "fetch failed" and puts the reason (DNS, refused, TLS) in `cause`. */
|
|
49
|
+
function unreachable(error) {
|
|
50
|
+
const messages = [];
|
|
51
|
+
for (let each = error; each instanceof Error && messages.length < 3; each = each.cause)
|
|
52
|
+
messages.push(each.message);
|
|
53
|
+
return { ok: false, notice: notice('badge.unreachable', {}), cause: messages.join(': ') };
|
|
54
|
+
}
|
|
55
|
+
/** `fetch` of the picture with a timeout: the service's `get`. */
|
|
56
|
+
export async function getBadge(url) {
|
|
57
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(TIMEOUT_MS) });
|
|
58
|
+
await response.body?.cancel();
|
|
59
|
+
return { status: response.status, type: response.headers.get('content-type') ?? '' };
|
|
60
|
+
}
|