rovecode 0.3.3 → 0.4.0-beta.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/CHANGELOG.md +512 -0
- package/README.md +33 -48
- package/bin/rovecode.js +24 -0
- package/dist/cli/app-dybnr56b.js +2 -0
- package/dist/cli/ask-user-p8hq4xgj.js +2 -0
- package/dist/cli/auth-login-ewpgw5sm.js +2 -0
- package/dist/cli/auth-m8p9grty.js +2 -0
- package/dist/cli/bench-xv3ypwev.js +9 -0
- package/dist/cli/catalog-737wb2s0.js +2 -0
- package/dist/cli/cli-arhg40m0.js +2 -0
- package/dist/cli/client-cf2pxx8q.js +2 -0
- package/dist/cli/commands-3p7e4xxs.js +2 -0
- package/dist/cli/connect-3q93d7cb.js +2 -0
- package/dist/cli/context-cmd-eqxmxhzq.js +2 -0
- package/dist/cli/context-report-hbw9zfes.js +2 -0
- package/dist/cli/count-remote-mby98cd0.js +2 -0
- package/dist/cli/design-122y0axd.js +2 -0
- package/dist/cli/dispatch-b4egzvvh.js +2 -0
- package/dist/cli/doctor-x4jkv72e.js +3 -0
- package/dist/cli/executor-ftvg6tsy.js +2 -0
- package/dist/cli/export-pdgdhkch.js +2 -0
- package/dist/cli/files-cez9a96p.js +2 -0
- package/dist/cli/gauntlet-r3xxaszc.js +2 -0
- package/dist/cli/gauntlet-runner-r515m7kk.js +10 -0
- package/dist/cli/gauntlet-wave3-bnkjk2v2.js +5 -0
- package/dist/cli/gauntlet-wave4-acs9s60q.js +14 -0
- package/dist/cli/hashline-ewg5hbe3.js +2 -0
- package/dist/cli/http-n0kehsk8.js +5 -0
- package/dist/cli/index-z5qt1s76.js +2 -0
- package/dist/cli/install-80mp63kx.js +2 -0
- package/dist/cli/loop-12twjcat.js +2 -0
- package/dist/cli/main-01pv9206.js +4 -0
- package/dist/cli/main-0jys2ccn.js +3 -0
- package/dist/cli/main-1ztz6fkj.js +10 -0
- package/dist/cli/main-23q7cmww.js +9 -0
- package/dist/cli/main-2rzbexn2.js +3 -0
- package/dist/cli/main-2wyax8k9.js +9 -0
- package/dist/cli/main-2yeveeve.js +6 -0
- package/dist/cli/main-2z3dek0b.js +3 -0
- package/dist/cli/main-2zgsknth.js +3 -0
- package/dist/cli/main-45ejth3a.js +4 -0
- package/dist/cli/main-45rn3trk.js +22 -0
- package/dist/cli/main-4p4e2w7x.js +4 -0
- package/dist/cli/main-4y0tnfpa.js +16 -0
- package/dist/cli/main-5py0rkmc.js +4 -0
- package/dist/cli/main-6dtqmbt6.js +7 -0
- package/dist/cli/main-6h9x282m.js +4 -0
- package/dist/cli/main-6vjeds42.js +3 -0
- package/dist/cli/main-78gq4bt9.js +6 -0
- package/dist/cli/main-7jd5vh3x.js +4 -0
- package/dist/cli/main-7kt6r53y.js +4 -0
- package/dist/cli/main-8c1tbazx.js +58 -0
- package/dist/cli/main-9a9rnh47.js +19 -0
- package/dist/cli/main-9ht36z12.js +3 -0
- package/dist/cli/main-a2yfvcy9.js +7 -0
- package/dist/cli/main-a3f51n0x.js +5 -0
- package/dist/cli/main-b8zq261k.js +3 -0
- package/dist/cli/main-bxtvnf6d.js +13 -0
- package/dist/cli/main-edxc3yzt.js +4 -0
- package/dist/cli/main-evgz4mp5.js +21 -0
- package/dist/cli/main-f33fc5je.js +9 -0
- package/dist/cli/main-fvnpq46y.js +12 -0
- package/dist/cli/main-gbbty4d4.js +3 -0
- package/dist/cli/main-gth53dnt.js +25 -0
- package/dist/cli/main-hqbz10aw.js +9 -0
- package/dist/cli/main-hrrvcfan.js +38 -0
- package/dist/cli/main-hzwtsb2m.js +5 -0
- package/dist/cli/main-j7ttv0sd.js +34 -0
- package/dist/cli/main-jak598k9.js +5 -0
- package/dist/cli/main-kba6zeyd.js +6 -0
- package/dist/cli/main-kwwsz6rq.js +3 -0
- package/dist/cli/main-m8vm17zq.js +3 -0
- package/dist/cli/main-mg4f96e1.js +3 -0
- package/dist/cli/main-mg9b20ac.js +18 -0
- package/dist/cli/main-mgb9ccnx.js +3 -0
- package/dist/cli/main-mjt2p7aj.js +3 -0
- package/dist/cli/main-n6qrdbmy.js +3 -0
- package/dist/cli/main-na7wse0x.js +5 -0
- package/dist/cli/main-nqveez48.js +4 -0
- package/dist/cli/main-ntqef02r.js +10 -0
- package/dist/cli/main-nvc3yjay.js +136 -0
- package/dist/cli/main-p0cfn6nr.js +16 -0
- package/dist/cli/main-qj2djy17.js +19 -0
- package/dist/cli/main-qsevpgsv.js +3 -0
- package/dist/cli/main-qvarybsp.js +3 -0
- package/dist/cli/main-rebtt91r.js +5 -0
- package/dist/cli/main-rpg7h8mb.js +3 -0
- package/dist/cli/main-rsy72qmw.js +15 -0
- package/dist/cli/main-rvetps99.js +18 -0
- package/dist/cli/main-s4bb0jav.js +3 -0
- package/dist/cli/main-s9v8k74e.js +3 -0
- package/dist/cli/main-tjvwmscs.js +3 -0
- package/dist/cli/main-tkgarpjj.js +4 -0
- package/dist/cli/main-v8y60bb2.js +3 -0
- package/dist/cli/main-vhrrq337.js +3 -0
- package/dist/cli/main-vp2dfb7s.js +4 -0
- package/dist/cli/main-vqbr22sz.js +8 -0
- package/dist/cli/main-vxnwe5xx.js +18 -0
- package/dist/cli/main-wgph00xf.js +5 -0
- package/dist/cli/main-wk2csfnj.js +5 -0
- package/dist/cli/main-wm997zjx.js +3 -0
- package/dist/cli/main-wpkyraxh.js +3 -0
- package/dist/cli/main-wqt32p5x.js +4 -0
- package/dist/cli/main-x9ct6y1a.js +3 -0
- package/dist/cli/main-xfekqh9m.js +7 -0
- package/dist/cli/main-xt9zc3n6.js +7 -0
- package/dist/cli/main-xx2z3zh5.js +4 -0
- package/dist/cli/main-y5c82rxr.js +3 -0
- package/dist/cli/main-yrjt2sqt.js +14 -0
- package/dist/cli/main-ys6zj3yr.js +3 -0
- package/dist/cli/main-ywbxshqc.js +8 -0
- package/dist/cli/main-z13755t8.js +25 -0
- package/dist/cli/main-zc7pyrbj.js +4 -0
- package/dist/cli/main.js +279 -0
- package/dist/cli/market-cmd-bm5xvn9f.js +5 -0
- package/dist/cli/mcp-login-bthtfpt7.js +2 -0
- package/dist/cli/mcp-market-cmd-mbeshfyd.js +2 -0
- package/dist/cli/notify-54v5z9dz.js +2 -0
- package/dist/cli/oauth-g5gme95c.js +2 -0
- package/dist/cli/output-satndjap.js +16 -0
- package/dist/cli/profiles-sfhpbq3m.js +2 -0
- package/dist/cli/provider-config-hv3xtdt4.js +2 -0
- package/dist/cli/provider-kwzq6g84.js +2 -0
- package/dist/cli/registry-fh0hdnyn.js +2 -0
- package/dist/cli/registry-y1y8e94r.js +2 -0
- package/dist/cli/repl-t4z03mqq.js +11 -0
- package/dist/cli/resume-fqt4chg8.js +2 -0
- package/dist/cli/run-flags-rysbag9t.js +2 -0
- package/dist/cli/runtime-j19fjbsa.js +2 -0
- package/dist/cli/sandbox-config-g4qxd7y5.js +2 -0
- package/dist/cli/server-r0b6bksk.js +5 -0
- package/dist/cli/session-arg-txmn5g4x.js +2 -0
- package/dist/cli/session-ed250d9j.js +2 -0
- package/dist/cli/sessions-cmd-adw7svfn.js +7 -0
- package/dist/cli/settings-y9rzcqx8.js +2 -0
- package/dist/cli/setup-jmbr11j0.js +2 -0
- package/dist/cli/sextant-smoke-tcth0vea.js +5 -0
- package/dist/cli/skills-cmd-zbdy99v6.js +2 -0
- package/dist/cli/smoke-1bg937kx.js +8 -0
- package/dist/cli/start-chat-p01cdks3.js +12 -0
- package/dist/cli/stream-4wmyaypz.js +2 -0
- package/dist/cli/task-eg4s093s.js +2 -0
- package/dist/cli/tasks-12v9rr9k.js +2 -0
- package/dist/cli/thinking-a5ngvqyh.js +2 -0
- package/dist/cli/todo-1wxpcecx.js +2 -0
- package/dist/cli/tools-2ftsya7w.js +2 -0
- package/dist/cli/tools-x1tj4fxm.js +2 -0
- package/dist/cli/trust-cmd-hccxehzb.js +2 -0
- package/dist/cli/update-check-ygt3vd7m.js +2 -0
- package/dist/cli/update-cmd-v23qhr8c.js +2 -0
- package/dist/cli/voice-g1gtck92.js +2 -0
- package/dist/cli/webfetch-0nnrjgb5.js +2 -0
- package/dist/cli/websearch-f0vr2p7d.js +2 -0
- package/dist/cli/workspace-9rq1w4ta.js +2 -0
- package/dist/lib/index.js +62 -0
- package/dist/lib/models-index.json +1 -0
- package/dist/lib/plugins.js +6 -0
- package/dist/lib/providers.js +17 -0
- package/dist/lib/public-api.js +20 -0
- package/dist/rovecode.exe +4 -0
- package/package.json +83 -72
- package/bin/rovecode.ts +0 -21
- package/src/acp/server.ts +0 -374
- package/src/cli/auth-login.ts +0 -122
- package/src/cli/connect.ts +0 -244
- package/src/cli/context-cmd.ts +0 -199
- package/src/cli/dispatch.ts +0 -82
- package/src/cli/doctor.ts +0 -362
- package/src/cli/export.ts +0 -276
- package/src/cli/help.ts +0 -293
- package/src/cli/is-tui-invocation.ts +0 -8
- package/src/cli/main.ts +0 -583
- package/src/cli/market-cmd.ts +0 -658
- package/src/cli/mcp-login.ts +0 -141
- package/src/cli/mcp-market-cmd.ts +0 -302
- package/src/cli/output.ts +0 -382
- package/src/cli/repl.ts +0 -250
- package/src/cli/repomap-root.ts +0 -14
- package/src/cli/resume.ts +0 -57
- package/src/cli/run-flags.ts +0 -43
- package/src/cli/run-limits.ts +0 -78
- package/src/cli/runtime.ts +0 -931
- package/src/cli/session-arg.ts +0 -30
- package/src/cli/sessions-cmd.ts +0 -145
- package/src/cli/setup.ts +0 -153
- package/src/cli/skills-cmd.ts +0 -194
- package/src/cli/start-chat.ts +0 -65
- package/src/cli/trust-cmd.ts +0 -52
- package/src/coding/bash.ts +0 -148
- package/src/coding/checkpoints.ts +0 -327
- package/src/coding/diff.ts +0 -138
- package/src/coding/files.ts +0 -341
- package/src/coding/hashline.ts +0 -274
- package/src/coding/lsp-gate.ts +0 -254
- package/src/coding/lsp-servers.ts +0 -147
- package/src/coding/lsp.ts +0 -283
- package/src/coding/repomap-cache.ts +0 -99
- package/src/coding/repomap-files.ts +0 -192
- package/src/coding/repomap.ts +0 -481
- package/src/core/agents.ts +0 -255
- package/src/core/compaction.ts +0 -259
- package/src/core/config.ts +0 -289
- package/src/core/context-report.ts +0 -228
- package/src/core/context.ts +0 -60
- package/src/core/count-remote.ts +0 -107
- package/src/core/execpolicy-rules.ts +0 -196
- package/src/core/execpolicy.ts +0 -385
- package/src/core/executor.ts +0 -454
- package/src/core/guardrails.ts +0 -400
- package/src/core/hooks.ts +0 -411
- package/src/core/images.ts +0 -230
- package/src/core/intro.ts +0 -266
- package/src/core/loop.ts +0 -567
- package/src/core/modes.ts +0 -372
- package/src/core/orchestrator.ts +0 -245
- package/src/core/proc-group.ts +0 -48
- package/src/core/project-trust.ts +0 -98
- package/src/core/reflection.ts +0 -165
- package/src/core/sandbox-config.ts +0 -186
- package/src/core/session-id.ts +0 -24
- package/src/core/session-images.ts +0 -73
- package/src/core/session-ops.ts +0 -183
- package/src/core/session-text.ts +0 -29
- package/src/core/session.ts +0 -469
- package/src/core/settings.ts +0 -170
- package/src/core/tasks.ts +0 -646
- package/src/core/token-scale.ts +0 -108
- package/src/core/tools.ts +0 -309
- package/src/core/trust.ts +0 -104
- package/src/core/types.ts +0 -330
- package/src/core/update-check.ts +0 -171
- package/src/core/usage.ts +0 -204
- package/src/core/validate.ts +0 -121
- package/src/core/verify-gate.ts +0 -159
- package/src/core/verify.ts +0 -236
- package/src/core/voice.ts +0 -158
- package/src/core/win-job.ts +0 -183
- package/src/core/workspace.ts +0 -184
- package/src/design/audit.ts +0 -797
- package/src/design/direction.ts +0 -190
- package/src/design/rules.ts +0 -157
- package/src/eval/bench.ts +0 -150
- package/src/eval/gauntlet-runner.ts +0 -215
- package/src/eval/gauntlet-support.ts +0 -84
- package/src/eval/gauntlet-wave3.ts +0 -269
- package/src/eval/gauntlet-wave4.ts +0 -217
- package/src/eval/gauntlet.ts +0 -253
- package/src/index.ts +0 -17
- package/src/lanes/agy.ts +0 -95
- package/src/lanes/approval.ts +0 -24
- package/src/lanes/claude.ts +0 -129
- package/src/lanes/codex.ts +0 -127
- package/src/lanes/events.ts +0 -130
- package/src/lanes/job.ts +0 -142
- package/src/lanes/opencode.ts +0 -122
- package/src/lanes/process.ts +0 -184
- package/src/lanes/progress.ts +0 -183
- package/src/lanes/registry.ts +0 -178
- package/src/lanes/runner.ts +0 -124
- package/src/lanes/types.ts +0 -112
- package/src/market/catalogs/mcp-docs.json +0 -111
- package/src/market/catalogs/plugins.json +0 -111
- package/src/market/catalogs/skills.json +0 -478
- package/src/market/clone.ts +0 -72
- package/src/market/context-cost.ts +0 -121
- package/src/market/digest.ts +0 -106
- package/src/market/index.ts +0 -22
- package/src/market/install.ts +0 -578
- package/src/market/manifest.ts +0 -187
- package/src/market/prereq.ts +0 -145
- package/src/market/registry.ts +0 -363
- package/src/market/resolve.ts +0 -111
- package/src/market/types.ts +0 -236
- package/src/market/validate.ts +0 -227
- package/src/mcp/client.ts +0 -449
- package/src/mcp/config.ts +0 -252
- package/src/mcp/local-package.ts +0 -211
- package/src/mcp/market-catalog.ts +0 -84
- package/src/mcp/market-install.ts +0 -289
- package/src/mcp/market.ts +0 -362
- package/src/mcp/oauth.ts +0 -251
- package/src/mcp/prompts-resources.ts +0 -249
- package/src/mcp/shared.ts +0 -149
- package/src/mcp/status.ts +0 -67
- package/src/mcp/tools.ts +0 -275
- package/src/mcp/transport.ts +0 -122
- package/src/mcp/trust.ts +0 -25
- package/src/memory/blocks.ts +0 -278
- package/src/memory/recall.ts +0 -355
- package/src/memory/scope.ts +0 -182
- package/src/memory/store.ts +0 -105
- package/src/memory/tools.ts +0 -99
- package/src/plugins/cli.ts +0 -119
- package/src/plugins/discover.ts +0 -108
- package/src/plugins/index.ts +0 -50
- package/src/plugins/install.ts +0 -184
- package/src/plugins/load.ts +0 -124
- package/src/plugins/manifest.ts +0 -92
- package/src/plugins/state.ts +0 -83
- package/src/providers/auth.ts +0 -408
- package/src/providers/cache.ts +0 -223
- package/src/providers/catalog-local.ts +0 -160
- package/src/providers/catalog.ts +0 -421
- package/src/providers/middleware-context.ts +0 -86
- package/src/providers/middleware.ts +0 -373
- package/src/providers/model-list.ts +0 -23
- package/src/providers/oauth/common.ts +0 -105
- package/src/providers/oauth/device-code.ts +0 -107
- package/src/providers/oauth/github-copilot.ts +0 -146
- package/src/providers/oauth/loopback.ts +0 -158
- package/src/providers/oauth/openai.ts +0 -163
- package/src/providers/oauth/openrouter.ts +0 -89
- package/src/providers/oauth/pkce.ts +0 -45
- package/src/providers/oauth/registry.ts +0 -39
- package/src/providers/oauth/seam.ts +0 -89
- package/src/providers/profile-glm53.ts +0 -111
- package/src/providers/profile-sonnet5-persona.ts +0 -65
- package/src/providers/profile-sonnet5-voice.ts +0 -23
- package/src/providers/profiles.ts +0 -156
- package/src/providers/provider-config.ts +0 -311
- package/src/providers/registry.ts +0 -333
- package/src/providers/responses.ts +0 -209
- package/src/providers/retry.ts +0 -234
- package/src/providers/router.ts +0 -294
- package/src/providers/sse.ts +0 -26
- package/src/providers/stream-errors.ts +0 -117
- package/src/providers/stream.ts +0 -566
- package/src/providers/thinking.ts +0 -189
- package/src/providers/wire-messages.ts +0 -129
- package/src/providers/wire-responses.ts +0 -79
- package/src/providers/wire-select.ts +0 -53
- package/src/server/http.ts +0 -291
- package/src/server/openapi.ts +0 -246
- package/src/sextant/card-hits.ts +0 -102
- package/src/sextant/card-keys.ts +0 -55
- package/src/sextant/context-source.ts +0 -157
- package/src/sextant/crew-cards.ts +0 -350
- package/src/sextant/draw-agents.ts +0 -273
- package/src/sextant/draw-code.ts +0 -388
- package/src/sextant/draw-context.ts +0 -222
- package/src/sextant/draw-frame.ts +0 -164
- package/src/sextant/draw-market.ts +0 -573
- package/src/sextant/draw-messages.ts +0 -386
- package/src/sextant/draw-pet.ts +0 -230
- package/src/sextant/draw-plan.ts +0 -187
- package/src/sextant/draw-tabs.ts +0 -85
- package/src/sextant/draw-util.ts +0 -65
- package/src/sextant/draw-wizard.ts +0 -378
- package/src/sextant/engine.ts +0 -230
- package/src/sextant/frame-hits.ts +0 -25
- package/src/sextant/frame.ts +0 -101
- package/src/sextant/git-status.ts +0 -197
- package/src/sextant/grid.ts +0 -59
- package/src/sextant/input.ts +0 -119
- package/src/sextant/keys.ts +0 -521
- package/src/sextant/layout.ts +0 -86
- package/src/sextant/local-commands.ts +0 -169
- package/src/sextant/market-source.ts +0 -287
- package/src/sextant/mentions.ts +0 -200
- package/src/sextant/message-hits.ts +0 -26
- package/src/sextant/model.ts +0 -387
- package/src/sextant/overlays.ts +0 -456
- package/src/sextant/panel-hits.ts +0 -38
- package/src/sextant/pet.ts +0 -399
- package/src/sextant/screen.ts +0 -324
- package/src/sextant/scroll-hits.ts +0 -66
- package/src/sextant/scrollbar.ts +0 -82
- package/src/sextant/sextant-bridge.ts +0 -174
- package/src/sextant/sextant-cards.ts +0 -142
- package/src/sextant/sextant-diff-base.ts +0 -63
- package/src/sextant/sextant-files.ts +0 -154
- package/src/sextant/sextant-frame-loop.ts +0 -335
- package/src/sextant/sextant-renderer.ts +0 -574
- package/src/sextant/sextant-repo.ts +0 -140
- package/src/sextant/theme.ts +0 -66
- package/src/sextant/tool-rows.ts +0 -189
- package/src/sextant/types.ts +0 -493
- package/src/skills/index.ts +0 -387
- package/src/skills/pack.ts +0 -220
- package/src/skills/spec.ts +0 -162
- package/src/skills/tools.ts +0 -69
- package/src/skills/versioned.ts +0 -227
- package/src/telemetry/otel-export.ts +0 -122
- package/src/telemetry/otel-lanes.ts +0 -89
- package/src/telemetry/otel-logs.ts +0 -131
- package/src/telemetry/otel-metrics.ts +0 -136
- package/src/telemetry/otel.ts +0 -397
- package/src/telemetry/otlp.ts +0 -76
- package/src/tools/ask-user.ts +0 -156
- package/src/tools/bash-bg.ts +0 -94
- package/src/tools/bash-jobs.ts +0 -237
- package/src/tools/design.ts +0 -151
- package/src/tools/evalcell.ts +0 -338
- package/src/tools/html-text.ts +0 -139
- package/src/tools/provider.ts +0 -149
- package/src/tools/task.ts +0 -250
- package/src/tools/todo.ts +0 -320
- package/src/tools/webfetch.ts +0 -332
- package/src/tools/websearch.ts +0 -359
- package/src/tui/agents-cmd.ts +0 -41
- package/src/tui/app.ts +0 -749
- package/src/tui/attach.ts +0 -127
- package/src/tui/boot-notes.ts +0 -41
- package/src/tui/builtin-prompts.ts +0 -59
- package/src/tui/checkpoints-cmd.ts +0 -70
- package/src/tui/clipboard-image.ts +0 -81
- package/src/tui/clipboard.ts +0 -78
- package/src/tui/commands.ts +0 -283
- package/src/tui/config-view.ts +0 -53
- package/src/tui/context-cmds.ts +0 -282
- package/src/tui/cost.ts +0 -108
- package/src/tui/crash-guard.ts +0 -173
- package/src/tui/focus-terminal.ts +0 -34
- package/src/tui/git-cmds.ts +0 -273
- package/src/tui/git-plain.ts +0 -58
- package/src/tui/info-cmd.ts +0 -150
- package/src/tui/input-plain.ts +0 -76
- package/src/tui/mcp-cmd.ts +0 -128
- package/src/tui/memory-note.ts +0 -77
- package/src/tui/modes-cmd.ts +0 -45
- package/src/tui/notify-seq.ts +0 -100
- package/src/tui/notify.ts +0 -318
- package/src/tui/overlays.ts +0 -97
- package/src/tui/pi-renderer.ts +0 -428
- package/src/tui/providers-cmd.ts +0 -377
- package/src/tui/reasoning-view.ts +0 -56
- package/src/tui/renderer.ts +0 -128
- package/src/tui/replay-marker.ts +0 -29
- package/src/tui/session-cmd.ts +0 -148
- package/src/tui/session-manage.ts +0 -95
- package/src/tui/sextant-attach.ts +0 -102
- package/src/tui/sextant-io.ts +0 -202
- package/src/tui/sextant-smoke.ts +0 -110
- package/src/tui/shell-cmd.ts +0 -158
- package/src/tui/smoke.ts +0 -72
- package/src/tui/staged-terminal.ts +0 -50
- package/src/tui/startup.ts +0 -12
- package/src/tui/theme.ts +0 -59
- package/src/tui/todo-label.ts +0 -7
- package/src/tui/trust-card.ts +0 -107
- package/src/tui/tui-commands.ts +0 -87
- package/tsconfig.json +0 -30
- package/vendor/pi-tui/LICENSE +0 -21
- package/vendor/pi-tui/PATCHES.md +0 -12
- package/vendor/pi-tui/PROVENANCE.md +0 -12
- package/vendor/pi-tui/README.upstream.md +0 -854
- package/vendor/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/vendor/pi-tui/src/alt-screen-search.ts +0 -158
- package/vendor/pi-tui/src/autocomplete.ts +0 -827
- package/vendor/pi-tui/src/components/alt-screen-flash.ts +0 -52
- package/vendor/pi-tui/src/components/box.ts +0 -138
- package/vendor/pi-tui/src/components/cancellable-loader.ts +0 -41
- package/vendor/pi-tui/src/components/editor.ts +0 -2364
- package/vendor/pi-tui/src/components/h-stack.ts +0 -45
- package/vendor/pi-tui/src/components/image.ts +0 -128
- package/vendor/pi-tui/src/components/input.ts +0 -448
- package/vendor/pi-tui/src/components/loader.ts +0 -93
- package/vendor/pi-tui/src/components/markdown.ts +0 -1016
- package/vendor/pi-tui/src/components/scroll-view.ts +0 -217
- package/vendor/pi-tui/src/components/select-list.ts +0 -230
- package/vendor/pi-tui/src/components/settings-list.ts +0 -277
- package/vendor/pi-tui/src/components/spacer.ts +0 -29
- package/vendor/pi-tui/src/components/stack.ts +0 -155
- package/vendor/pi-tui/src/components/text.ts +0 -108
- package/vendor/pi-tui/src/components/truncated-text.ts +0 -66
- package/vendor/pi-tui/src/components/v-stack.ts +0 -34
- package/vendor/pi-tui/src/editor-component.ts +0 -75
- package/vendor/pi-tui/src/fuzzy.ts +0 -138
- package/vendor/pi-tui/src/index.ts +0 -149
- package/vendor/pi-tui/src/keybindings.ts +0 -321
- package/vendor/pi-tui/src/keys.ts +0 -1402
- package/vendor/pi-tui/src/kill-ring.ts +0 -47
- package/vendor/pi-tui/src/latex.ts +0 -1381
- package/vendor/pi-tui/src/layout-node.ts +0 -52
- package/vendor/pi-tui/src/layout.ts +0 -411
- package/vendor/pi-tui/src/native-modifiers.ts +0 -60
- package/vendor/pi-tui/src/native-module-path.ts +0 -32
- package/vendor/pi-tui/src/stdin-buffer.ts +0 -445
- package/vendor/pi-tui/src/terminal-colors.ts +0 -74
- package/vendor/pi-tui/src/terminal-image.ts +0 -701
- package/vendor/pi-tui/src/terminal.ts +0 -554
- package/vendor/pi-tui/src/tui-alt-screen.ts +0 -1379
- package/vendor/pi-tui/src/tui-main-screen.ts +0 -655
- package/vendor/pi-tui/src/tui.ts +0 -1264
- package/vendor/pi-tui/src/undo-stack.ts +0 -29
- package/vendor/pi-tui/src/utils.ts +0 -1327
- package/vendor/pi-tui/src/word-navigation.ts +0 -118
- package/vendor/pi-tui/test/test-themes.ts +0 -39
- package/vendor/pi-tui/test/virtual-terminal.ts +0 -219
- /package/{src/providers → dist/cli}/models-index.json +0 -0
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
/** Provider configuration — the DATA half of the provider layer (no adapters, no network).
|
|
2
|
-
*
|
|
3
|
-
* Sources, merged per provider id in this order (later wins):
|
|
4
|
-
* 1. BUILTIN_PROVIDERS (the table below) scope "builtin"
|
|
5
|
-
* 2. ~/.rovecode/providers.json (ROVECODE_HOME-aware) scope "user"
|
|
6
|
-
* 3. <cwd>/.rovecode/providers.json scope "project"
|
|
7
|
-
* 4. ROVECODE_BASE_URL + ROVECODE_API_KEY scope "env" — the "custom" provider, always the default
|
|
8
|
-
*
|
|
9
|
-
* File shape (both scopes):
|
|
10
|
-
* { "default"?: "provider/model",
|
|
11
|
-
* "providers"?: { "<id>": { "baseUrl", "protocol"?, "keyEnv"?, "defaultModel"?, "models"?, "headers"?, "noKey"? } } }
|
|
12
|
-
*
|
|
13
|
-
* Secrets never live in providers.json. A provider's key is the stored credential (auth.ts,
|
|
14
|
-
* `rovecode auth set <id>`, masked prompt) else process.env[keyEnv ?? keyNameFor(id)]; `noKey: true`
|
|
15
|
-
* marks local servers (ollama, vllm) that need none. The `default` selector is "provider/model"
|
|
16
|
-
* split on the FIRST slash (router.ts grammar) — a bare provider id selects its defaultModel.
|
|
17
|
-
*
|
|
18
|
-
* Hot reload: ProviderConfig.snapshot() re-reads when the mtime or size of any source file changed
|
|
19
|
-
* (both providers.json + credentials.json), checked at most once per `throttleMs`. A provider added
|
|
20
|
-
* from another terminal — or by the agent through provider_edit — is live on the next model call;
|
|
21
|
-
* no restart. resolveProvider() (stream.ts) is the one-shot form of the same merge, so the CLI and
|
|
22
|
-
* a long-running TUI always agree on what "the default provider" is. */
|
|
23
|
-
|
|
24
|
-
import { mkdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
|
|
25
|
-
import { dirname, join } from "node:path";
|
|
26
|
-
import { credentialsPath, keyNameFor, loadCredentials, rovecodeHome, type StoredCredential } from "./auth.ts";
|
|
27
|
-
|
|
28
|
-
export type ProviderProtocol = "openai" | "anthropic";
|
|
29
|
-
export type ProviderScope = "builtin" | "user" | "project" | "env";
|
|
30
|
-
/** where a provider's key came from: stored credential, env var, the ROVECODE_API_KEY pair, or nowhere */
|
|
31
|
-
export type KeySource = "stored" | "env" | "inline" | "none";
|
|
32
|
-
|
|
33
|
-
export interface ProviderSpec {
|
|
34
|
-
id: string;
|
|
35
|
-
baseUrl: string;
|
|
36
|
-
protocol: ProviderProtocol;
|
|
37
|
-
/** env var consulted when no credential is stored; default keyNameFor(id) (models.dev name or <ID>_API_KEY) */
|
|
38
|
-
keyEnv?: string;
|
|
39
|
-
defaultModel?: string;
|
|
40
|
-
/** static model list for `/models` when the endpoint has no /models route */
|
|
41
|
-
models?: string[];
|
|
42
|
-
/** extra request headers (proxies, org ids) — sent on every call to this provider */
|
|
43
|
-
headers?: Record<string, string>;
|
|
44
|
-
/** local servers: no key required, the provider counts as configured without one */
|
|
45
|
-
noKey?: boolean;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export interface ResolvedProvider extends ProviderSpec {
|
|
49
|
-
keyEnv: string;
|
|
50
|
-
scope: ProviderScope;
|
|
51
|
-
apiKey: string | null;
|
|
52
|
-
keySource: KeySource;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export const BUILTIN_PROVIDERS: readonly ProviderSpec[] = [
|
|
56
|
-
{ id: "kaesra", baseUrl: "https://api.kaesra.tech/v1", protocol: "openai", keyEnv: "KAESRA_API_KEY", defaultModel: "zai-org/glm-5.3-flash" },
|
|
57
|
-
{ id: "openai", baseUrl: "https://api.openai.com/v1", protocol: "openai", keyEnv: "OPENAI_API_KEY" },
|
|
58
|
-
{ id: "anthropic", baseUrl: "https://api.anthropic.com/v1", protocol: "anthropic", keyEnv: "ANTHROPIC_API_KEY", defaultModel: "claude-opus-5" },
|
|
59
|
-
{ id: "deepseek", baseUrl: "https://api.deepseek.com/v1", protocol: "openai", keyEnv: "DEEPSEEK_API_KEY" },
|
|
60
|
-
{ id: "groq", baseUrl: "https://api.groq.com/openai/v1", protocol: "openai", keyEnv: "GROQ_API_KEY" },
|
|
61
|
-
{ id: "openrouter", baseUrl: "https://openrouter.ai/api/v1", protocol: "openai", keyEnv: "OPENROUTER_API_KEY" },
|
|
62
|
-
{ id: "ollama", baseUrl: "http://127.0.0.1:11434/v1", protocol: "openai", keyEnv: "OLLAMA_API_KEY" },
|
|
63
|
-
{ id: "lmstudio", baseUrl: "http://127.0.0.1:1234/v1", protocol: "openai", keyEnv: "LMSTUDIO_API_KEY" },
|
|
64
|
-
{ id: "together", baseUrl: "https://api.together.xyz/v1", protocol: "openai", keyEnv: "TOGETHER_API_KEY" },
|
|
65
|
-
{ id: "mistral", baseUrl: "https://api.mistral.ai/v1", protocol: "openai", keyEnv: "MISTRAL_API_KEY" },
|
|
66
|
-
{ id: "cerebras", baseUrl: "https://api.cerebras.ai/v1", protocol: "openai", keyEnv: "CEREBRAS_API_KEY" },
|
|
67
|
-
{ id: "fireworks", baseUrl: "https://api.fireworks.ai/inference/v1", protocol: "openai", keyEnv: "FIREWORKS_API_KEY" },
|
|
68
|
-
{ id: "perplexity", baseUrl: "https://api.perplexity.ai", protocol: "openai", keyEnv: "PERPLEXITY_API_KEY" },
|
|
69
|
-
{ id: "xai", baseUrl: "https://api.x.ai/v1", protocol: "openai", keyEnv: "XAI_API_KEY" },
|
|
70
|
-
{ id: "moondream", baseUrl: "https://api.moondream.ai/v1", protocol: "openai", keyEnv: "MOONDREAM_API_KEY" },
|
|
71
|
-
{ id: "vllm", baseUrl: "http://127.0.0.1:8000/v1", protocol: "openai", keyEnv: "VLLM_API_KEY" },
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
// ---------- files ----------
|
|
75
|
-
|
|
76
|
-
/** one providers.json entry as written: baseUrl required, protocol may be omitted (inferred on read) */
|
|
77
|
-
export interface ProviderEntry extends Partial<Omit<ProviderSpec, "id" | "baseUrl">> { baseUrl: string }
|
|
78
|
-
|
|
79
|
-
export interface ProvidersFile {
|
|
80
|
-
default?: string;
|
|
81
|
-
providers?: Record<string, ProviderEntry>;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type FileScope = "user" | "project";
|
|
85
|
-
|
|
86
|
-
export function userProvidersPath(): string { return join(rovecodeHome(), "providers.json"); }
|
|
87
|
-
export function projectProvidersPath(cwd: string): string { return join(cwd, ".rovecode", "providers.json"); }
|
|
88
|
-
export function providersPathFor(scope: FileScope, cwd: string): string {
|
|
89
|
-
return scope === "project" ? projectProvidersPath(cwd) : userProvidersPath();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/** ids are lowercase slugs — they name env vars (keyNameFor) and appear in "provider/model" selectors */
|
|
93
|
-
export const PROVIDER_ID_RE = /^[a-z0-9][a-z0-9_.-]{0,39}$/;
|
|
94
|
-
const ENV_NAME_RE = /^[A-Z_][A-Z0-9_]*$/;
|
|
95
|
-
|
|
96
|
-
export function inferProtocol(baseUrl: string): ProviderProtocol {
|
|
97
|
-
return baseUrl.includes("anthropic.com") ? "anthropic" : "openai";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** Validate one provider entry (file entry or CLI/tool input) into a spec. Pure; never throws. */
|
|
101
|
-
export function validateSpec(id: string, raw: unknown): { spec: ProviderSpec } | { error: string } {
|
|
102
|
-
if (!PROVIDER_ID_RE.test(id)) return { error: `provider id "${id}" must be a lowercase slug (a-z 0-9 _ . -), at most 40 chars` };
|
|
103
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return { error: `provider "${id}": entry must be an object` };
|
|
104
|
-
const r = raw as Record<string, unknown>;
|
|
105
|
-
const baseUrl = typeof r["baseUrl"] === "string" ? r["baseUrl"].trim().replace(/\/+$/, "") : "";
|
|
106
|
-
if (!/^https?:\/\/[^\s/]+/.test(baseUrl)) return { error: `provider "${id}": baseUrl must be an http(s) URL` };
|
|
107
|
-
const protocol = r["protocol"] === undefined ? inferProtocol(baseUrl) : r["protocol"];
|
|
108
|
-
if (protocol !== "openai" && protocol !== "anthropic") return { error: `provider "${id}": protocol must be "openai" or "anthropic"` };
|
|
109
|
-
const spec: ProviderSpec = { id, baseUrl, protocol };
|
|
110
|
-
if (r["keyEnv"] !== undefined) {
|
|
111
|
-
if (typeof r["keyEnv"] !== "string" || !ENV_NAME_RE.test(r["keyEnv"])) return { error: `provider "${id}": keyEnv must be an ENV_VAR_NAME` };
|
|
112
|
-
spec.keyEnv = r["keyEnv"];
|
|
113
|
-
}
|
|
114
|
-
if (r["defaultModel"] !== undefined) {
|
|
115
|
-
if (typeof r["defaultModel"] !== "string" || r["defaultModel"].trim().length === 0) return { error: `provider "${id}": defaultModel must be a non-empty string` };
|
|
116
|
-
spec.defaultModel = r["defaultModel"].trim();
|
|
117
|
-
}
|
|
118
|
-
if (r["models"] !== undefined) {
|
|
119
|
-
if (!Array.isArray(r["models"]) || !r["models"].every((m) => typeof m === "string" && m.trim().length > 0)) return { error: `provider "${id}": models must be a list of model ids` };
|
|
120
|
-
spec.models = (r["models"] as string[]).map((m) => m.trim());
|
|
121
|
-
}
|
|
122
|
-
if (r["headers"] !== undefined) {
|
|
123
|
-
const h = r["headers"];
|
|
124
|
-
if (typeof h !== "object" || h === null || Array.isArray(h) || !Object.values(h as Record<string, unknown>).every((v) => typeof v === "string")) return { error: `provider "${id}": headers must be an object of strings` };
|
|
125
|
-
spec.headers = { ...(h as Record<string, string>) };
|
|
126
|
-
}
|
|
127
|
-
if (r["noKey"] !== undefined) {
|
|
128
|
-
if (typeof r["noKey"] !== "boolean") return { error: `provider "${id}": noKey must be true or false` };
|
|
129
|
-
if (r["noKey"]) spec.noKey = true;
|
|
130
|
-
}
|
|
131
|
-
return { spec };
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/** Read one providers.json: a missing file is {} silently; a corrupt file or a malformed entry is
|
|
135
|
-
* dropped with a warning, never fatal (auth.ts loadCredentials idiom). */
|
|
136
|
-
export function readProvidersFile(path: string): { data: ProvidersFile; warnings: string[] } {
|
|
137
|
-
let text: string;
|
|
138
|
-
try { text = readFileSync(path, "utf8"); } catch { return { data: {}, warnings: [] }; }
|
|
139
|
-
let parsed: unknown;
|
|
140
|
-
try { parsed = JSON.parse(text); } catch { return { data: {}, warnings: [`${path}: invalid JSON — ignored`] }; }
|
|
141
|
-
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) return { data: {}, warnings: [`${path}: expected an object — ignored`] };
|
|
142
|
-
const o = parsed as Record<string, unknown>;
|
|
143
|
-
const data: ProvidersFile = {};
|
|
144
|
-
const warnings: string[] = [];
|
|
145
|
-
if (o["default"] !== undefined) {
|
|
146
|
-
if (typeof o["default"] === "string" && o["default"].trim().length > 0) data.default = o["default"].trim();
|
|
147
|
-
else warnings.push(`${path}: "default" must be "provider/model" — ignored`);
|
|
148
|
-
}
|
|
149
|
-
if (o["providers"] !== undefined) {
|
|
150
|
-
const p = o["providers"];
|
|
151
|
-
if (typeof p !== "object" || p === null || Array.isArray(p)) warnings.push(`${path}: "providers" must be an object — ignored`);
|
|
152
|
-
else {
|
|
153
|
-
data.providers = {};
|
|
154
|
-
for (const [id, raw] of Object.entries(p as Record<string, unknown>)) {
|
|
155
|
-
const v = validateSpec(id, raw);
|
|
156
|
-
if ("error" in v) { warnings.push(`${path}: ${v.error} — ignored`); continue; }
|
|
157
|
-
const { id: _id, ...rest } = v.spec;
|
|
158
|
-
data.providers[id] = rest;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return { data, warnings };
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function writeProvidersFile(path: string, data: ProvidersFile): void {
|
|
166
|
-
mkdirSync(dirname(path), { recursive: true });
|
|
167
|
-
writeFileSync(path, JSON.stringify(data, null, 2) + "\n");
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// ---------- merge ----------
|
|
171
|
-
|
|
172
|
-
export interface ProviderSnapshot {
|
|
173
|
-
/** builtins in table order, then file-only providers in file order, then the env "custom" provider */
|
|
174
|
-
providers: ResolvedProvider[];
|
|
175
|
-
/** the `default` selector — project file beats user file */
|
|
176
|
-
defaultSelector?: string;
|
|
177
|
-
defaultScope?: FileScope;
|
|
178
|
-
warnings: string[];
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export function resolveKey(spec: ProviderSpec, scope: ProviderScope, env: NodeJS.ProcessEnv, creds: Record<string, StoredCredential>): ResolvedProvider {
|
|
182
|
-
const keyEnv = spec.keyEnv ?? keyNameFor(spec.id);
|
|
183
|
-
const stored = creds[spec.id]?.key;
|
|
184
|
-
if (stored !== undefined && stored.trim().length > 0) return { ...spec, keyEnv, scope, apiKey: stored, keySource: "stored" };
|
|
185
|
-
const fromEnv = env[keyEnv];
|
|
186
|
-
if (fromEnv !== undefined && fromEnv.trim().length > 0) return { ...spec, keyEnv, scope, apiKey: fromEnv, keySource: "env" };
|
|
187
|
-
return { ...spec, keyEnv, scope, apiKey: null, keySource: "none" };
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
/** The ROVECODE_BASE_URL/ROVECODE_API_KEY pair (ROVECODE_API_KEY falls back to OPENAI_API_KEY, as before). */
|
|
191
|
-
export function envCustomProvider(env: NodeJS.ProcessEnv): ResolvedProvider | null {
|
|
192
|
-
const base = env["ROVECODE_BASE_URL"];
|
|
193
|
-
const key = env["ROVECODE_API_KEY"] ?? env["OPENAI_API_KEY"];
|
|
194
|
-
if (!base || !key) return null;
|
|
195
|
-
return {
|
|
196
|
-
id: "custom", baseUrl: base, protocol: inferProtocol(base), keyEnv: "ROVECODE_API_KEY", scope: "env", apiKey: key, keySource: "inline",
|
|
197
|
-
...(env["ROVECODE_MODEL"] ? { defaultModel: env["ROVECODE_MODEL"] } : {}),
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
export function isConfigured(p: ResolvedProvider): boolean {
|
|
202
|
-
return p.apiKey !== null || p.noKey === true;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export function buildSnapshot(cwd: string, env: NodeJS.ProcessEnv = process.env): ProviderSnapshot {
|
|
206
|
-
const warnings: string[] = [];
|
|
207
|
-
const order: string[] = [];
|
|
208
|
-
const specs = new Map<string, { spec: ProviderSpec; scope: ProviderScope }>();
|
|
209
|
-
for (const b of BUILTIN_PROVIDERS) { specs.set(b.id, { spec: b, scope: "builtin" }); order.push(b.id); }
|
|
210
|
-
let defaultSelector: string | undefined;
|
|
211
|
-
let defaultScope: FileScope | undefined;
|
|
212
|
-
const layer = (path: string, scope: FileScope): void => {
|
|
213
|
-
const { data, warnings: w } = readProvidersFile(path);
|
|
214
|
-
warnings.push(...w);
|
|
215
|
-
for (const [id, rest] of Object.entries(data.providers ?? {})) {
|
|
216
|
-
const prev = specs.get(id);
|
|
217
|
-
specs.set(id, { spec: { ...(prev?.spec ?? {}), ...rest, id } as ProviderSpec, scope });
|
|
218
|
-
if (prev === undefined) order.push(id);
|
|
219
|
-
}
|
|
220
|
-
if (data.default !== undefined) { defaultSelector = data.default; defaultScope = scope; }
|
|
221
|
-
};
|
|
222
|
-
layer(userProvidersPath(), "user");
|
|
223
|
-
layer(projectProvidersPath(cwd), "project");
|
|
224
|
-
const creds = loadCredentials();
|
|
225
|
-
const providers = order.map((id) => { const e = specs.get(id)!; return resolveKey(e.spec, e.scope, env, creds); });
|
|
226
|
-
const custom = envCustomProvider(env);
|
|
227
|
-
if (custom) providers.push(custom);
|
|
228
|
-
return { providers, ...(defaultSelector !== undefined ? { defaultSelector, defaultScope } : {}), warnings };
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
// ---------- selection ----------
|
|
232
|
-
|
|
233
|
-
export interface Selection { provider: string; model?: string }
|
|
234
|
-
|
|
235
|
-
/** "provider/model" split on the FIRST slash so model ids keep their own slashes; a bare id is a provider. */
|
|
236
|
-
export function parseSelector(selector: string): Selection {
|
|
237
|
-
const s = selector.trim();
|
|
238
|
-
const i = s.indexOf("/");
|
|
239
|
-
if (i <= 0) return { provider: s };
|
|
240
|
-
const model = s.slice(i + 1).trim();
|
|
241
|
-
return model.length > 0 ? { provider: s.slice(0, i), model } : { provider: s.slice(0, i) };
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
export interface DefaultPick { provider: ResolvedProvider; model?: string; via: "env-pair" | "default" | "stored" | "env-key" | "no-key" }
|
|
245
|
-
|
|
246
|
-
/** The default provider (+ its model, when one is known WITHOUT env ROVECODE_MODEL — callers layer
|
|
247
|
-
* that on top): env pair > file `default` (when that provider is configured) > first stored
|
|
248
|
-
* credential in order > first env key in order > first keyless file provider > null. The first
|
|
249
|
-
* three ranks are resolveProvider()'s historical precedence, pinned by test/unit/auth.test.ts. */
|
|
250
|
-
export function pickDefault(snap: ProviderSnapshot): DefaultPick | null {
|
|
251
|
-
const custom = snap.providers.find((p) => p.scope === "env");
|
|
252
|
-
if (custom) return { provider: custom, model: custom.defaultModel, via: "env-pair" };
|
|
253
|
-
if (snap.defaultSelector !== undefined) {
|
|
254
|
-
const sel = parseSelector(snap.defaultSelector);
|
|
255
|
-
const p = snap.providers.find((x) => x.id === sel.provider);
|
|
256
|
-
if (p && isConfigured(p)) return { provider: p, model: sel.model ?? p.defaultModel, via: "default" };
|
|
257
|
-
}
|
|
258
|
-
const stored = snap.providers.find((p) => p.keySource === "stored");
|
|
259
|
-
if (stored) return { provider: stored, model: stored.defaultModel, via: "stored" };
|
|
260
|
-
const fromEnv = snap.providers.find((p) => p.keySource === "env");
|
|
261
|
-
if (fromEnv) return { provider: fromEnv, model: fromEnv.defaultModel, via: "env-key" };
|
|
262
|
-
const noKey = snap.providers.find((p) => p.noKey === true);
|
|
263
|
-
if (noKey) return { provider: noKey, model: noKey.defaultModel, via: "no-key" };
|
|
264
|
-
return null;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// ---------- live view (hot reload) ----------
|
|
268
|
-
|
|
269
|
-
export class ProviderConfig {
|
|
270
|
-
private snap: ProviderSnapshot | null = null;
|
|
271
|
-
private stamp = "";
|
|
272
|
-
private checkedAt = -Infinity;
|
|
273
|
-
private readonly listeners = new Set<(snap: ProviderSnapshot) => void>();
|
|
274
|
-
|
|
275
|
-
constructor(
|
|
276
|
-
private readonly cwd: string,
|
|
277
|
-
private readonly env: NodeJS.ProcessEnv = process.env,
|
|
278
|
-
private readonly throttleMs = 250,
|
|
279
|
-
) {}
|
|
280
|
-
|
|
281
|
-
/** the files whose mtime/size drive reloads */
|
|
282
|
-
sourcePaths(): string[] { return [userProvidersPath(), projectProvidersPath(this.cwd), credentialsPath()]; }
|
|
283
|
-
|
|
284
|
-
private stampNow(): string {
|
|
285
|
-
return this.sourcePaths().map((p) => { try { const s = statSync(p); return `${s.mtimeMs}:${s.size}`; } catch { return "-"; } }).join("|");
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/** Current merged view. Re-reads when a source file changed (checked at most every throttleMs);
|
|
289
|
-
* listeners fire on every rebuild after the first. */
|
|
290
|
-
snapshot(): ProviderSnapshot {
|
|
291
|
-
const now = Date.now();
|
|
292
|
-
if (this.snap !== null && now - this.checkedAt < this.throttleMs) return this.snap;
|
|
293
|
-
this.checkedAt = now;
|
|
294
|
-
const stamp = this.stampNow();
|
|
295
|
-
if (this.snap === null || stamp !== this.stamp) {
|
|
296
|
-
const first = this.snap === null;
|
|
297
|
-
this.stamp = stamp;
|
|
298
|
-
this.snap = buildSnapshot(this.cwd, this.env);
|
|
299
|
-
if (!first) for (const cb of this.listeners) cb(this.snap);
|
|
300
|
-
}
|
|
301
|
-
return this.snap;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
/** Force a re-read on the next snapshot() (in-process writers call this right after writing). */
|
|
305
|
-
invalidate(): void { this.checkedAt = -Infinity; this.stamp = ""; }
|
|
306
|
-
|
|
307
|
-
onChange(cb: (snap: ProviderSnapshot) => void): () => void {
|
|
308
|
-
this.listeners.add(cb);
|
|
309
|
-
return () => { this.listeners.delete(cb); };
|
|
310
|
-
}
|
|
311
|
-
}
|
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
/** Live provider registry — the ADAPTER half of the provider layer, over provider-config.ts (data).
|
|
2
|
-
*
|
|
3
|
-
* One registry per runtime. stream() returns a DISPATCHING StreamFn: every call resolves
|
|
4
|
-
* `model.provider` against the live snapshot (hot reload — provider-config.ts), so a provider added
|
|
5
|
-
* from another terminal, by `rovecode provider add`, by `/provider add` in the TUI or by the agent's
|
|
6
|
-
* provider_edit tool serves the very next model call. No restart, no runtime rebuild. Concrete
|
|
7
|
-
* adapters (stream.ts) are cached per provider id and rebuilt when baseUrl, protocol, key or
|
|
8
|
-
* headers change — a rotated key takes effect on the next call too.
|
|
9
|
-
*
|
|
10
|
-
* Seam contract (ADR-003): the dispatcher never throws. An unknown provider or a missing key is ONE
|
|
11
|
-
* error turn whose text starts with `config: ` — router.ts classifyStreamError treats that prefix
|
|
12
|
-
* as non-retryable, so neither the same-model retry (port #23) nor a fallback chain (port #14)
|
|
13
|
-
* spins on a configuration mistake; the text tells the human exactly how to fix it.
|
|
14
|
-
*
|
|
15
|
-
* Because the dispatcher honours model.provider per call, cross-provider fallback chains
|
|
16
|
-
* (ROVECODE_MODEL_<ROLE>=a/x,b/y) now really route each candidate to its own endpoint.
|
|
17
|
-
*
|
|
18
|
-
* Secrets: this module reads keys to build adapters and to redact them from probe errors
|
|
19
|
-
* (scrubSecret). Nothing here prints or returns a key; formatProviderList shows key SOURCES. */
|
|
20
|
-
|
|
21
|
-
import type { AssistantTurn, Message, ModelRef, StreamEvent, StreamFn, StreamOptions } from "../core/types.ts";
|
|
22
|
-
import { fetchModels, providerStream, providerStreaming, wantsStreaming, type ProviderConfig as WireProviderConfig } from "./stream.ts";
|
|
23
|
-
import {
|
|
24
|
-
ProviderConfig, isConfigured, parseSelector, pickDefault, providersPathFor, readProvidersFile, validateSpec, writeProvidersFile,
|
|
25
|
-
type FileScope, type ProviderEntry, type ProviderSnapshot, type ProviderSpec, type ResolvedProvider,
|
|
26
|
-
} from "./provider-config.ts";
|
|
27
|
-
import { next } from "../core/voice.ts";
|
|
28
|
-
|
|
29
|
-
export type AdapterFactory = (p: ResolvedProvider, opts: { sse: boolean }) => StreamFn;
|
|
30
|
-
|
|
31
|
-
/** stream.ts ProviderConfig for a resolved provider (a keyless provider sends an empty bearer). */
|
|
32
|
-
export function toWireConfig(p: ResolvedProvider): WireProviderConfig {
|
|
33
|
-
return {
|
|
34
|
-
id: p.id, baseUrl: p.baseUrl, apiKey: p.apiKey ?? "", protocol: p.protocol,
|
|
35
|
-
...(p.defaultModel !== undefined ? { defaultModel: p.defaultModel } : {}),
|
|
36
|
-
...(p.headers !== undefined ? { headers: p.headers } : {}),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const defaultAdapterFactory: AdapterFactory = (p, { sse }) => {
|
|
41
|
-
const wire = toWireConfig(p);
|
|
42
|
-
// both protocols stream (openai SSE chunks, anthropic Messages events); `sse` is off only when
|
|
43
|
-
// ROVECODE_STREAM asked for the one-shot JSON adapters
|
|
44
|
-
return sse ? providerStreaming(wire) : providerStream(wire);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/** Error-text prefix the router/retry classifier treats as non-retryable (router.ts). */
|
|
48
|
-
export const CONFIG_ERROR_PREFIX = "config: ";
|
|
49
|
-
|
|
50
|
-
export function configErrorTurn(text: string): AssistantTurn {
|
|
51
|
-
return { parts: [], stopReason: "error", usage: { input: 0, output: 0 }, error: CONFIG_ERROR_PREFIX + text };
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** Replace a secret wherever it leaked into text (some proxies echo request headers in error bodies). */
|
|
55
|
-
export function scrubSecret(text: string, secret: string | null | undefined): string {
|
|
56
|
-
return secret !== null && secret !== undefined && secret.length > 0 ? text.split(secret).join("…") : text;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface RegistryOptions {
|
|
60
|
-
env?: NodeJS.ProcessEnv;
|
|
61
|
-
/** test seam: build adapters without touching the network */
|
|
62
|
-
adapterFactory?: AdapterFactory;
|
|
63
|
-
/** provider-config.ts reload throttle (ms); tests pass 0 */
|
|
64
|
-
throttleMs?: number;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export class ProviderRegistry {
|
|
68
|
-
readonly cwd: string;
|
|
69
|
-
private readonly env: NodeJS.ProcessEnv;
|
|
70
|
-
private readonly cfg: ProviderConfig;
|
|
71
|
-
private readonly factory: AdapterFactory;
|
|
72
|
-
private readonly adapters = new Map<string, { sig: string; fn: StreamFn }>();
|
|
73
|
-
|
|
74
|
-
constructor(cwd: string, opts: RegistryOptions = {}) {
|
|
75
|
-
this.cwd = cwd;
|
|
76
|
-
this.env = opts.env ?? process.env;
|
|
77
|
-
this.factory = opts.adapterFactory ?? defaultAdapterFactory;
|
|
78
|
-
this.cfg = new ProviderConfig(cwd, this.env, opts.throttleMs);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
snapshot(): ProviderSnapshot { return this.cfg.snapshot(); }
|
|
82
|
-
list(): ResolvedProvider[] { return this.snapshot().providers; }
|
|
83
|
-
ids(): string[] { return this.list().map((p) => p.id); }
|
|
84
|
-
get(id: string): ResolvedProvider | undefined { return this.list().find((p) => p.id === id); }
|
|
85
|
-
/** at least one provider has a key (or needs none) */
|
|
86
|
-
configured(): boolean { return this.list().some(isConfigured); }
|
|
87
|
-
warnings(): string[] { return this.snapshot().warnings; }
|
|
88
|
-
/** fires after every rebuild: external file edits (detected lazily) and in-process add/remove/setDefault */
|
|
89
|
-
onChange(cb: (snap: ProviderSnapshot) => void): () => void { return this.cfg.onChange(cb); }
|
|
90
|
-
/** re-read now (in-process writers call it right after writing) and notify listeners */
|
|
91
|
-
refresh(): ProviderSnapshot { this.cfg.invalidate(); return this.cfg.snapshot(); }
|
|
92
|
-
|
|
93
|
-
/** default provider + model with env ROVECODE_MODEL layered on top; null when nothing is configured */
|
|
94
|
-
defaultRef(): ModelRef | null {
|
|
95
|
-
const d = pickDefault(this.snapshot());
|
|
96
|
-
if (d === null) return null;
|
|
97
|
-
return { provider: d.provider.id, model: this.env["ROVECODE_MODEL"] ?? d.model ?? "" };
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/** stream.ts-shaped config of the default provider (Runtime.provider compatibility) */
|
|
101
|
-
defaultConfig(): WireProviderConfig | null {
|
|
102
|
-
const d = pickDefault(this.snapshot());
|
|
103
|
-
if (d === null) return null;
|
|
104
|
-
return { ...toWireConfig(d.provider), ...(d.model !== undefined ? { defaultModel: d.model } : {}) };
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
defaultSelector(): string | undefined { return this.snapshot().defaultSelector; }
|
|
108
|
-
|
|
109
|
-
/** "provider/model" or a bare model on `currentProvider`. A leading segment counts as a provider
|
|
110
|
-
* only when it names one, so "zai-org/glm-5.3" stays a model id on the current provider. The
|
|
111
|
-
* current provider is not validated (it may be "mock" or an injected test stream): a bare model
|
|
112
|
-
* always lands there, exactly as `/model <id>` always did. */
|
|
113
|
-
resolveSelector(selector: string, currentProvider: string): ModelRef | { error: string } {
|
|
114
|
-
const s = selector.trim();
|
|
115
|
-
if (s.length === 0) return { error: "empty model selector" };
|
|
116
|
-
const i = s.indexOf("/");
|
|
117
|
-
if (i > 0) {
|
|
118
|
-
const head = s.slice(0, i);
|
|
119
|
-
const tail = s.slice(i + 1).trim();
|
|
120
|
-
if (this.get(head) !== undefined) return tail.length > 0 ? { provider: head, model: tail } : { error: `"${s}" names no model — use ${head}/<model>` };
|
|
121
|
-
}
|
|
122
|
-
return { provider: currentProvider, model: s };
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
add(spec: ProviderSpec, scope: FileScope = "user"): ResolvedProvider | { error: string } {
|
|
126
|
-
const { id, ...raw } = spec;
|
|
127
|
-
const v = validateSpec(id, raw);
|
|
128
|
-
if ("error" in v) return v;
|
|
129
|
-
if (this.get(id)?.scope === "env") return { error: `"custom" is reserved for the ROVECODE_BASE_URL/ROVECODE_API_KEY pair — pick another id` };
|
|
130
|
-
const path = providersPathFor(scope, this.cwd);
|
|
131
|
-
const { data } = readProvidersFile(path);
|
|
132
|
-
const { id: _id, ...rest } = v.spec;
|
|
133
|
-
data.providers = { ...(data.providers ?? {}), [id]: rest };
|
|
134
|
-
writeProvidersFile(path, data);
|
|
135
|
-
this.refresh();
|
|
136
|
-
return this.get(id)!;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
remove(id: string): { removed: FileScope[] } | { error: string } {
|
|
140
|
-
const p = this.get(id);
|
|
141
|
-
if (p === undefined) return { error: `unknown provider "${id}" — known: ${this.ids().join(" ")}` };
|
|
142
|
-
if (p.scope === "builtin") return { error: `"${id}" is built in; drop its key with \`rovecode auth remove ${id}\` instead` };
|
|
143
|
-
if (p.scope === "env") return { error: `"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY — unset those env vars` };
|
|
144
|
-
const removed: FileScope[] = [];
|
|
145
|
-
for (const scope of ["user", "project"] as const) {
|
|
146
|
-
const path = providersPathFor(scope, this.cwd);
|
|
147
|
-
const { data } = readProvidersFile(path);
|
|
148
|
-
if (data.providers !== undefined && id in data.providers) {
|
|
149
|
-
delete data.providers[id];
|
|
150
|
-
if (Object.keys(data.providers).length === 0) delete data.providers;
|
|
151
|
-
writeProvidersFile(path, data);
|
|
152
|
-
removed.push(scope);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
this.refresh();
|
|
156
|
-
return { removed };
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
setDefault(selector: string, scope: FileScope = "user"): ModelRef | { error: string } {
|
|
160
|
-
const sel = parseSelector(selector);
|
|
161
|
-
const p = this.get(sel.provider);
|
|
162
|
-
if (p === undefined) return { error: `unknown provider "${sel.provider}" — known: ${this.ids().join(" ")}` };
|
|
163
|
-
const model = sel.model ?? p.defaultModel;
|
|
164
|
-
if (model === undefined) return { error: `"${selector}" names no model and ${p.id} has no default — use ${p.id}/<model>` };
|
|
165
|
-
const path = providersPathFor(scope, this.cwd);
|
|
166
|
-
const { data } = readProvidersFile(path);
|
|
167
|
-
data.default = `${p.id}/${model}`;
|
|
168
|
-
writeProvidersFile(path, data);
|
|
169
|
-
this.refresh();
|
|
170
|
-
return { provider: p.id, model };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/** pin a provider's ACTIVE model list (the connect wizard's model step): writes `models` on the
|
|
174
|
-
* provider's row in the scope's file — creating the row for a builtin, which is how `add` works
|
|
175
|
-
* too. An EMPTY list removes the field: the provider goes back to asking its /models endpoint
|
|
176
|
-
* every time (the "use them all" answer — nothing frozen). Returns the written list. */
|
|
177
|
-
setModels(id: string, models: readonly string[], scope: FileScope = "user"): { models: string[] } | { error: string } {
|
|
178
|
-
const p = this.get(id);
|
|
179
|
-
if (p === undefined) return { error: `unknown provider "${id}" — known: ${this.ids().join(" ")}` };
|
|
180
|
-
if (p.scope === "env") return { error: `"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY — a model list cannot be pinned on it` };
|
|
181
|
-
for (const m of models) if (m.trim().length === 0) return { error: "model ids must be non-empty strings" };
|
|
182
|
-
const path = providersPathFor(scope, this.cwd);
|
|
183
|
-
const { data } = readProvidersFile(path);
|
|
184
|
-
const rows = data.providers ?? {};
|
|
185
|
-
const existing = rows[id];
|
|
186
|
-
// a builtin with no file row yet carries its baseUrl in the spec — the new row must too
|
|
187
|
-
const row: ProviderEntry = existing ?? { baseUrl: p.baseUrl };
|
|
188
|
-
const deduped = [...new Set(models.map((m) => m.trim()))];
|
|
189
|
-
if (deduped.length === 0) {
|
|
190
|
-
delete row.models;
|
|
191
|
-
} else {
|
|
192
|
-
row.models = deduped;
|
|
193
|
-
// a pinned list that does not contain the current default silently breaks the default —
|
|
194
|
-
// keep the field only when it still names a usable model
|
|
195
|
-
if (row.defaultModel !== undefined && !deduped.includes(row.defaultModel)) delete row.defaultModel;
|
|
196
|
-
}
|
|
197
|
-
rows[id] = row;
|
|
198
|
-
data.providers = rows;
|
|
199
|
-
writeProvidersFile(path, data);
|
|
200
|
-
this.refresh();
|
|
201
|
-
return { models: deduped };
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
keyHint(p: ResolvedProvider): string {
|
|
205
|
-
return `no API key for provider "${p.id}" — I can't call it without one. ${next(`rovecode auth set ${p.id}`)} (masked prompt) · or /provider key ${p.id} <key> in the TUI · or set ${p.keyEnv}`;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
async models(id: string): Promise<{ ok: true; models: string[]; source: "file" | "endpoint" } | { ok: false; error: string }> {
|
|
209
|
-
const p = this.get(id);
|
|
210
|
-
if (p === undefined) return { ok: false, error: `unknown provider "${id}" — known: ${this.ids().join(" ")}` };
|
|
211
|
-
if (p.models !== undefined && p.models.length > 0) return { ok: true, models: p.models, source: "file" };
|
|
212
|
-
if (!isConfigured(p)) return { ok: false, error: this.keyHint(p) };
|
|
213
|
-
const list = await fetchModels(toWireConfig(p), true);
|
|
214
|
-
return { ok: true, models: list.map((m) => m.id), source: "endpoint" };
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
/** One tiny real call ("ping", ≤8 output tokens): proves url + key + model together. */
|
|
218
|
-
async probe(id: string, model?: string): Promise<{ ok: boolean; model: string; detail: string }> {
|
|
219
|
-
const p = this.get(id);
|
|
220
|
-
if (p === undefined) return { ok: false, model: model ?? "", detail: `unknown provider "${id}" — known: ${this.ids().join(" ")}` };
|
|
221
|
-
if (!isConfigured(p)) return { ok: false, model: model ?? "", detail: this.keyHint(p) };
|
|
222
|
-
const m = model ?? p.defaultModel;
|
|
223
|
-
if (m === undefined) return { ok: false, model: "", detail: `${p.id} has no default model — pass one: test ${p.id} <model>` };
|
|
224
|
-
const probeMsg: Message = { id: "probe", role: "user", parts: [{ kind: "text", text: "ping" }], parentId: null, createdAt: Date.now() };
|
|
225
|
-
const t0 = Date.now();
|
|
226
|
-
let turn: AssistantTurn | undefined;
|
|
227
|
-
try {
|
|
228
|
-
for await (const ev of this.adapterFor(p)({ provider: p.id, model: m, maxTokens: 8 }, [probeMsg], { tools: [] })) if (ev.type === "turn") turn = ev.turn;
|
|
229
|
-
} catch (e) {
|
|
230
|
-
return { ok: false, model: m, detail: scrubSecret(e instanceof Error ? e.message : String(e), p.apiKey) };
|
|
231
|
-
}
|
|
232
|
-
if (turn === undefined) return { ok: false, model: m, detail: "stream produced no turn" };
|
|
233
|
-
if (turn.stopReason === "error") return { ok: false, model: m, detail: scrubSecret(turn.error ?? "stream error", p.apiKey) };
|
|
234
|
-
return { ok: true, model: m, detail: `ok in ${Date.now() - t0} ms (${turn.usage.input} in / ${turn.usage.output} out tokens)` };
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** The dispatching StreamFn (see the header). */
|
|
238
|
-
stream(): StreamFn {
|
|
239
|
-
const self = this;
|
|
240
|
-
return async function* (model: ModelRef, messages: Message[], options?: StreamOptions): AsyncGenerator<StreamEvent> {
|
|
241
|
-
const p = self.get(model.provider);
|
|
242
|
-
if (p === undefined) {
|
|
243
|
-
yield { type: "turn", turn: configErrorTurn(`provider "${model.provider}" is not configured — I can't route to it. ${next(`rovecode provider add ${model.provider} <baseUrl> [--protocol openai|anthropic]`)} (or /provider add in the TUI); known: ${self.ids().join(" ")}`) };
|
|
244
|
-
return;
|
|
245
|
-
}
|
|
246
|
-
if (!isConfigured(p)) { yield { type: "turn", turn: configErrorTurn(self.keyHint(p)) }; return; }
|
|
247
|
-
yield* self.adapterFor(p)(model, messages, options);
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
private adapterFor(p: ResolvedProvider): StreamFn {
|
|
252
|
-
const sse = wantsStreaming({ ROVECODE_STREAM: this.env["ROVECODE_STREAM"] }); // default ON
|
|
253
|
-
const sig = [p.baseUrl, p.protocol, p.apiKey ?? "", JSON.stringify(p.headers ?? {}), sse ? "sse" : "json"].join("\u0000");
|
|
254
|
-
const hit = this.adapters.get(p.id);
|
|
255
|
-
if (hit !== undefined && hit.sig === sig) return hit.fn;
|
|
256
|
-
const fn = this.factory(p, { sse });
|
|
257
|
-
this.adapters.set(p.id, { sig, fn });
|
|
258
|
-
return fn;
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// ---------- shared CLI / TUI helpers ----------
|
|
263
|
-
|
|
264
|
-
export const ADD_USAGE = "add <id> <baseUrl> [--protocol openai|anthropic] [--key-env NAME] [--model <id>] [--no-key] [--project]";
|
|
265
|
-
|
|
266
|
-
export interface AddArgs { spec: ProviderSpec; scope: FileScope; promptKey: boolean }
|
|
267
|
-
|
|
268
|
-
/** Parse `add` words (CLI argv tail or TUI slash args) into a validated spec + scope. `--key` (CLI:
|
|
269
|
-
* prompt for the secret afterwards) is recorded, never a value. Pure; never throws. */
|
|
270
|
-
export function parseAddArgs(words: readonly string[]): AddArgs | { error: string } {
|
|
271
|
-
const pos: string[] = [];
|
|
272
|
-
const raw: Record<string, unknown> = {};
|
|
273
|
-
let scope: FileScope = "user";
|
|
274
|
-
let promptKey = false;
|
|
275
|
-
for (let i = 0; i < words.length; i++) {
|
|
276
|
-
const w = words[i]!;
|
|
277
|
-
const value = (): string | { error: string } => {
|
|
278
|
-
const v = words[i + 1];
|
|
279
|
-
if (v === undefined || v.startsWith("-")) return { error: `${w} needs a value — ${ADD_USAGE}` };
|
|
280
|
-
i++;
|
|
281
|
-
return v;
|
|
282
|
-
};
|
|
283
|
-
switch (w) {
|
|
284
|
-
case "--protocol": { const v = value(); if (typeof v !== "string") return v; raw["protocol"] = v; break; }
|
|
285
|
-
case "--key-env": { const v = value(); if (typeof v !== "string") return v; raw["keyEnv"] = v; break; }
|
|
286
|
-
case "--model": { const v = value(); if (typeof v !== "string") return v; raw["defaultModel"] = v; break; }
|
|
287
|
-
case "--scope": {
|
|
288
|
-
const v = value(); if (typeof v !== "string") return v;
|
|
289
|
-
if (v !== "user" && v !== "project") return { error: "--scope must be user or project" };
|
|
290
|
-
scope = v; break;
|
|
291
|
-
}
|
|
292
|
-
case "--project": scope = "project"; break;
|
|
293
|
-
case "--user": scope = "user"; break;
|
|
294
|
-
case "--no-key": raw["noKey"] = true; break;
|
|
295
|
-
case "--key": promptKey = true; break;
|
|
296
|
-
default:
|
|
297
|
-
if (w.startsWith("-")) return { error: `unknown flag ${w} — ${ADD_USAGE}` };
|
|
298
|
-
pos.push(w);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
const [id, baseUrl] = pos;
|
|
302
|
-
if (id === undefined || baseUrl === undefined) return { error: `usage: ${ADD_USAGE}` };
|
|
303
|
-
raw["baseUrl"] = baseUrl;
|
|
304
|
-
const v = validateSpec(id, raw);
|
|
305
|
-
if ("error" in v) return v;
|
|
306
|
-
return { spec: v.spec, scope, promptKey };
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
/** One row per provider — key SOURCE only, never the value. */
|
|
310
|
-
export function formatProviderLine(p: ResolvedProvider): string {
|
|
311
|
-
const key = p.keySource === "stored" ? "key: stored"
|
|
312
|
-
: p.keySource === "env" ? `key: env ${p.keyEnv}`
|
|
313
|
-
: p.keySource === "inline" ? "key: ROVECODE_API_KEY"
|
|
314
|
-
: p.noKey === true ? "key: not needed"
|
|
315
|
-
: `key: NONE (rovecode auth set ${p.id} · or set ${p.keyEnv})`;
|
|
316
|
-
return `${p.id.padEnd(12)} ${p.protocol.padEnd(9)} ${p.baseUrl.padEnd(40)} ${key}${p.defaultModel !== undefined ? ` model: ${p.defaultModel}` : ""} [${p.scope}]`;
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
/** Listing for `rovecode provider list`, `/provider list` and the provider_list tool. Built-in providers
|
|
320
|
-
* without a key are folded into a count unless `all` — sixteen dead rows hide the live ones. */
|
|
321
|
-
export function formatProviderList(reg: ProviderRegistry, opts: { all?: boolean } = {}): string {
|
|
322
|
-
const d = reg.defaultRef();
|
|
323
|
-
const all = reg.list();
|
|
324
|
-
const rows = all.filter((p) => opts.all === true || isConfigured(p) || p.scope !== "builtin");
|
|
325
|
-
const lines = [d !== null
|
|
326
|
-
? `default → ${d.provider}/${d.model || "(no model — pass one with /model or ROVECODE_MODEL)"}${reg.defaultSelector() !== undefined ? ` (providers.json default: ${reg.defaultSelector()})` : ""}`
|
|
327
|
-
: `default → none yet. ${next("rovecode setup")} (or rovecode provider add <id> <baseUrl>, then rovecode auth set <id>)`];
|
|
328
|
-
lines.push(...rows.map(formatProviderLine));
|
|
329
|
-
const hidden = all.length - rows.length;
|
|
330
|
-
if (hidden > 0) lines.push(`(+${hidden} built-in providers without a key — \`list --all\` shows them)`);
|
|
331
|
-
lines.push(...reg.warnings().map((w) => `warning: ${w}`));
|
|
332
|
-
return lines.join("\n");
|
|
333
|
-
}
|