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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Cf as rJ,vf as XJ}from"./main-xfekqh9m.js";import{$f as PJ,ag as NJ,bg as RJ,cg as a,lg as WQ}from"./main-rvetps99.js";import{xj as HJ,yj as lJ}from"./main-2rzbexn2.js";import{Mk as DJ,Nk as BJ,Qk as pJ,rk as KJ,sk as cJ}from"./main-qj2djy17.js";import{Sk as n,bl as $Q}from"./main-6dtqmbt6.js";import{wn as x}from"./main-qsevpgsv.js";var E,w,AQ,d=50,yQ=100,xQ=30,fQ;var c=x(()=>{E={BOLD:1,DIM:2,ITALIC:4,UNDERLINE:8,INVERSE:16,STRIKE:32},w=["night","ember","contrast"],AQ=["code","files","plan"],fQ=["\u25C7","\u25C8","\u25C6","\u25C8"]});import{isAbsolute as JJ,relative as yJ}from"path";function M(J,Q){let Z=[...J];return Z.length<=Q?J:Z.slice(0,Math.max(0,Q-1)).join("")+"\u2026"}function r(J,Q=ZJ){let Z=J.split(/\r?\n/).find(($)=>$.trim().length>0)??"";return M(Z.replace(/\s+/g," ").trim(),Q)}function CJ(J,Q=ZJ){let Z=J.split(/\r?\n/).filter(($)=>$.trim().length>0);return M((Z[Z.length-1]??"").replace(/\s+/g," ").trim(),Q)}function $J(J,Q){if(!Q)return"";let Z=Q;if(JJ(Q)){let $=yJ(J,Q);Z=$&&!$.startsWith("..")&&!JJ($)?$:Q}else if(hJ.test(Q)){let $=l(Q),V=l(J).replace(/\/+$/,"");if(V&&$.toLowerCase().startsWith(V.toLowerCase()+"/"))Z=$.slice(V.length+1)}return l(Z).replace(/^\.\/+/,"")}function mJ(J){try{return new URL(J).host||M(J,g)}catch{return M(J,g)||"url"}}function WJ(J,Q,Z){let $=QJ(Q);switch(J){case"read":{let V=p($.offset),Y=p($.limit),W=V!==void 0||Y!==void 0?[V??1,(V??1)+(Y??2000)-1]:null;return C("read",Z,$,"READING","reading",{hl:W})}case"edit":{let V=Array.isArray($.edits)?$.edits:[],Y=0,W=1/0,G=-1/0;for(let D of V){let j=QJ(D),U=Array.isArray(j.newLines)?j.newLines.length:0;Y+=U;let F=p(j.anchorLine);if(F!==void 0)W=Math.min(W,F),G=Math.max(G,F+Math.max(0,U-1))}return C("edit",Z,$,"EDITING","editing",{add:Y,del:V.length,hl:W<=G?[W,G]:null})}case"write":{let V=R($.content);return C("write",Z,$,"EDITING","writing",{add:V?V.split(/\r?\n/).length:0})}case"remove":case"rm":case"delete":case"unlink":return C("remove",Z,$,"EDITING","removing");case"bash":case"shell":case"run":{let V=R($.command)||R($.cmd),Y=uJ(V)||"command",W=fJ.test(V);return{verb:"run",label:Y,path:null,touch:!1,state:W?"TESTING":"RUNNING",activity:W?"running tests":`running ${Y}`,hl:null,add:0,del:0,cmd:V}}case"glob":case"grep":{let V=M(R($.pattern),g)||J;return{verb:"search",label:V,path:null,touch:!1,state:"READING",activity:`searching ${V}`,hl:null,add:0,del:0,cmd:null}}case"ls":{let V=$J(Z,R($.path))||".";return{verb:"other",label:V,path:null,touch:!1,state:"READING",activity:`listing ${V}`,hl:null,add:0,del:0,cmd:null}}case"web_fetch":{let V=mJ(R($.url));return{verb:"fetch",label:V,path:null,touch:!1,state:"READING",activity:`fetching ${V}`,hl:null,add:0,del:0,cmd:null}}case"task":{let V=M(R($.label)||R($.agent)||"task",g);return{verb:"task",label:V,path:null,touch:!1,state:"DELEGATING",activity:`delegating ${V}`,hl:null,add:0,del:0,cmd:null}}case"ask_user":return{verb:"other",label:M(r(R($.question),g)||"question",g),path:null,touch:!1,state:"WAITING",activity:"waiting for you",hl:null,add:0,del:0,cmd:null};case"todo_write":case"todo_read":return{verb:"other",label:"todos",path:null,touch:!1,state:"THINKING",activity:"planning",hl:null,add:0,del:0,cmd:null};default:return{verb:"other",label:M(J,g),path:null,touch:!1,state:"RUNNING",activity:`running ${J}`,hl:null,add:0,del:0,cmd:null}}}function wJ(J){let Q=/\(showing lines (\d+)-(\d+) of (\d+)\)/.exec(J);if(Q){let Z=Number(Q[1]),$=Number(Q[2]);return $>=Z&&Z>0?$-Z+1:0}return J.split(/\r?\n/).filter((Z)=>/^\d+#/.test(Z)).length}function VJ(J,Q,Z,$){if(J.verb==="run"){let V=/^exit=(-?\d+)\r?\n?/.exec($),Y=V?$.slice(V[0].length):$,W=Y.split(/\r?\n/);while(W.length&&W[W.length-1].trim()==="")W.pop();return{detail:CJ(Y)||(V?`exit ${V[1]}`:""),runLines:W,...V?{exitCode:Number(V[1])}:{}}}if(!Z)return{detail:r(J.verb==="edit"||J.verb==="write"?dJ($):$)};switch(J.verb){case"read":return{detail:`${wJ($)} lines`};case"edit":return{};case"write":{let V=/\((\d+) bytes/.exec($);return V?{detail:`${V[1]} bytes`}:{}}case"remove":return{};case"search":{let V=$.split(/\r?\n/).filter((W)=>W.trim().length>0),Y=V.filter((W)=>!W.startsWith("(")).length;return{detail:`${Y} ${Q==="glob"?Y===1?"file":"files":Y===1?"match":"matches"}`,searchLines:V.slice(0,xJ)}}case"fetch":return{detail:`${$.length} chars`};default:return{detail:r($)}}}var g=48,ZJ=80,xJ=500,fJ,QJ=(J)=>J&&typeof J==="object"&&!Array.isArray(J)?J:{},R=(J)=>typeof J==="string"?J:"",p=(J)=>typeof J==="number"&&Number.isFinite(J)&&J>0?Math.floor(J):void 0,hJ,l=(J)=>J.replace(/\\/g,"/"),vJ=(J)=>J.slice(J.lastIndexOf("/")+1)||J,uJ=(J)=>M(J.replace(/\s+/g," ").trim(),g),C=(J,Q,Z,$,V,Y={})=>{let W=$J(Q,R(Z.path)),G=vJ(W)||"file";return{verb:J,label:G,path:W||null,touch:!0,state:$,activity:`${V} ${G}`,hl:null,add:0,del:0,cmd:null,...Y}},dJ=(J)=>J.replace(/ at \S.*?:\d+(?=\s|$)/,"");var jJ=x(()=>{fJ=/\b(tests?|vitest|jest|pytest|mocha|spec)\b/i;hJ=/^[A-Za-z]:[\\/]/});function lQ(J){return{cwd:J.cwd,repo:{name:J.repo.name,branch:J.repo.branch,modified:J.repo.modified??0},files:{paths:[],statuses:new Map,expanded:new Set,touched:new Map,cursor:0,scroll:0,version:0},activity:{state:"IDLE",label:"idle",runId:null,startedAt:null,endedAt:null},code:{mode:"code",file:null,content:null,hl:null,scroll:0,search:null,run:null,diff:null,lane:0,laneOpen:!1},messages:[],msgScroll:0,stick:!0,card:null,plan:{todos:[]},crew:[],usage:{provider:J.model?.provider??"",model:J.model?.model??"",turns:0,tokensIn:0,tokensOut:0,contextPct:null,costUsd:null},input:{text:"",cur:0,history:[],histIdx:-1,sgSel:0},focus:"messages",page:"code",palette:null,market:null,context:null,wizard:null,help:!1,toasts:[],notices:[],staged:[],escUntil:0,running:!1,mode:J.mode,yolo:J.yolo,theme:J.theme,bootAt:J.now,commands:J.commands,version:J.version}}function f(J){for(let Q of J.messages)if(Q.kind==="assistant")Q.streaming=!1}function i(J,Q){for(let Z=J.messages.length-1;Z>=0;Z--){let $=J.messages[Z];if($.kind==="tool"&&$.callId===Q)return $}return}function oJ(J,Q){let Z=Q.split(/\r?\n/).find((Y)=>Y.trim())?.trim()??"",$=J?`${J} \xB7 ${Z}`:Z,V=[...$];return V.length>UJ?"\u2026"+V.slice(V.length-UJ+1).join(""):$}function eJ(J,Q,Z){if(J.code.file!==Q)J.code.content=null,J.code.scroll=0;J.code.mode="code",J.code.file=Q,J.code.hl=Z}function tJ(J={}){let Q=new Map,Z=!1,$=0,V=(W)=>{if(W.activity.turnAt===void 0)return;let G=W.messages[W.messages.length-1];W.activity.tokens=$+(G&&G.kind==="assistant"&&G.streaming?KJ(G.text):0)},Y=(W)=>{delete W.activity.turnAt,delete W.activity.tokens};return(W,G,D)=>{switch(G.type){case"run_start":W.activity={state:"THINKING",label:"thinking",runId:G.runId,startedAt:D,endedAt:null},W.running=!0,W.stick=!0,Z=!1,$=0,Q.clear();break;case"turn_start":f(W),_(W,"THINKING","thinking"),W.usage.turns+=1,W.activity.turnAt=D,W.activity.tokens=0,$=0;break;case"message_update":{let j=W.messages[W.messages.length-1];if(j&&j.kind==="assistant"&&j.streaming)j.text+=G.delta;else f(W),N(W,{kind:"assistant",text:G.delta,streaming:!0,id:G.messageId});Z=!0,_(W,"WRITING","writing"),V(W);break}case"reasoning_update":$=G.tokens,V(W);break;case"tool_execution_start":{f(W),Y(W);let j=WJ(G.tool,G.args,W.cwd);Q.set(G.callId,{tool:G.tool,verb:j.verb,path:j.path,add:j.add,del:j.del,cmd:j.cmd});let U={kind:"tool",callId:G.callId,tool:G.tool,verb:j.verb,label:j.label,running:!0};if(j.path)U.path=j.path;if(j.verb==="edit"||j.verb==="write")U.add=j.add,U.del=j.del;if(N(W,U),_(W,j.state,j.activity),j.path&&j.touch)W.files.touched.set(j.path,D+iJ),JQ(W,j.path),W.files.version++;if(j.path&&(j.verb==="read"||j.verb==="edit"||j.verb==="write"))eJ(W,j.path,j.hl);if(j.verb==="run")W.code.mode="run",W.code.run={cmd:j.cmd??j.label,lines:[],status:"running"};if(j.verb==="search")W.code.mode="search",W.code.search={query:j.label,lines:[]};break}case"tool_execution_update":{let j=i(W,G.callId);if(j)j.detail=oJ(j.detail,G.note);break}case"tool_execution_end":{let j=Q.get(G.callId);Q.delete(G.callId);let U=i(W,G.callId);if(!U)U={kind:"tool",callId:G.callId,tool:j?.tool??"tool",verb:j?.verb??"other",label:j?.tool??G.callId,running:!0},N(W,U);U.running=!1,U.ok=G.ok,U.ms=G.durationMs;let F=VJ({verb:U.verb},U.tool,G.ok,G.output);if(F.detail)U.detail=F.detail;if(F.runLines&&W.code.run&&(!j?.cmd||W.code.run.cmd===j.cmd)){if(W.code.run.lines=F.runLines,W.code.run.status=G.ok?"ok":"fail",F.exitCode!==void 0)W.code.run.exitCode=F.exitCode}if(F.searchLines&&W.code.search)W.code.search.lines=F.searchLines;if(G.ok&&j?.path&&(U.verb==="edit"||U.verb==="write")){if(U.verb==="write")sJ(W,j.path);let K=J.diffFor?.(j.path,U.tool,W)??null;if(K)U.add=K.add,U.del=K.del,W.code.diff={file:j.path,...K},W.code.mode="diff"}if(!G.ok)_(W,"ERROR",`${U.verb} failed`,D);else if(!aJ(W))_(W,"THINKING","thinking");break}case"tool_call_failed":{Q.delete(G.callId),Y(W);let j=i(W,G.callId),U=G.reason.replace(/_/g," ");if(j)j.running=!1,j.ok=!1,j.detail=U;N(W,{kind:"system",tone:"error",text:`${U}: ${G.detail}`});let F=G.reason==="permission_denied"?"denied":U;_(W,"ERROR",j?`${j.label} ${F}`:F,D),h(W,j?`${j.label} ${F}`:`tool ${F}`,D,"error","error");break}case"compaction":N(W,{kind:"compaction",text:`compacted (${G.strategy}${G.trigger?`, ${G.trigger}`:""}): ${FJ(G.tokensBefore)} \u2192 ${FJ(G.tokensAfter)} tokens`});break;case"steer":N(W,{kind:"steer",text:G.text});break;case"verify":N(W,{kind:"system",tone:G.state==="running"||G.state==="passed"?"info":"warn",text:G.state==="running"?`\u29D7 verify: ${G.command}`:`verify ${G.state}: ${G.detail??""}`});break;case"turn_end":f(W),Y(W);break;case"run_end":{if(f(W),Y(W),G.status==="done"){if(_(W,"SUCCESS","done"),!Z&&G.summary)N(W,{kind:"assistant",text:G.summary,streaming:!1});let j=G.outstanding?DJ(G.outstanding):null,U=G.outstanding?BJ(G.outstanding):"info";if(j!==null)N(W,{kind:"system",tone:U,text:`done \xB7 ${j}`});h(W,j!==null?`run done \xB7 ${j}`:"run done",D,U,"done")}else if(G.status==="error"){if(_(W,"ERROR","error",D),G.summary)N(W,{kind:"system",tone:"error",text:G.summary});h(W,`run failed${G.summary?`: ${G.summary.split(`
|
|
3
|
+
`)[0].slice(0,80)}`:""}`,D,"error","error")}else _(W,"IDLE",G.status),N(W,{kind:"system",tone:"warn",text:`run ${G.status}: ${G.summary}`}),h(W,`run ${G.status}`,D,"warn","done");W.activity.endedAt=D,W.running=!1;for(let j of W.messages)if(j.kind==="tool"&&j.running)j.running=!1,j.ok=!1,j.detail??="interrupted";{let j=W.files.touched.size;for(let[U,F]of W.files.touched)if(F<=D)W.files.touched.delete(U);if(W.files.touched.size!==j)W.files.version++}Q.clear();break}}}}function iQ(J,Q,Z){J.files.paths=[...new Set(Q.map(YJ).filter(Boolean))].sort(v),J.files.statuses=new Map(Z?[...Z].map(([$,V])=>[YJ($),V]):[]),J.repo.modified=J.files.statuses.size,J.files.version++}function sJ(J,Q){if(J.files.paths.includes(Q))return;J.files.paths.push(Q),J.files.paths.sort(v),J.files.version++}function JQ(J,Q){let Z=Q.split("/"),$=!1;for(let V=1;V<Z.length;V++){let Y=Z.slice(0,V).join("/");if(!J.files.expanded.has(Y))J.files.expanded.add(Y),$=!0}if($)J.files.version++}function aQ(J){let Q=new Set(J.files.paths);for(let[Z,$]of J.files.statuses)if($==="D")Q.delete(Z);else Q.add(Z);return Q.size}function oQ(J,Q=-1){let Z=J.files.expanded.size;if(k&&k.files===J.files&&k.version===J.files.version&&k.expSz===Z&&k.now===Q)return k.rows;let $=new Set(J.files.paths);for(let D of J.files.statuses.keys())$.add(D);let V={name:"",path:"",kids:new Map};for(let D of[...$].sort(v)){let j=D.split("/").filter(Boolean),U=V;j.forEach((F,K)=>{let H=K===j.length-1,B=U.kids.get(F);if(!B)B={name:F,path:j.slice(0,K+1).join("/"),kids:H?null:new Map},U.kids.set(F,B);else if(!H&&!B.kids)B.kids=new Map;U=B})}let Y=(D)=>D.kids?[...D.kids.values()].some(Y):J.files.statuses.has(D.path),W=[],G=(D,j)=>{let U=[...D.kids.values()].sort((F,K)=>Number(!!K.kids)-Number(!!F.kids)||v(F.name,K.name));for(let F of U)if(F.kids){let K=J.files.expanded.has(F.path),H={path:F.path,name:F.name,depth:j,dir:!0,expanded:K};if(!K&&Y(F))H.hasChanges=!0;if(W.push(H),K)G(F,j+1)}else{let K={path:F.path,name:F.name,depth:j,dir:!1},H=J.files.statuses.get(F.path);if(H)K.status=H;let B=J.files.touched.get(F.path);if(B!==void 0)K.touchedUntil=B;W.push(K)}};return G(V,0),k={files:J.files,version:J.files.version,expSz:Z,now:Q,rows:W},W}function eQ(J){let Q=J.length,Z=Array(Q).fill(!0),$=[];for(let W=Q-1;W>=0;W--){let G=J[W].depth;Z[W]=!$[G],$[G]=!0,$.length=G+1}let V=[],Y=[];for(let W=0;W<Q;W++){let G=J[W].depth;Y[G]=Z[W];let D=[];for(let j=1;j<=G;j++)D.push(j===G?Z[W]?"end":"tee":Y[j]?"blank":"bar");V.push(D)}return V}function QQ(J,Q,Z,$="info"){if(J.toasts.push({text:Q,until:Z+nJ,tone:$}),J.toasts.length>GJ)J.toasts.splice(0,J.toasts.length-GJ)}function h(J,Q,Z,$="info",V="info"){QQ(J,Q,Z,$);let Y=(J.notices[J.notices.length-1]?.id??0)+1;if(J.notices.push({id:Y,at:Z,tone:$,kind:V,text:Q,read:!1}),J.notices.length>d)J.notices.splice(0,J.notices.length-d)}function tQ(J){return J.notices.reduce((Q,Z)=>Q+(Z.read?0:1),0)}function IJ(J){for(let Q of J.notices)Q.read=!0}function sQ(J,Q){if(J.toasts.some((Z)=>Z.until<=Q))J.toasts=J.toasts.filter((Z)=>Z.until>Q)}function JZ(J,Q){let Z=J.activity;return Z.startedAt===null?0:Math.max(0,(Z.endedAt??Q)-Z.startedAt)}function QZ(J){let Q=Math.max(0,J)/1000,Z=Math.floor(Q/60),$=Q-Z*60;return`${String(Z).padStart(2,"0")}:${$.toFixed(1).padStart(4,"0")}`}function ZZ(J){let Q=Math.floor(Math.max(0,J)/1000);if(Q<60)return`${Q}s`;let Z=Math.floor(Q/60);if(Z<60)return`${Z}m ${Q-Z*60}s`;return`${Math.floor(Z/60)}h ${Z%60}m`}function ZQ(J,Q){if(Q===void 0)return null;return Math.min(100,Math.round(HJ(J,Q).fraction*100))}function $Z(J,Q){if(Q.provider!==void 0)J.usage.provider=Q.provider;if(Q.model!==void 0)J.usage.model=Q.model;if(Q.effort!==void 0)J.usage.effort=Q.effort;if(Q.turns!==void 0)J.usage.turns=Q.turns;if(Q.tokensIn!==void 0)J.usage.tokensIn=Q.tokensIn;if(Q.tokensOut!==void 0)J.usage.tokensOut=Q.tokensOut;if("contextTokens"in Q||"contextWindow"in Q){if(J.usage.contextPct=ZQ(Q.contextTokens??0,Q.contextWindow),Q.contextTokens!==void 0)J.usage.contextTokens=Q.contextTokens;if(Q.contextWindow!==void 0)J.usage.contextWindow=Q.contextWindow;else delete J.usage.contextWindow}if(Q.costUsd!==void 0)J.usage.costUsd=Q.costUsd}function WZ(J,Q){J.plan=Q.note?{todos:Q.items,note:Q.note}:{todos:Q.items}}function jZ(J,Q){J.crew=[...Q]}var iJ=1500,nJ=2600,GJ=6,UJ=120,_=(J,Q,Z,$)=>{if(J.activity.state=Q,J.activity.label=Z,Q==="ERROR"&&$!==void 0)J.activity.errorAt=$},N=(J,Q)=>{J.messages.push(Q),J.stick=!0},aJ=(J)=>J.messages.some((Q)=>Q.kind==="tool"&&Q.running),rQ,v=(J,Q)=>{let Z=J.toLowerCase(),$=Q.toLowerCase();return Z<$?-1:Z>$?1:J<Q?-1:J>Q?1:0},YJ=(J)=>J.replace(/\\/g,"/").replace(/^\.\/+/,""),nQ=(J)=>J.files.statuses.size,k=null,FJ=(J)=>J>=1000?`${(J/1000).toFixed(1)}k`:String(Math.max(0,Math.round(J))),VZ=(J)=>XJ(J.plan.todos);var SJ=x(()=>{lJ();pJ();cJ();rJ();c();jJ();rQ=tJ()});import{existsSync as VQ,openSync as jQ,closeSync as GQ,readSync as UQ,readFileSync as YQ,statSync as FQ}from"fs";import{homedir as KQ}from"os";import{isAbsolute as zJ,resolve as L,sep as MJ}from"path";function DQ(J){let Q=J.trim();if(Q[0]==="/"||Q[0]==="!")return[];return[...Q.matchAll(o)].map((Z)=>Z[1])}function SQ(J,Q){let Z=Q.exists??VQ;if(J==="~"||J.startsWith("~/")||J.startsWith("~\\"))return{abs:L(KQ(),J.slice(2)),label:J};if(zJ(J))return{abs:L(J),label:J};let $=Q.resolve(J);if($!==null)return{abs:L(Q.cwd,$),label:$};for(let V of Q.roots??[]){let Y=L(V,J);if((Y===L(V)||Y.startsWith(L(V)+MJ))&&Z(Y))return{abs:Y,label:J,root:V}}return null}function OQ(J,Q){try{if(Q.read){let $=Buffer.from(Q.read(J).slice(0,32),"binary");return n($)??null}let Z=jQ(J,"r");try{let $=Buffer.alloc(32),V=UQ(Z,$,0,32,0);return n($.subarray(0,V))??null}finally{GQ(Z)}}catch{return null}}function BZ(J,Q){let Z=[...new Set(Q.mentions??DQ(J))],$=[],V=[],Y=[];if(Z.length===0)return{text:J,attached:V,notes:$};let W=L(Q.cwd),G=Q.stat??((j)=>FQ(j)),D=OJ;for(let j of Z){if(V.length>=qJ){$.push(`@${j}: not attached \u2014 ${qJ} files per message is the cap; ask me to read it`);continue}let U=SQ(j,Q);if(U===null){$.push(`@${j}: no file in the workspace matches`);continue}let{abs:F}=U,K=U.label;if(U.root===void 0&&!zJ(j)&&!j.startsWith("~")&&F!==W&&!F.startsWith(W+MJ)){$.push(`@${K}: outside the workspace \u2014 not attached`);continue}let H;try{H=G(F)}catch{$.push(`@${K}: cannot be read \u2014 not attached`);continue}if(!H.isFile()){$.push(`@${K}: a directory \u2014 name a file in it`);continue}if(Q.attachImage){let b=OQ(F,Q);if(b!==null){Q.attachImage(F),$.push(`@${K}: attached as an image (${b})${U.root?` (from ${U.root})`:""}`);continue}}if(H.size>HQ){$.push(`@${K}: ${(H.size/1048576).toFixed(1)} MB is too large to attach \u2014 ask me to read a window of it`);continue}let B;try{B=Q.read?Q.read(F):YQ(F,"utf8")}catch{$.push(`@${K}: cannot be read \u2014 not attached`);continue}if(B.slice(0,qQ).includes("\x00")){$.push(`@${K}: a binary file \u2014 not attached`);continue}if(D<XQ){$.push(`@${K}: not attached \u2014 this message already carries ${OJ.toLocaleString()} characters of files; ask me to read it`);continue}let q=Q.read?PQ(F,B):RJ(F),P=q.lines.length,S=Math.min(P,BQ),I=a({...q,lines:q.lines.slice(0,S)}).replace(/\n$/,"");while(I.length>D&&S>1)S=Math.max(1,Math.floor(S*D/I.length)),I=a({...q,lines:q.lines.slice(0,S)}).replace(/\n$/,"");let O=S<P;D-=I.length;let z=O?`[@${K} \u2014 attached: ${S} of ${P} lines, capped: read it with offset ${S+1} for the rest]`:`[@${K} \u2014 attached: ${P} lines]`;if(Y.push(`${z}
|
|
4
|
+
${I}
|
|
5
|
+
(showing lines ${P===0?0:1}-${S} of ${P})`),V.push({path:K,shown:S,total:P,capped:O}),O)$.push(`@${K}: ${P} lines \u2014 attached the first ${S}; the rest is a read away`)}if(Y.length===0)return{text:J,attached:V,notes:$};return{text:`${J.trimEnd()}
|
|
6
|
+
|
|
7
|
+
${_J}
|
|
8
|
+
|
|
9
|
+
${Y.join(`
|
|
10
|
+
|
|
11
|
+
`)}`,attached:V,notes:$}}function PQ(J,Q){return{path:J,tag:NJ(Q),lines:Q.split(`
|
|
12
|
+
`).map((Z,$)=>({n:$+1,hash:PJ(Z),text:Z}))}}function HZ(J){let Q=J.split(`
|
|
13
|
+
`),Z=Q.indexOf(_J);if(Z<0)return{text:J,files:[]};let $=[];for(let V of Q.slice(Z+1)){let Y=IQ.exec(V);if(Y)$.push(Y[3]!==void 0?`${Y[1]} \xB7 ${Y[2]}/${Y[3]} lines, capped`:`${Y[1]} \xB7 ${Y[2]} lines`)}return{text:Q.slice(0,Z).join(`
|
|
14
|
+
`).trimEnd(),files:$}}var o,BQ=400,qJ=8,OJ=60000,HQ=2097152,XQ=500,_J="(files attached by @mention \u2014 each block is what `read` returns for the file; its edit anchors are valid)",IQ,qQ=8192;var gJ=x(()=>{$Q();WQ();o=/(?:^|\s)@([\w./\\:~-]+)/g;IQ=/^\[@(\S+) \u2014 attached: (\d+)(?: of (\d+))? lines(, capped[^\]]*)?\]$/});function kJ(J){let Q=J.trim();if(Q[0]==="/"){let Z=/^\/(\S*)(\s+(.*))?$/s.exec(J.trimStart());return{kind:"slash",cmd:Z?.[1]??"",arg:Z?.[2]===void 0?void 0:(Z[3]??"").trim(),mentions:[]}}if(Q[0]==="!"&&Q.length>1&&Q[1]!=="!"&&!/\s/.test(Q[1]))return{kind:"shell",cmd:Q.slice(1).trim(),mentions:[]};return{kind:"text",mentions:[...Q.matchAll(o)].map((Z)=>Z[1])}}function NQ(J,Q){let Z=/(?:^|\s)@([\w./-]*)$/.exec(J.slice(0,Q));return Z?{start:Q-Z[1].length-1,query:Z[1]}:null}function OZ(J,Q,Z=y){if(!J)return null;let $=J.replace(/^@/,"");if(Q.includes($))return $;let V=Q.filter((Y)=>Y.endsWith("/"+$)||Y.split("/").pop()===$);if(V.length===1)return V[0];return T($,Q,Z)[0]??null}function T(J,Q,Z,$=String){if(!J)return[...Q];return Q.map((V)=>({it:V,m:Z(J,$(V))})).filter((V)=>V.m).sort((V,Y)=>Y.m.score-V.m.score).map((V)=>V.it)}function A(J){let Q=new Set(e.map((Z)=>Z.name));return[...e.map(({name:Z,description:$,arg:V,local:Y})=>({name:Z,description:$,arg:V,local:Y})),...J.commands.filter((Z)=>!Q.has(Z.name)).map((Z)=>{if(!Z.choices)return{name:Z.name,description:Z.description};let $=typeof Z.choices==="function"?"provider/model":Z.choices.join("\xB7");return{name:Z.name,description:Z.description,arg:$,choices:Z.choices,...Z.choicesThen?{choicesThen:Z.choicesThen}:{}}})]}function t(J,Q,Z,$=y){return T(Q,Z,$).slice(0,6).map((V)=>({label:V,hint:J.files.statuses.get(V)??""}))}function PZ(J,Q,Z=y){return _Q(J,Q,Z).slice(0,MQ)}function _Q(J,Q,Z){if(J.palette||J.help||J.card)return[];let $=J.input.text;if(!$.trim())return[];let V=NQ($,J.input.cur);if(V)return t(J,V.query,Q,Z).map((U)=>({kind:"mention",label:U.label,hint:U.hint,enter:"complete",apply:{text:$.slice(0,V.start)+"@"+U.label+" "+$.slice(J.input.cur),cur:V.start+U.label.length+2}}));let Y=kJ($);if(Y.kind!=="slash")return[];if(Y.arg===void 0)return T(Y.cmd??"",A(J),Z,(U)=>U.name).map((U)=>{let F=U.arg!==void 0&&!U.arg.endsWith("?"),K="/"+U.name+(U.arg?" ":"");return{kind:"slash",label:"/"+U.name,hint:U.description,arg:U.arg,apply:{text:K,cur:K.length},enter:F?"complete":"submit"}});let W=e.find((U)=>U.name===Y.cmd);if(W?.options)return W.options(J,Y.arg,Z).map((U)=>{let F="/"+W.name+" "+U.label;return{kind:"arg",label:U.label,hint:U.hint,apply:{text:F,cur:F.length},enter:"submit"}});let G=A(J).find((U)=>U.name===Y.cmd&&U.choices),D=G?RQ(G):[];if(!G||!D.length)return[];let j=G.choicesThen==="complete";return T(Y.arg,D,Z).map((U)=>{let F="/"+G.name+" "+U+(j?" ":"");return{kind:"arg",label:U,hint:"",apply:{text:F,cur:F.length},enter:j?"complete":"submit"}})}function NZ(J,Q,Z,$,V,Y){if(!$.length||Z.input.sgSel<0)return;let W=Math.min(Z.input.sgSel,$.length-1),G=$[0].kind,D=kJ(Z.input.text).cmd,j=G==="mention"?"mention a file":G==="slash"?"commands":`/${D} \xB7 ${A(Z).find((q)=>q.name===D)?.arg??""}`,U=Math.min(Q.w-4,76),F=Q.x+2,K=$.length+3,H=Math.max(Q.y+1,Q.y+Q.h-3-K);J.box(F,H,U,K,X(V.rule2),V.bg2),J.text(F+2,H+1,[[j,X(V.dim,V.bg2)]]);let B=G==="mention"?"tab insert":"tab complete \u23CE run";J.put(F+U-2-B.length,H+1,B,X(V.dim,V.bg2)),$.forEach((q,P)=>{let S=H+2+P,I=P===W,O=[[I?"\u25B8 ":" ",X(V.accent,V.bg2)],[q.label,X(I?V.fg:V.fg2,V.bg2,I?E.BOLD:0)]];if(q.arg)O.push([" "+q.arg,X(V.dim,V.bg2)]);if(J.text(F+2,S,O,U-4),q.hint){let z=Math.min(q.hint.length,34);J.clip(F+U-2-z,S,q.hint,X(V.muted,V.bg2),z)}Y?.push({rect:{x:F,y:S,w:U,h:1},onClick:()=>{Z.input.sgSel=P},key:TJ})})}function gQ(J){let Q=A(J).map(($)=>({label:"/"+$.name,group:"commands",action:"/"+$.name}));for(let $ of w)Q.push({label:`theme ${$}`,group:"theme",action:`theme:${$}`});let Z=[["code view","code"],["diff view","diff"],["run output","run"],["agents board","agents"]];for(let[$,V]of Z)Q.push({label:$,group:"view",action:`mode:${V}`});for(let $ of["messages","code","files"])Q.push({label:`focus ${$}`,group:"view",action:`focus:${$}`});for(let $ of J.files.paths)Q.push({label:$,group:"open",action:`open:${$}`});return Q}function bJ(J,Q){if(Q!=="palette")J.palette=null;if(Q!=="market")J.market=null;if(Q!=="help")J.help=!1;if(Q!=="context")J.context=null;if(Q!=="wizard")J.wizard=null}function RZ(J){let Q=[];if(J.palette)Q.push("palette");if(J.market)Q.push("market");if(J.help)Q.push("help");if(J.context)Q.push("context");if(J.wizard)Q.push("wizard");return Q}function zZ(J){bJ(J,"help"),J.help=!0}function EQ(J,Q=gQ(J),Z){bJ(J,"palette"),J.palette={query:"",sel:0,items:Q,...Z!==void 0?{title:Z}:{}}}function s(J){J.palette=null}function MZ(J,Q=Date.now()){let Z=[...J.notices].reverse().map(($)=>({label:`${$.tone==="error"?"\u2717":$.tone==="warn"?"\u25C6":"\xB7"} ${$.text}`,group:"notices",action:"noop:",hint:kQ(Q-$.at)}));IJ(J),EQ(J,Z.length?Z:[{label:"no notifications yet",group:"notices",action:"noop:",hint:""}],"notifications")}function kQ(J){let Q=Math.max(0,Math.round(J/1000));if(Q<5)return"just now";if(Q<60)return`${Q}s`;if(Q<3600)return`${Math.round(Q/60)}m`;return`${Math.round(Q/3600)}h`}function AJ(J,Q=y){let Z=J.query.trim();if(!Z){let $=0;return J.items.filter((V)=>V.group!=="open"||$++<6)}return T(Z,J.items,Q,($)=>$.label).sort(($,V)=>EJ.indexOf($.group)-EJ.indexOf(V.group))}function LQ(J,Q){if(Q.hint!==void 0)return Q.hint;if(Q.action.startsWith("/"))return A(J).find((Y)=>"/"+Y.name===Q.action)?.description??"";let Z=Q.action.indexOf(":"),$=Q.action.slice(0,Z),V=Q.action.slice(Z+1);switch($){case"theme":return LJ[V]??"";case"mode":return zQ[V]??"";case"focus":return V==="files"?"\u2303e":"";case"open":return J.files.statuses.get(V)??"";default:return""}}function _Z(J,Q,Z,$,V=y,Y){let W=$.palette;if(!W)return null;Y?.push({rect:{x:0,y:0,w:Q.w,h:Q.h},onClick:()=>s($)});let G=AJ(W,V);W.sel=Math.max(0,Math.min(W.sel,G.length-1));let D=[],j="";G.forEach((I,O)=>{if(I.group!==j)j=I.group,D.push({type:"group",name:j});D.push({type:"item",it:I,idx:O})});let U=Math.min(72,Q.w-10),F=Math.floor((Q.w-U)/2),K=Math.max(3,Math.min(D.length||1,Math.floor(Q.h/2))),H=K+5,B=Math.max(2,Math.floor(Q.h*0.14));J.box(F,B,U,H,X(Z.accent),Z.bg2);let q=` ${W.title??"commands"} `;if(J.clip(F+2,B,q,X(Z.accent,-1,E.BOLD),Math.max(0,U-4)),Y?.push({rect:{x:F,y:B,w:U,h:H},onClick:()=>{}}),J.put(F+2,B+1,"\u258C",X(Z.accent,Z.bg2)),W.query)J.put(F+4,B+1,W.query,X(Z.fg,Z.bg2,E.BOLD),U-12);else J.put(F+4,B+1,W.title===void 0?"commands, themes, views, files\u2026":"type to filter\u2026",X(Z.dim,Z.bg2),U-12);J.put(F+U-6,B+1,"esc",X(Z.dim,Z.bg2)),J.hline(F+1,B+2,U-2,X(Z.rule2,Z.bg2),"\u254C");let P=D.findIndex((I)=>I.type==="item"&&I.idx===W.sel),S=P>=K-1?P-K+2:0;if(!D.length)J.put(F+4,B+3,"no matches",X(Z.muted,Z.bg2));for(let I=0;I<K;I++){let O=D[S+I];if(!O)break;let z=B+3+I;if(O.type==="group"){J.put(F+4,z,O.name,X(Z.dim,Z.bg2),U-6);continue}let b=O.idx===W.sel;J.text(F+2,z,[[b?"\u25B8 ":" ",X(Z.accent,Z.bg2)],[O.it.label,X(b?Z.fg:Z.fg2,Z.bg2,b?E.BOLD:0)]],U-30);let u=LQ($,O.it);if(u)J.clip(F+U-3-Math.min(u.length,24),z,u,X(Z.muted,Z.bg2),24);Y?.push({rect:{x:F,y:z,w:U,h:1},onClick:()=>{W.sel=O.idx},key:TJ})}return{x:F+4+W.query.length,y:B+1}}function gZ(J,Q,Z,$=y){let V=J.palette;if(!V)return;let{name:Y,ctrl:W,alt:G,ch:D}=Q;if(Y==="escape"||W&&(Y==="k"||Y==="p")){s(J);return}let j=AJ(V,$),U=Math.max(1,j.length);if(Y==="up"){V.sel=(V.sel-1+U)%U;return}if(Y==="down"){V.sel=(V.sel+1)%U;return}if(Y==="enter"){let K=j[V.sel];if(s(J),K)Z(K.action);return}if(Y==="backspace"){V.query=[...V.query].slice(0,-1).join(""),V.sel=0;return}let F=Y==="space"?" ":D;if(F&&!W&&!G)V.query+=F,V.sel=0}function TQ(J){return A(J).map((Q)=>["/"+Q.name,Q.description,Q.arg??""])}function EZ(J,Q,Z,$,V){let Y=TQ($),W=Math.min(Q.w-8,112),G=W>=110,D=Math.max(1,Q.h-8),j=Y.length>D?[...Y.slice(0,D-1),["\u2026",`${Y.length-D+1} more \xB7 /help lists all`,""]]:Y,U=m.length>D?[...m.slice(0,D-1),["\u2026",`${m.length-D+1} more`]]:[...m],F=Math.max(j.length,U.length)+6,K=Math.floor((Q.w-W)/2),H=Math.max(1,Math.floor((Q.h-F)/2));J.box(K,H,W,F,X(Z.accent),Z.bg2),J.text(K+2,H,[[" help ",X(Z.accent,-1,E.BOLD)]]),J.put(K+W-14,H," esc closes ",X(Z.dim));let B=G?K+70:K+50;J.put(K+3,H+2,"commands",X(Z.muted,Z.bg2)),J.put(B,H+2,"keys",X(Z.muted,Z.bg2)),j.forEach(([q,P,S],I)=>{let O=H+3+I;if(J.put(K+3,O,q,X(Z.accent,Z.bg2),13),J.put(K+17,O,P,X(Z.fg2,Z.bg2),G?28:30),G&&S)J.put(K+46,O,S,X(Z.dim,Z.bg2),22)}),U.forEach(([q,P],S)=>{let I=H+3+S;J.put(B,I,q,X(Z.fg,Z.bg2,E.BOLD),10),J.put(B+11,I,P,X(Z.fg2,Z.bg2),W-(B-K)-13)}),J.put(K+3,H+F-2,"plain text and !commands reach the agent as typed \xB7 @file attaches the file as a read (400 lines, 8 files)",X(Z.dim,Z.bg2),W-6),V?.push({rect:{x:0,y:0,w:Q.w,h:Q.h},onClick:()=>{$.help=!1}})}var y=(J,Q)=>{J=J.toLowerCase(),Q=Q.toLowerCase();let Z=0,$=0,V=-2,Y=[];for(let W=0;W<Q.length&&Z<J.length;W++)if(Q[W]===J[Z])Y.push(W),$+=(V===W-1?3:1)+(W===0||Q[W-1]===" "||Q[W-1]==="/"?2:0),V=W,Z++;return Z===J.length?{score:$,idx:Y}:null},RQ=(J)=>typeof J.choices==="function"?J.choices():J.choices??[],e,LJ,zQ,MQ=10,X=(J,Q=-1,Z=0)=>({fg:J,bg:Q,a:Z}),TJ,EJ,m;var bQ=x(()=>{c();SJ();gJ();e=[{name:"help",description:"commands + keys card",local:!0},{name:"theme",description:"switch palette",arg:"night\xB7ember\xB7contrast",local:!0,options:(J,Q,Z)=>T(Q,w,Z).map(($)=>({label:$,hint:LJ[$]}))},{name:"open",description:"open a file in the code view",arg:"path",local:!0,options:(J,Q,Z)=>t(J,Q,J.files.paths,Z)},{name:"diff",description:"diff of a file (or the current one)",arg:"path?",local:!0,options:(J,Q,Z)=>{let $=J.files.paths.filter((V)=>J.files.statuses.has(V));return t(J,Q,$.length?$:J.files.paths,Z)}},{name:"focus",description:"move keyboard focus",arg:"messages\xB7code\xB7files",local:!0,options:(J,Q,Z)=>T(Q,["messages","code","files"],Z).map(($)=>({label:$,hint:""}))},{name:"agents",description:"the crew board (code panel \u2237)",local:!0},{name:"notices",description:"notification history (\u2303b)",local:!0},{name:"market",description:"install MCP servers, skills, plugins (\u2303m)",local:!0},{name:"context",description:"what is in the window right now, item by item (\u2303g)",local:!0}],LJ={night:"night + mint",ember:"ink + ember",contrast:"pure contrast"},zQ={code:"\u2303s",diff:"\u2303d",run:"\u2303r",agents:"\u2303a"};TJ={type:"key",name:"enter"};EJ=["commands","theme","view","open"];m=[["\u23CE","send \xB7 confirm a card \xB7 run the suggestion"],["tab \u21E7tab","complete a suggestion \xB7 cycle focus"],["esc esc","stop the run (the first esc warns)"],["\u2303c","quit (interrupts a run first)"],["\u2303k \u2303p","command palette"],["\u2303s \u2303d \u2303r","code \xB7 diff \xB7 run view"],["\u2303a","agents board"],["\u2303e","files panel"],["\u2303o","next tab (narrow terminal)"],["\u2303b","notifications"],["\u2303m","market (install servers, skills, plugins)"],["\u2303g","context (what is in the window, and how far our count is from the provider\u2019s)"],["\u2325d","market: the selected item's documentation"],["\u2303v","paste image \xB7 drop a file to attach"],["\u2303t","next theme"],["\u2303n","new session (/new)"],["\u2303u","clear the prompt line"],["\u2191\u2193 \u2190\u2192","files: pick \xB7 fold \u2014 code: scroll \xB7 mode \u2014 prompt: history"],["\u2303\u2190 \u2303\u2192","prompt: jump by word"],["home end","prompt: line start \xB7 end (end re-sticks the tail)"],["pgup pgdn","scroll messages \xB7 end sticks to the tail"],["mouse","click \xB7 wheel \xB7 drag a scrollbar \u2014 drag over the chat to select and copy it"],["@file","mention a file (picker)"]]});
|
|
15
|
+
export{E as ka,w as la,AQ as ma,yQ as na,xQ as oa,fQ as pa,c as qa,M as ra,$J as sa,vJ as ta,WJ as ua,VJ as va,jJ as wa,lQ as xa,tJ as ya,iQ as za,nQ as Aa,aQ as Ba,oQ as Ca,eQ as Da,QQ as Ea,h as Fa,tQ as Ga,sQ as Ha,JZ as Ia,QZ as Ja,FJ as Ka,ZZ as La,$Z as Ma,WZ as Na,VZ as Oa,jZ as Pa,SJ as Qa,DQ as Ra,BZ as Sa,HZ as Ta,gJ as Ua,y as Va,kJ as Wa,OZ as Xa,PZ as Ya,NZ as Za,bJ as _a,RZ as $a,zZ as ab,EQ as bb,s as cb,MZ as db,AJ as eb,_Z as fb,gZ as gb,EZ as hb,bQ as ib};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{di as v,fi as u}from"./main-kba6zeyd.js";import{Dl as o,ul as p}from"./main-a3f51n0x.js";import{wn as F}from"./main-qsevpgsv.js";class h{opts;jobs=new Map;listeners=new Set;seq=0;unbind;constructor(z={}){this.opts=z;let Q=z.owner;if(Q){let V=()=>{this.killAll()};Q.addEventListener("abort",V,{once:!0}),this.unbind=()=>Q.removeEventListener("abort",V)}}subscribe(z){return this.listeners.add(z),()=>this.listeners.delete(z)}list(){return[...this.jobs.values()].map((z)=>({...z.info}))}status(z){let Q=this.jobs.get(z);return Q?{...Q.info}:void 0}get running(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")z++;return z}start(z,Q){if(this.running>=y)return{ok:!1,reason:`${y} background jobs already running (bash_list shows them; bash_kill frees a slot) \u2014 run this one in the foreground or wait`};let V=`b${++this.seq}`,Z=new AbortController,$={info:{id:V,command:z,status:"running",startedAt:Date.now(),dropped:0,drained:!1},buf:"",cursor:0,ac:Z,done:Promise.resolve()},q=new TextDecoder,J={onSpawn:(K)=>{$.info.pid=K},onChunk:(K,W)=>{this.append($,q.decode(W,{stream:!0}))}};return this.jobs.set(V,$),$.done=v().run(z,Q,Z.signal,J).then((K)=>{if($.info.status==="killed"){this.finish($);return}if($.info.status=K.code===0?"exited":"failed",$.info.exitCode=K.code,$.buf===""&&K.text!=="")this.append($,K.text);this.finish($)},(K)=>{$.info.status="failed",this.append($,`
|
|
3
|
+
[job runner threw: ${K instanceof Error?K.message:String(K)}]`),this.finish($)}),{ok:!0,info:{...$.info}}}append(z,Q){if(Q==="")return;if(z.buf+=Q,z.buf.length>g){let V=z.buf.length-g;z.buf=z.buf.slice(V),z.info.dropped+=V,z.cursor=Math.max(0,z.cursor-V)}}finish(z){z.info.finishedAt=Date.now();let Q={...z.info};for(let Z of this.listeners)Z(Q);let V=z.info.status==="killed"?"killed":`exit=${z.info.exitCode}`;this.opts.notify?.push(`background job ${z.info.id} finished (${V}): ${m(z.info.command,60)} \u2014 bash_output ${z.info.id} reads what it printed`),this.reap()}read(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session (bash_list shows them; a finished job is dropped after its output has been read)`};let V=Q.info.dropped,$=Q.buf.slice(Q.cursor).slice(0,x);Q.cursor+=$.length;let q=Q.cursor<Q.buf.length;if(!q&&Q.info.status!=="running")Q.info.drained=!0,this.reap();return{ok:!0,info:{...Q.info},text:$,more:q,lost:V}}kill(z){let Q=this.jobs.get(z);if(!Q)return{ok:!1,reason:`no background job "${z}" in this session`};if(Q.info.status!=="running")return{ok:!0,info:{...Q.info}};return Q.info.status="killed",Q.ac.abort(),{ok:!0,info:{...Q.info}}}killAll(){let z=0;for(let Q of this.jobs.values())if(Q.info.status==="running")this.kill(Q.info.id),z++;return z}async drain(){await Promise.allSettled([...this.jobs.values()].map((z)=>z.done))}dispose(){this.killAll(),this.unbind?.(),this.listeners.clear()}reap(){let z=[...this.jobs.values()].filter((Q)=>Q.info.status!=="running"&&Q.info.drained);if(z.length<=M)return;z.sort((Q,V)=>(Q.info.finishedAt??0)-(V.info.finishedAt??0));for(let Q of z.slice(0,z.length-M))this.jobs.delete(Q.info.id)}}function $z(z){k=z}function A(){return k!==null}function Wz(){return k}function _(z,Q){if(!k)return{ok:!1,reason:"background jobs are not available on this surface \u2014 run the command in the foreground (drop run_in_background)"};return k.start(z,Q)}var y=4,g=200000,x=1e4,M=8,m=(z,Q)=>z.length>Q?z.slice(0,Q-1)+"\u2026":z,k=null;var S=F(()=>{u()});function f(z){if(z===void 0||z===null)return;let Q=typeof z==="number"?z:Number(z);if(!Number.isFinite(Q)||Q<=0)return Error(`timeout_ms must be a positive number of milliseconds (got ${JSON.stringify(z)})`);if(Q>L)return Error(`timeout_ms ${Q} is longer than the ${L}ms cap \u2014 use run_in_background for work that takes longer`);return Math.floor(Q)}function E(z){let Q=d.find((V)=>V.test(z));return Q?`command refused by safety blocklist (matched ${Q.source}): this tool is not a sandbox; rephrase without destructive system commands`:null}var L=600000,l,d;var b=F(()=>{u();S();l={schema:{name:"bash",description:"Run a shell command in the workspace (cwd locked to the session cwd). One automatic retry on non-zero exit. "+"Destructive system commands are refused by a best-effort blocklist \u2014 this is NOT a sandbox. Output truncated to 10k chars. "+`\`timeout_ms\` gives up after that long and RETURNS what the command printed (max ${L}ms); the process tree is killed. `+"`run_in_background: true` returns a job id at once instead of waiting \u2014 for a dev server, a long build, a slow test run. "+"Read it later with bash_output (only NEW output per read), see them with bash_list, stop one with bash_kill; a finished job also posts one note here by itself.",args:{type:"object",properties:{command:{type:"string"},timeout_ms:{type:"number",description:`give up after this many ms and return the partial output (1..${L}); a timeout is never retried`},run_in_background:{type:"boolean",description:"start it as a background job and return its id immediately (bash_output reads it)"}},required:["command"]}},kind:"execute",sequential:!0,async execute(z,Q){let V=z,Z=String(V.command),$=E(Z);if($)return{ok:!1,output:$};if(V.run_in_background===!0){if(!A())return{ok:!1,output:"background jobs are not available on this surface \u2014 drop run_in_background to run it in the foreground"};let W=_(Z,Q.cwd);if(!W.ok)return{ok:!1,output:W.reason};return{ok:!0,output:`started background job ${W.info.id}: ${Z}
|
|
4
|
+
It runs while you continue \u2014 do NOT poll in a loop. \`bash_output ${W.info.id}\` reads what is new; a note lands here when it finishes.`,data:W.info}}let q=f(V.timeout_ms);if(q instanceof Error)return{ok:!1,output:q.message};let J=async()=>{if(q===void 0){let G=await v().run(Z,Q.cwd,Q.signal);return{code:G.code,text:G.text,timedOut:!1}}let W=new AbortController,Y=()=>W.abort();Q.signal.addEventListener("abort",Y,{once:!0});let U,B=!1;try{U=setTimeout(()=>{B=!0,W.abort()},q);let G=await v().run(Z,Q.cwd,W.signal);return{code:G.code,text:G.text,timedOut:B}}finally{clearTimeout(U),Q.signal.removeEventListener("abort",Y)}},K=await J();if(K.code!==0&&!K.timedOut&&!Q.signal.aborted)K=await J();if(K.timedOut)return{ok:!1,output:`timed out after ${q}ms (process tree killed; what it printed follows)
|
|
5
|
+
${K.text}`};return{ok:K.code===0,output:`exit=${K.code}
|
|
6
|
+
${K.text}`}}};d=[/rm\s+(-[a-z]*\s+)*\/(\s|$)/,/rm\s+(-[a-z]*\s+)*\/\*/,/rm\s+(-[a-z]*\s+)*(--no-preserve-root\s+)?\*(\s|$)/,/:\(\)\s*\{/,/\bmkfs(\.\w+)?\b/,/\b(shutdown|reboot|poweroff|halt)\b/,/(^|[;&|\s])(sudo\s+)?format\s+(\/|[c-z]:)/i,/(^|[;&|\s])(sudo\s+)?del\s+\/[fqs]/i,/(^|[;&|\s])(sudo\s+)?rd\s+\/[sq]/i,/(^|[;&|\s])(sudo\s+)?remove-item\s+-(rec|r|f|force)/i,/\bdd\s+[^|]*of=\/dev\/(sd|nvme|hd|disk)/,/>\s*\/dev\/(sd|nvme|hd|disk)/,/\bsudo\b.*\b(rm|mkfs|dd|shutdown|reboot|halt|format)\b/]});import{createHash as i}from"crypto";import{readFileSync as D,writeFileSync as j,existsSync as R}from"fs";import{dirname as n}from"path";function X(z){let Q=z.replace(/\s/g,""),V=2166136261;for(let Z=0;Z<Q.length;Z++)V^=Q.charCodeAt(Z),V=Math.imul(V,16777619)>>>0;return V.toString(36).padStart(3,"0").slice(-3)}function N(z){return i("sha1").update(z).digest("hex").slice(0,4)}function s(z){let Q=D(z,"utf8"),V=Q.split(`
|
|
7
|
+
`).map((Z,$)=>({n:$+1,hash:X(Z),text:Z}));return{path:z,tag:N(Q),lines:V}}function c(z){let Q=`${z.path}#${z.tag}`,V=z.lines.map((Z)=>`${Z.n}#${Z.hash}|${Z.text}`).join(`
|
|
8
|
+
`);return`${Q}
|
|
9
|
+
${V}`}function r(z,Q,V){let Z=N(z),$=Q.find((W)=>W.tag!==Z);if($)return{ok:!1,failure:{kind:"tag-mismatch",path:V,expected:$.tag,actual:Z}};let q=z.split(`
|
|
10
|
+
`),J=[...Q].sort((W,Y)=>Y.anchorLine-W.anchorLine);for(let W of J){if(W.anchorLine<1||W.anchorLine>q.length)return{ok:!1,failure:{kind:"out-of-range",path:V,line:W.anchorLine,lineCount:q.length}};let Y=q[W.anchorLine-1],U=X(Y);if(U!==W.anchorHash){let B=[];for(let C=0;C<q.length&&B.length<a;C++)if(X(q[C])===W.anchorHash)B.push(C+1);let G=B.length>0?`line ${B[0]} currently holds that hash: ${q[B[0]-1].slice(0,80)}`:`no line matches; line ${W.anchorLine} is now: ${Y.slice(0,80)}`;return{ok:!1,failure:{kind:"hash-mismatch",path:V,line:W.anchorLine,expected:W.anchorHash,actual:U,nearest:G,text:Y.slice(0,80),matches:B}}}q.splice(W.anchorLine-1,1,...W.newLines)}let K=q.join(`
|
|
11
|
+
`);return{ok:!0,content:K,newTag:N(K)}}function t(z,Q){if(!R(z))return{ok:!1,failure:{kind:"out-of-range",path:z,line:0,lineCount:0}};let V=r(D(z,"utf8"),Q,z);if(!V.ok)return V;return j(z,V.content),{ok:!0,newTag:V.newTag}}function e(z){let V=I-15-w.length-1;return`Edit rejected: ${P(zz(z),V)} ${w}`}function zz(z){switch(z.kind){case"tag-mismatch":return`stale read \u2014 ${z.path} changed since you read it (file TAG is now ${z.actual}, your edit carries ${z.expected}).`;case"hash-mismatch":{let Q=z.matches.length>0?`Lines whose hash matches your anchor: ${z.matches.join(", ")} \u2014 did you mean one of those?`:"No line in the file has that hash now \u2014 the content changed since your read.";return`anchor mismatch at ${z.path}:${z.line} \u2014 line ${z.line} now reads ${JSON.stringify(z.text)} (hash ${z.actual}), your anchor expected hash ${z.expected}. ${Q}`}case"out-of-range":return`line ${z.line} is out of range \u2014 ${z.path} has ${z.lineCount} lines (valid anchors: 1-${z.lineCount}).`}}function P(z,Q){return z.length<=Q?z:z.slice(0,Math.max(0,Q-1))+"\u2026"}function T(z,Q){return p(z,Q)}function Qz(z,Q,V){let Z=z.lines.length,$=Math.max(1,Math.floor(Q));if($>Z)return`${z.path}#${z.tag}
|
|
12
|
+
(showing lines 0-0 of ${Z}; offset ${$} is past EOF)`;let q=Math.min(Z,$+Math.floor(V)-1),J=z.lines.slice($-1,q);return c({...z,lines:J}).replace(/\n$/,"")+`
|
|
13
|
+
(showing lines ${$}-${q} of ${Z})`}function Cz(z){O=z}var a=3,I=600,w="Remedy: re-read the file with `read` to get fresh line hashes, then retry the edit.",H=8,vz,O,Lz,Oz;var Vz=F(()=>{o();b();vz={schema:{name:"read",description:"Read a file window. Output is `path#TAG` header plus `N#hash|content` lines; use hashes for edit anchors. Defaults: offset 1, limit 2000 lines. Footer notes `showing lines X-Y of Z`; if Y < Z pass a larger offset to see more.",args:{type:"object",properties:{path:{type:"string"},offset:{type:"integer",description:"first line to show (1-based, default 1)"},limit:{type:"integer",description:"max lines to show (default 2000)"}},required:["path"]}},kind:"read",sequential:!1,execute(z,Q){let V=z,Z=T(Q.cwd,V.path);if(!R(Z))return Promise.resolve({ok:!1,output:`file not found: ${Z}`});let $=Number.isFinite(V.offset)&&V.offset>0?Math.floor(V.offset):1,q=Number.isFinite(V.limit)&&V.limit>0?Math.floor(V.limit):2000;return Promise.resolve({ok:!0,output:Qz(s(Z),$,q)})}};Lz={schema:{name:"edit",description:"Anchored edit. Each op replaces the line at anchorLine (whose hash must equal anchorHash) with newLines. tag must match the TAG from your last read.",args:{type:"object",properties:{path:{type:"string"},edits:{type:"array",items:{type:"object",properties:{tag:{type:"string"},anchorLine:{type:"integer"},anchorHash:{type:"string"},newLines:{type:"array",items:{type:"string"}}},required:["tag","anchorLine","anchorHash","newLines"]}}},required:["path","edits"]}},kind:"write",sequential:!0,execute(z,Q){let V=z,Z=T(Q.cwd,V.path);if(!R(Z))return Promise.resolve({ok:!1,output:P(`Edit rejected: file not found: ${Z} \u2014 check the path (relative paths resolve against ${Q.cwd}) or create the file with \`write\`.`,I)});let $=D(Z,"utf8"),q=t(Z,V.edits.map((J)=>({...J,path:Z})));if(!q.ok)return Promise.resolve({ok:!1,output:e(q.failure)});if(O){let J=O($,Z),K=O(D(Z,"utf8"),Z),W=new Set(J),Y=K.filter((U)=>!W.has(U));if(Y.length>0){j(Z,$);let U=Y.slice(0,H).join(`
|
|
14
|
+
`)+(Y.length>H?`
|
|
15
|
+
\u2026 and ${Y.length-H} more`:"");return Promise.resolve({ok:!1,output:`Edit applied but lint failed \u2014 file reverted to original. New lint errors:
|
|
16
|
+
${U}
|
|
17
|
+
Fix these and retry the edit.`})}}return Promise.resolve({ok:!0,output:`applied ${V.edits.length} edit(s); new TAG ${q.newTag}`})}},Oz={schema:{name:"write",description:"Create or overwrite a file with content.",args:{type:"object",properties:{path:{type:"string"},content:{type:"string"}},required:["path","content"]}},kind:"write",sequential:!0,execute(z,Q){let V=z,Z=T(Q.cwd,V.path),$=n(Z);if(!R($))return Promise.resolve({ok:!1,output:P(`Write rejected: directory ${$} does not exist \u2014 create it first (bash: mkdir -p ${JSON.stringify($)}) or write into an existing directory.`,I)});return j(Z,V.content),Promise.resolve({ok:!0,output:`wrote ${Z} (${V.content.length} bytes, TAG ${N(V.content)})`})}}});
|
|
18
|
+
export{h as Vf,$z as Wf,Wz as Xf,S as Yf,l as Zf,E as _f,X as $f,N as ag,s as bg,c as cg,r as dg,t as eg,I as fg,e as gg,vz as hg,Cz as ig,Lz as jg,Oz as kg,Vz as lg};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var N=8,O=80,P=2000,S="ask_user unavailable: no interactive user in this session (headless run/serve/acp) \u2014 proceed with your best judgment or stop",U="ask_user aborted",V="user declined to answer";function L(B){let j=B&&typeof B==="object"?B:{},C=typeof j.question==="string"?j.question.trim():"";if(C==="")return"question must be a non-empty string";if(C.length>2000)return`question too long (${C.length} chars, max 2000)`;let z;if(j.options!==void 0&&j.options!==null){if(!Array.isArray(j.options))return"options must be an array of strings";if(j.options.length>8)return`too many options (${j.options.length}, max 8)`;z=[];for(let G of j.options){if(typeof G!=="string"||G.trim()==="")return"every option must be a non-empty string";let I=G.trim();if(I.length>80)return`option too long (${I.length} chars, max 80): ${I.slice(0,40)}\u2026`;z.push(I)}if(z.length===0)z=void 0}if(j.allowFreeText!==void 0&&typeof j.allowFreeText!=="boolean")return"allowFreeText must be a boolean";let E=j.allowFreeText!==!1;if(!z&&!E)return"nothing to answer with: provide options or allow free text";return{question:C,...z?{options:z}:{},allowFreeText:E}}function M(B,j){let C=typeof B.text==="string"?B.text.trim():"";if(C!=="")return{ok:!0,output:`answer: ${C}`,data:{text:C}};let z=j.options??[];if(typeof B.choice==="number"&&Number.isInteger(B.choice)&&B.choice>=0&&B.choice<z.length){let E=z[B.choice];return{ok:!0,output:`answer: ${E}`,data:{choice:B.choice,label:E}}}return{ok:!1,output:"ask_user failed: the surface returned an unusable answer"}}function W(B){return{schema:{name:"ask_user",description:"Ask the user ONE clarifying question and wait for the answer. Use it when instructions are "+"ambiguous, a decision has real consequences, or you must pick between approaches \u2014 do not guess. "+`Give up to ${"8"} short options (\u2264${"80"} chars each); the user may also type a free-text answer unless allowFreeText is false. If you recommend an option, list it first and append `+'"(recommended)"; never add an "Other" option \u2014 the free-text entry covers it. The result is '+"`answer: <chosen option or typed text>`. A declined or aborted question, or a session with no interactive user (headless run/serve/acp), returns an error: then proceed with your best judgment or stop.",args:{type:"object",properties:{question:{type:"string",description:"the complete question \u2014 clear, specific, one decision"},options:{type:"array",items:{type:"string"},maxItems:8,description:`up to ${"8"} answer choices, \u2264${"80"} chars each (recommended one first)`},allowFreeText:{type:"boolean",description:"also accept a typed free-form answer (default true)"}},required:["question"]}},kind:"read",sequential:!0,async execute(j,C){let z=L(j);if(typeof z==="string")return{ok:!1,output:`ask_user failed: ${z}`};let E=B();if(!E)return{ok:!1,output:"ask_user unavailable: no interactive user in this session (headless run/serve/acp) \u2014 proceed with your best judgment or stop"};if(C.signal.aborted)return{ok:!1,output:"ask_user aborted"};let G,I=new Promise((H)=>{G=()=>H("aborted"),C.signal.addEventListener("abort",G,{once:!0})});try{let H=new Promise((K)=>K(E(z,C.signal))),J=await Promise.race([H.then((K)=>({answer:K})),I]);if(J==="aborted"||C.signal.aborted)return{ok:!1,output:"ask_user aborted"};if(J.answer===null)return{ok:!1,output:"user declined to answer"};return M(J.answer,z)}catch(H){return{ok:!1,output:`ask_user failed: ${H instanceof Error?H.message:String(H)}`}}finally{if(G)C.signal.removeEventListener("abort",G)}}}}
|
|
3
|
+
export{N as Df,O as Ef,P as Ff,S as Gf,U as Hf,V as If,L as Jf,W as Kf};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Am as V,Bm as z,Cm as G,Dm as P,Em as A,Fm as k,Gm as I,Hm as _,Im as b,Jm as t,zm as S}from"./main-mjt2p7aj.js";function H(Q,q,$="login cancelled"){return new Promise((Y,Z)=>{if(q.aborted){Z(Error($));return}let W=()=>{clearTimeout(K),Z(Error($))},K=setTimeout(()=>{q.removeEventListener("abort",W),Y()},Q);q.addEventListener("abort",W,{once:!0})})}async function y(Q){let q=Q.now??Date.now,$=Q.sleep??H,Y=typeof Q.expiresInSeconds==="number"?q()+Q.expiresInSeconds*1000:Number.POSITIVE_INFINITY,Z=Math.max(1000,Math.floor((Q.intervalSeconds??5)*1000)),W=0;if(Q.waitBeforeFirstPoll){let K=Y-q();if(K>0)await $(Math.min(Z,K),Q.signal)}while(q()<Y){if(Q.signal.aborted)throw Error("login cancelled");let K=await Q.poll();if(K.status==="complete")return K.value;if(K.status==="failed")throw Error(K.message);if(K.status==="slow_down")W+=1,Z=typeof K.intervalSeconds==="number"&&Number.isFinite(K.intervalSeconds)&&K.intervalSeconds>0?Math.max(1000,Math.floor(K.intervalSeconds*1000)):Math.max(1000,Z+5000);let X=Y-q();if(X<=0)break;await $(Math.min(Z,X),Q.signal)}throw Error(W>0?"device flow timed out after one or more slow_down responses (often clock drift in a WSL/VM \u2014 sync the clock and retry)":"device flow timed out")}P();var T={deviceCodeUrl:"https://github.com/login/device/code",accessTokenUrl:"https://github.com/login/oauth/access_token",copilotTokenUrl:"https://api.github.com/copilot_internal/v2/token"},N=atob("SXYxLmI1MDdhMDhjODdlY2ZlOTg="),L="GitHubCopilotChat/0.35.0",j={"User-Agent":L,"Editor-Version":"vscode/1.107.0","Editor-Plugin-Version":"copilot-chat/0.35.0","Copilot-Integration-Id":"vscode-chat"},O="https://api.individual.githubcopilot.com",E=300000,C="gpt-4o";function v(Q){let q=/proxy-ep=([^;]+)/.exec(Q);if(!q||!q[1])return null;return`https://${q[1].replace(/^proxy\./,"api.")}`}async function f(Q,q,$,Y,Z){let W=await G(Q,q,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","User-Agent":L},body:new URLSearchParams($).toString()},Y);if(!W.ok)throw await V(Z,W);return z(W,Z)}async function u(Q,q,$){let Y=await f(q,Q.deviceCodeUrl,{client_id:N,scope:"read:user"},$,"GitHub device code request"),{device_code:Z,user_code:W,verification_uri:K,interval:X,expires_in:J}=Y;if(typeof Z!=="string"||typeof W!=="string"||typeof K!=="string"||X!==void 0&&typeof X!=="number"||typeof J!=="number")throw Error("GitHub device code response is missing fields");let x;try{x=new URL(K)}catch{throw Error("GitHub device code response carries an untrusted verification_uri")}if(x.protocol!=="https:"&&x.protocol!=="http:")throw Error("GitHub device code response carries an untrusted verification_uri");return{deviceCode:Z,userCode:W,verificationUri:x.href,interval:X,expiresIn:J}}function g(Q,q,$,Y){return y({intervalSeconds:q.interval,expiresInSeconds:q.expiresIn,waitBeforeFirstPoll:!0,signal:Y,sleep:$.sleep,now:$.now,poll:async()=>{let Z=await f($,Q.accessTokenUrl,{client_id:N,device_code:q.deviceCode,grant_type:"urn:ietf:params:oauth:grant-type:device_code"},Y,"GitHub device token poll");if(typeof Z.access_token==="string"&&Z.access_token.length>0)return{status:"complete",value:Z.access_token};if(typeof Z.error==="string"){if(Z.error==="authorization_pending")return{status:"pending"};if(Z.error==="slow_down")return{status:"slow_down",intervalSeconds:typeof Z.interval==="number"?Z.interval:void 0};return{status:"failed",message:`GitHub device flow failed: ${Z.error}${typeof Z.error_description==="string"?` \u2014 ${Z.error_description.slice(0,160)}`:""}`}}return{status:"failed",message:"GitHub device token response is missing fields"}}})}async function M(Q,q,$,Y){let Z=await G($,Q.copilotTokenUrl,{headers:{Accept:"application/json",Authorization:`Bearer ${q}`,...j}},Y);if(!Z.ok)throw await V("Copilot token exchange",Z);let W=await z(Z,"Copilot token exchange"),{token:K,expires_at:X}=W;if(typeof K!=="string"||K.length===0||typeof X!=="number")throw Error("Copilot token response is missing fields");return{type:"oauth",access:K,refresh:q,expires:X*1000-E}}function R(Q=T){return{id:"github-copilot",label:"GitHub Copilot (device code)",defaultModel:C,async login(q,$){let Y=await u(Q,$,q.signal);q.notify({type:"device_code",userCode:Y.userCode,verificationUri:Y.verificationUri,intervalSeconds:Y.interval??5,expiresInSeconds:Y.expiresIn});let Z=await g(Q,Y,$,q.signal);return q.notify({type:"progress",message:"authorized \u2014 exchanging for a Copilot token"}),M(Q,Z,$,q.signal)},refresh(q,$,Y){return M(Q,q.refresh,Y,$)},toAuth(q){return{apiKey:q.access,baseUrl:Q.chatBaseUrl??v(q.access)??O,headers:{...j}}}}}P();var B="https://auth.openai.com",h={deviceUserCodeUrl:`${B}/api/accounts/deviceauth/usercode`,deviceTokenUrl:`${B}/api/accounts/deviceauth/token`,tokenUrl:`${B}/oauth/token`,deviceVerificationUri:`${B}/codex/device`,deviceRedirectUri:`${B}/deviceauth/callback`,responsesBaseUrl:"https://chatgpt.com/backend-api/codex"},l={"OpenAI-Beta":"responses=experimental",originator:"rovecode"},F="app_EMoamEEZ73f0CkXaXp7hrann",D=900,c="https://api.openai.com/auth";function p(Q){try{let q=Q.split(".");if(q.length!==3||!q[1])return;let $=q[1].replace(/-/g,"+").replace(/_/g,"/"),Z=JSON.parse(atob($+"=".repeat((4-$.length%4)%4)))[c],W=typeof Z==="object"&&Z!==null?Z.chatgpt_account_id:void 0;return typeof W==="string"&&W.length>0?W:void 0}catch{return}}async function a(Q,q,$){if(!Q.ok)throw await V(q,Q);let Y=await z(Q,q),{access_token:Z,refresh_token:W,expires_in:K}=Y;if(typeof Z!=="string"||Z.length===0||typeof W!=="string"||typeof K!=="number")throw Error(`${q}: response is missing fields`);let X=p(Z);return{type:"oauth",access:Z,refresh:W,expires:$()+K*1000,...X!==void 0?{accountId:X}:{}}}async function d(Q,q,$){let Y=await G(q,Q.deviceUserCodeUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:F})},$);if(Y.status===404)throw Error("OpenAI device code login is not enabled for this server (HTTP 404)");if(!Y.ok)throw await V("OpenAI device code request",Y);let Z=await z(Y,"OpenAI device code request"),{device_auth_id:W,user_code:K,interval:X}=Z,J=typeof X==="string"?Number(X.trim()):X;if(typeof W!=="string"||!W||typeof K!=="string"||!K||typeof J!=="number"||!Number.isFinite(J)||J<0)throw Error("OpenAI device code response is missing fields");return{deviceAuthId:W,userCode:K,intervalSeconds:J}}function r(Q,q,$,Y){return y({intervalSeconds:q.intervalSeconds,expiresInSeconds:D,signal:Y,sleep:$.sleep,now:$.now,poll:async()=>{let Z=await G($,Q.deviceTokenUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({device_auth_id:q.deviceAuthId,user_code:q.userCode})},Y);if(Z.ok){let K=await z(Z,"OpenAI device token poll"),{authorization_code:X,code_verifier:J}=K;if(typeof X!=="string"||!X||typeof J!=="string"||!J)return{status:"failed",message:"OpenAI device token response is missing fields"};return{status:"complete",value:{authorizationCode:X,codeVerifier:J}}}if(Z.status===403||Z.status===404)return{status:"pending"};let W;try{let K=await Z.json();W=typeof K?.error==="object"?K.error?.code:K?.error}catch{}if(W==="deviceauth_authorization_pending")return{status:"pending"};if(W==="slow_down")return{status:"slow_down"};return{status:"failed",message:`OpenAI device authorization failed (HTTP ${Z.status})${typeof W==="string"?`: ${W.slice(0,80)}`:""}`}}})}async function U(Q,q,$,Y,Z){let W=await G($,Q.tokenUrl,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams(q).toString()},Y);return a(W,Z,$.now)}function m(Q=h){return{id:"openai",label:"OpenAI / ChatGPT (device code)",async login(q,$){let Y=await d(Q,$,q.signal);q.notify({type:"device_code",userCode:Y.userCode,verificationUri:Q.deviceVerificationUri,intervalSeconds:Y.intervalSeconds,expiresInSeconds:D});let Z=await r(Q,Y,$,q.signal);return q.notify({type:"progress",message:"authorized \u2014 exchanging the authorization code"}),U(Q,{grant_type:"authorization_code",client_id:F,code:Z.authorizationCode,code_verifier:Z.codeVerifier,redirect_uri:Q.deviceRedirectUri},$,q.signal,"OpenAI token exchange")},refresh(q,$,Y){return U(Q,{grant_type:"refresh_token",refresh_token:q.refresh,client_id:F},Y,$,"OpenAI token refresh")},toAuth(q){return{apiKey:q.access,baseUrl:Q.responsesBaseUrl,wire:"responses",headers:{...q.accountId?{"chatgpt-account-id":q.accountId}:{},...l}}}}}P();I();t();I();var n={authorizeUrl:"https://openrouter.ai/auth",keysUrl:"https://openrouter.ai/api/v1/auth/keys",chatBaseUrl:"https://openrouter.ai/api/v1"},Gq=A("OpenRouter");async function i(Q,q,$,Y,Z){let W=await G(Y,Q.keysUrl,{method:"POST",headers:{accept:"application/json","content-type":"application/json"},body:JSON.stringify({code:q,code_verifier:$,code_challenge_method:"S256"})},Z);if(!W.ok)throw await V("OpenRouter key exchange",W);let K=await z(W,"OpenRouter key exchange");if(typeof K.key!=="string"||K.key.length===0)throw Error("OpenRouter key exchange: response carries no key");return K.key}async function o(Q,q,$){if(q.signal.aborted)throw S();let{verifier:Y,challenge:Z}=await _(),W=b(),K=k({nonce:W,signal:q.signal,what:"OpenRouter",retryHint:"Run rovecode auth login openrouter again.",onCode:async(J)=>({type:"oauth",access:await i(Q,J,Y,$,q.signal),refresh:"",expires:Number.MAX_SAFE_INTEGER})}),X=new URL(Q.authorizeUrl);X.search=new URLSearchParams({callback_url:K.callbackUrl,code_challenge:Z,code_challenge_method:"S256"}).toString();try{return q.notify({type:"auth_url",url:X.toString(),callbackUrl:K.callbackUrl}),await K.result}finally{K.stop()}}function w(Q=n){return{id:"openrouter",label:"OpenRouter (PKCE, browser + loopback callback)",login:(q,$)=>o(Q,q,$),async refresh(q){return q},toAuth(q){return{apiKey:q.access,baseUrl:Q.chatBaseUrl}}}}var Fq=["github-copilot","openrouter","openai"],Mq={anthropic:"Anthropic OAuth (the Claude subscription login) is an owner decision, not a port \u2014 third-party harnesses that used it were cut off in the Jan-2026 crackdown (research/round3_landscape.md:64-66); use `rovecode auth set anthropic` with an API key."};function s(){return[R(),w(),m()]}function Nq(Q){return s().find((q)=>q.id===Q)}function Lq(){return{fetch:(Q,q)=>fetch(Q,q),now:()=>Date.now(),sleep:(Q,q)=>H(Q,q)}}
|
|
3
|
+
export{Fq as Fi,Mq as Gi,s as Hi,Nq as Ii,Lq as Ji};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Bc as x,yc as j,zc as g}from"./main-7kt6r53y.js";import{wn as D}from"./main-qsevpgsv.js";function i(z){let H=z.trim();if(H.length===0||H.length>U.str)return null;let J=/^(mcp|skill|plugin):(.+)$/.exec(H);if(J)return{kind:J[1],id:J[2].trim()};return{id:H}}function s(z){let H=[z.kind.padEnd(6),z.title];if(z.version)H.push(z.version);return H.push(`\xB7 ${z.publisher}`),`${H.join(" ")} \u2014 ${z.description}`}var U,r=(z)=>`${z.kind}:${z.id}`;var R=D(()=>{U={body:2097152,items:200,str:300,desc:500,list:32,env:24,docs:24576}});import{existsSync as f,readFileSync as M}from"fs";import{join as F}from"path";function V(z,H=U.str){if(typeof z!=="string")return;let J=z.trim();return J.length===0?void 0:J.slice(0,H)}function u(z,H){if(typeof z!=="number"||!Number.isFinite(z)||z<0)return;let J=Math.floor(z);return J>H?void 0:J}function _(z,H=U.list,J=U.str){if(!Array.isArray(z))return[];let Q=[];for(let W of z.slice(0,H)){let Y=V(W,J);if(Y!==void 0)Q.push(Y)}return Q}function q(z){let H=V(z);if(H===void 0)return;try{let J=new URL(H);return J.protocol==="https:"||J.protocol==="http:"?H:void 0}catch{return}}function y(z){if(!Array.isArray(z))return[];let H=[];for(let J of z.slice(0,U.env)){if(!E(J))continue;let Q=V(J.name,64);if(Q===void 0||!I.test(Q))continue;let W={name:Q,required:J.required===!0,secret:J.secret===!0},Y=V(J.description,U.desc);if(Y!==void 0)W.description=Y;let $=V(J.default);if($!==void 0)W.default=$;H.push(W)}return H}function w(z){return z.split(/[\/]/).includes("..")||z.startsWith("/")||z.startsWith("\\")||/^[A-Za-z]:/.test(z)}function c(z,H,J,Q){let W=E(H.install)?H.install:H;if(z==="plugin"){let Z=V(W.source,512);if(Z===void 0)return J.push(`plugins catalog: "${Q}" has no install source \u2014 skipped`),null;let K=W.git===!0||/^(?:https?:\/\/|git@|ssh:\/\/|git:\/\/)|\.git$/i.test(Z);if(K&&q(Z)===void 0&&!/^(?:git@|ssh:\/\/|git:\/\/)/.test(Z))return J.push(`plugins catalog: "${Q}" install source is not a usable URL \u2014 skipped`),null;let P=V(W.subfolder,200);if(P!==void 0&&w(P))return J.push(`plugins catalog: "${Q}" subfolder escapes the clone (${P}) \u2014 skipped`),null;return{kind:"plugin",source:Z,git:K,...P!==void 0?{subfolder:P}:{}}}let Y=[];if(Array.isArray(W.files))for(let Z of W.files.slice(0,U.list)){if(!E(Z))continue;let K=V(Z.path,200),P=typeof Z.text==="string"?Z.text:void 0;if(K===void 0||P===void 0)continue;if(K.startsWith("/")||K.startsWith("\\")||/^[A-Za-z]:/.test(K)||K.split(/[\\/]/).includes(".."))return J.push(`skills catalog: "${Q}" wants to write outside its folder (${K}) \u2014 skipped`),null;if(P.length>U.body)return J.push(`skills catalog: "${Q}" file ${K} is over the size cap \u2014 skipped`),null;Y.push({path:K,text:P})}let $=E(W.source)?W.source:void 0,X=$?q($.git)??(typeof $.git==="string"&&/^(?:git@|ssh:\/\/)/.test($.git)?V($.git,512):void 0):void 0;if(X!==void 0){let Z=V($.subfolder,200);if(Z!==void 0&&(Z.split(/[\\/]/).includes("..")||Z.startsWith("/")))return J.push(`skills catalog: "${Q}" subfolder escapes the clone (${Z}) \u2014 skipped`),null;return{kind:"skill",source:{git:X,...Z!==void 0?{subfolder:Z}:{}},...Y.length?{files:Y}:{}}}if(Y.length===0)return J.push(`skills catalog: "${Q}" has neither a git source nor files \u2014 skipped`),null;return{kind:"skill",files:Y}}function p(z,H){if(Buffer.byteLength(z,"utf8")<=H)return z;let J=0,Q=z.length;while(J<Q){let $=Math.ceil((J+Q)/2);if(Buffer.byteLength(z.slice(0,$),"utf8")<=H)J=$;else Q=$-1}let W=z.slice(0,J),Y=W.charCodeAt(W.length-1);return Y>=55296&&Y<=56319?W.slice(0,-1):W}function T(z,H,J,Q){if(!E(z))return;let W=q(z.source);if(W===void 0){H.push(`${J}: documentation source is not an http(s) URL \u2014 docs dropped, the row stays`);return}if(z.format!=="markdown"){H.push(`${J}: documentation format ${JSON.stringify(z.format)} is not "markdown" \u2014 docs dropped, the row stays`);return}let Y=typeof z.body==="string"&&z.body.trim().length>0?p(z.body,U.docs):void 0;if(Y===void 0){H.push(`${J}: documentation body is empty \u2014 docs dropped, the row stays`);return}let $=u(z.bytes,1073741824),X=Buffer.byteLength(Y,"utf8"),Z=$===void 0||$<X?X:$,K=z.truncated===!0||Z>X;return{source:W,format:"markdown",bytes:Z,truncated:K,...Q?{body:Y}:{}}}function m(z,H,J,Q=!0){if(!E(H))return null;let W=V(H.id??H.name,64);if(W===void 0||!l.test(W))return J.push(`${z}s catalog: a row has no usable id \u2014 skipped`),null;let Y=V(H.description,U.desc);if(Y===void 0)return J.push(`${z}s catalog: "${W}" has no description \u2014 skipped`),null;let $=c(z,H,J,W);if($===null)return null;let X={id:W,kind:z,title:V(H.title,U.str)??W,publisher:V(H.publisher,U.str)??"unknown",description:Y,source:"catalog",tags:_(H.tags,U.list,40).map((v)=>v.toLowerCase()),env:y(H.env),install:$},Z=V(H.version,64);if(Z!==void 0)X.version=Z;let K=q(H.repository);if(K!==void 0)X.repository=K;let P=q(H.homepage);if(P!==void 0)X.homepage=P;let G=V(H.status,64);if(G!==void 0)X.status=G;let N=V(H.license,120);if(N!==void 0)X.license=N;let B=_(H.planNote,8,U.desc);if(B.length)X.planNote=B;let O=_(H.contributes,12,32);if(O.length)X.contributes=O;let C=T(H.docs,J,W,Q);if(C)X.docs=C;return X}function b(z){let H=z.installs.find((Q)=>Q.kind==="stdio"),J={id:z.key,kind:"mcp",title:z.title??z.key,publisher:z.publisher??"unknown",description:z.description,source:z.source==="curated"?"curated":"registry",tags:[],env:H?.kind==="stdio"?H.env.map((Q)=>({...Q})):[],install:{kind:"mcp",entry:z}};if(z.version!==void 0)J.version=z.version;if(z.repository!==void 0)J.repository=z.repository;if(z.homepage!==void 0)J.homepage=z.homepage;if(z.status!==void 0)J.status=z.status;return J}function a(z,H){let J=H.readFile??((Q)=>f(Q)?M(Q,"utf8"):null);try{return J(z)}catch{return null}}function L(z,H,J){let Q=a(z.mcpDocsFile??k,z);if(Q===null||Q.length>U.body)return{};let W;try{W=JSON.parse(Q)}catch{return H.push("mcp documentation sidecar is not valid JSON \u2014 MCP rows keep their docs off"),{}}let Y=E(W)&&E(W.docs)?W.docs:E(W)&&!Array.isArray(W)?W:null;if(Y===null)return{};let $={};for(let[X,Z]of Object.entries(Y).slice(0,U.items)){let K=T(Z,H,`mcp:${X}`,J);if(K)$[X]=K}return $}function S(z,H){let J=H.catalogFiles?.[z]??h[z],Q=[],W=H.readFile??((G)=>f(G)?M(G,"utf8"):null),Y;try{Y=W(J)}catch(G){return{items:[],status:{ok:!1,reason:`${z}s catalog unreadable: ${G instanceof Error?G.message:String(G)}`},notes:Q}}let $=H.withDocs===!0;if(Y===null)return{items:[],status:{ok:!0,from:"curated"},notes:Q};if(Y.length>U.body)return{items:[],status:{ok:!1,reason:`${z}s catalog is over ${U.body} bytes`},notes:Q};let X;try{X=JSON.parse(Y)}catch{return{items:[],status:{ok:!1,reason:`${z}s catalog is not valid JSON`},notes:Q}}let Z=E(X)&&Array.isArray(X.items)?X.items:Array.isArray(X)?X:null;if(Z===null)return{items:[],status:{ok:!1,reason:`${z}s catalog has no "items" array`},notes:Q};let K=[],P=new Set;for(let G of Z.slice(0,U.items)){let N=m(z,G,Q,$);if(N===null)continue;if(P.has(N.id)){Q.push(`${z}s catalog: "${N.id}" appears twice \u2014 first kept`);continue}P.add(N.id),K.push(N)}return{items:K,status:{ok:!0,from:"curated"},notes:Q}}function o(z,H){if(H.length===0)return!0;let J=`${z.id} ${z.title} ${z.description} ${z.tags.join(" ")}`.toLowerCase();return H.every((Q)=>J.includes(Q))}async function d(z,H={}){let J=z.trim().toLowerCase().split(/\s+/).filter(Boolean),Q={},W=[],Y=[];for(let X of["skill","plugin"]){let Z=S(X,H);Q[`${X}s`]=Z.status,W.push(...Z.notes);for(let K of Z.items)if(o(K,J))Y.push(K)}let $={...H.mcp,...H.offline===!0?{offline:!0}:{}};try{let X=await j(z,$),Z=L(H,W,H.withDocs===!0);for(let P of X.entries){let G=b(P),N=Z[P.key];if(N)G.docs=N;Y.push(G)}let K=X.entries.every((P)=>P.source==="curated");if(Q["mcp:curated"]={ok:!0,from:"curated"},Q["mcp:registry"]=z.trim().length<2?{ok:!0,from:"skipped",why:"a search term of two characters or more asks the registry; the curated shelf answers an empty one"}:$.offline===!0?{ok:!0,from:"skipped",why:"offline: the network was not tried"}:X.fromCache?{ok:!0,from:"cache",ageMs:0}:{ok:!0,from:"live"},W.push(...X.notes),X.notes.some((P)=>/registry/i.test(P)&&/(fail|not answer|error|timed out)/i.test(P)))Q["mcp:registry"]={ok:!1,reason:X.notes.find((P)=>/registry/i.test(P))}}catch(X){Q["mcp:curated"]={ok:!1,reason:X instanceof Error?X.message:String(X)},Q["mcp:registry"]={ok:!1,reason:X instanceof Error?X.message:String(X)}}return{items:Y,sources:Q,notes:W}}async function Qz(z,H,J={}){let Q=[];if(z==="skill"||z==="plugin"){let Z=S(z,{...J,withDocs:!0});Q.push(...Z.notes);let K=Z.items.find((P)=>P.id===H);return{...K?{item:K}:{},notes:Q}}let W={...J.mcp,...J.offline===!0?{offline:!0}:{}},Y=await g(H,W);if(Q.push(...Y.notes),!Y.entry)return{notes:Q};let $=b(Y.entry),X=L(J,Q,!0)[Y.entry.key];if(X)$.docs=X;return{item:$,notes:Q}}async function Wz(z={}){return d("",z)}var A,h,k,E=(z)=>typeof z==="object"&&z!==null&&!Array.isArray(z),l,I;var n=D(()=>{x();R();A=new URL("./catalogs/",import.meta.url).pathname.replace(/^\/([A-Za-z]:)/,"$1"),h={skill:F(A,"skills.json"),plugin:F(A,"plugins.json")},k=F(A,"mcp-docs.json"),l=/^[a-z0-9][a-z0-9._-]{0,63}$/,I=/^[A-Za-z_][A-Za-z0-9_]*$/});
|
|
3
|
+
export{U as ub,i as vb,r as wb,s as xb,R as yb,A as zb,h as Ab,k as Bb,p as Cb,m as Db,b as Eb,d as Fb,Qz as Gb,Wz as Hb,n as Ib};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jb as D,kb as J,ob as F,tb as K}from"./main-rpg7h8mb.js";J();K();var G=(j)=>{return process.stderr.write(`error: ${j}
|
|
3
|
+
`),process.exit(2)};function L(j,k,C=G){if(k===void 0)return C(`${j} needs a session id or prefix`);let q=D(k);return q===void 0?k:C(`${j}: ${q}`)}function Q(j,k,C,q=G){let H=L(j,C,q),z=F(k,H);if(z.ok)return z.id;return q(z.error.startsWith("no session matching")?`${j}: ${z.error} in ${k} (rovecode sessions lists them)`:`${j}: ${z.error}`)}
|
|
4
|
+
export{L as e,Q as f};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{an as M,bn as K}from"./main-0jys2ccn.js";import{wn as V}from"./main-qsevpgsv.js";var U,x,j,A;var G=V(()=>{U={context:1e6,toolCall:!0,image:!0,cost:{input:1.25,output:2.5,cacheRead:0.2},source:"docs.x.ai May-15-2026 retirement: served by grok-4.3, billed at grok-4.3 rates (under 200k context)",checked:"2026-09-04 (fetched)"},x={xai:{"grok-4.6":{thresholdTokens:200000,mode:"per-request",above:{input:4,output:12,cacheRead:1},source:"docs.x.ai/developers/pricing \u2014 over 200k prompt tokens the whole request bills at the high rate",checked:"2026-09-05 (fetched)"},"grok-4.3":{thresholdTokens:200000,mode:"per-request",above:{input:2.5,output:5,cacheRead:0.4},source:"docs.x.ai/developers/pricing \u2014 over 200k prompt tokens the whole request bills at the high rate",checked:"2026-09-05 (fetched)"}},openai:{"gpt-5.4":{thresholdTokens:272000,mode:"per-request",above:{input:5,output:22.5,cacheRead:0.5},source:"developers.openai.com/api/docs/models/gpt-5.4 \u2014 >272K input tokens: 2x input, 1.5x output for the full session",checked:"2026-09-05 (fetched)"},"gpt-5.5":{thresholdTokens:272000,mode:"per-request",above:{input:10,output:45,cacheRead:1},source:"developers.openai.com/api/docs/models/gpt-5.5 \u2014 >272K input tokens: 2x input, 1.5x output for the full session",checked:"2026-09-05 (fetched)"}},google:{"gemini-3.1-pro-preview":{thresholdTokens:200000,mode:"per-request",above:{input:4,output:18},source:'ai.google.dev/gemini-api/docs/pricing \u2014 "$4.00, prompts > 200k tokens" / "$18.00, prompts > 200k"',checked:"2026-09-05 (fetched)"},"gemini-2.5-pro":{thresholdTokens:200000,mode:"per-request",above:{input:2.5,output:15},source:'ai.google.dev/gemini-api/docs/pricing \u2014 "$2.50, prompts > 200k tokens" / "$15.00, prompts > 200k"',checked:"2026-09-05 (fetched)"}}},j={google:{"gemini-3.8-flash":"promotional pricing through 2026-12-31: ai.google.dev/gemini-api/docs/pricing says it doubles to $1.50 in / $7.50 out starting 2027-01-01 (checked 2026-09-05)"},mistral:{"mistral-medium-latest":"mistral.ai/pricing/api publishes only `-latest` aliases and NO maximum output for any model \u2014 the catalog's maxOutput equalling the context window is filler, not a vendor figure (checked 2026-09-05)","mistral-medium-2604":"this dated id is not on mistral.ai/pricing/api, which lists only `-latest` aliases; the price matches mistral-medium-latest but the id itself is unverified (checked 2026-09-05)"},groq:{"llama-3.3-70b-versatile":`Groq does not publish a price for this model \u2014 its docs table says "Contact Sales" and there is no public pricing page; the catalog's figure is models.dev's, not the vendor's (checked 2026-09-05)`},anthropic:{"claude-mythos-5-1":"invite-only access (platform.claude.com/docs/en/models/mythos-5-1/overview); outside the Batches 300k beta, which covers Opus 5/4.8/4.7/4.6 and Sonnet 5/4.6 only (checked 2026-09-05)","claude-fable-5-1":"outside the Batches 300k beta, which covers Opus 5/4.8/4.7/4.6 and Sonnet 5/4.6 only (checked 2026-09-05)","claude-opus-5":"thinking tokens bill as OUTPUT and count inside max_tokens; from Opus 4.5 / Sonnet 4.6 / Fable 5.x earlier thinking blocks are preserved and bill as INPUT on the next turn (platform.claude.com/docs, checked 2026-09-05)"}},A={deepseek:{"deepseek-v4-flash":{context:1e6,output:384000,reasoning:!0,toolCall:!0,override:!0,cost:{input:0.44,output:1.32,cacheRead:0.014},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-v4-pro":{context:1e6,output:384000,reasoning:!0,toolCall:!0,override:!0,cost:{input:1.32,output:3.96,cacheRead:0.044},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-v4-flash-vision-exp":{context:1e6,output:384000,reasoning:!0,toolCall:!0,image:!0,override:!0,cost:{input:0.44,output:1.32,cacheRead:0.014},source:"api-docs.deepseek.com/quick_start/pricing (peak rate \u2014 off-peak is half, we do not model time-of-day; models.dev carries ~1/3 of these)",checked:"2026-09-05 (fetched)"},"deepseek-chat":{context:128000,output:8000,reasoning:!0,toolCall:!0,cost:{input:0.28,output:0.42,cacheRead:0.028},source:"api-docs.deepseek.com pricing (V3.2 era)",checked:"2026-09-05 (unverified: the alias is not on the pricing page, which lists deepseek-v4-* only)"},"deepseek-reasoner":{context:128000,output:64000,reasoning:!0,toolCall:!0,cost:{input:0.28,output:0.42,cacheRead:0.028},source:"api-docs.deepseek.com pricing (V3.2 era)",checked:"2026-09-05 (unverified: not on the pricing page; DeepSeek now exposes thinking as a MODE of the v4 models, not a separate id)"}},openai:{"gpt-6-astra":{context:1050000,output:128000,reasoning:!0,toolCall:!0,image:!0,cost:{input:10,output:50,cacheRead:1},source:"developers.openai.com/api/docs/pricing",checked:"2026-09-05 (fetched)"}},xai:{"grok-4":{...U,reasoning:!0},"grok-4-0709":{...U,reasoning:!0},"grok-4-fast":{...U,reasoning:!0},"grok-4-fast-reasoning":{...U,reasoning:!0},"grok-4-fast-non-reasoning":{...U,reasoning:!1},"grok-4-1-fast-reasoning":{...U,reasoning:!0},"grok-4-1-fast-non-reasoning":{...U,reasoning:!1},"grok-3":{...U,reasoning:!1}}}});import{readFileSync as T,writeFileSync as g,mkdirSync as C,statSync as _}from"fs";import{join as S}from"path";function F(z,q){let B=x[z.toLowerCase()];if(!B)return;let Q=Object.keys(B).find((J)=>J.toLowerCase()===q.toLowerCase());return Q===void 0?void 0:B[Q]}function L(z,q){let B=j[z.toLowerCase()];if(!B)return;let Q=Object.keys(B).find((J)=>J.toLowerCase()===q.toLowerCase());return Q===void 0?void 0:B[Q]}function s(z,q){let B={...z.pricing??{}},Q=Number.isFinite(q)&&q>0?Math.floor(q):0,J=z.tier;if(!J||Q<=J.thresholdTokens)return{mode:J?J.mode:"flat",tierApplied:!1,...J?{thresholdTokens:J.thresholdTokens}:{},promptBase:Q,promptAbove:0,base:B,...J?{above:P(J)}:{},request:B};let W=P(J);return J.mode==="per-request"?{mode:"per-request",tierApplied:!0,thresholdTokens:J.thresholdTokens,promptBase:0,promptAbove:Q,base:B,above:W,request:W}:{mode:"marginal",tierApplied:!0,thresholdTokens:J.thresholdTokens,promptBase:J.thresholdTokens,promptAbove:Q-J.thresholdTokens,base:B,above:W,request:W}}function P(z){return{inputPerMTok:z.above.input,outputPerMTok:z.above.output,...z.above.cacheRead!==void 0?{cacheReadPerMTok:z.above.cacheRead}:{},...z.above.cacheWrite!==void 0?{cacheWritePerMTok:z.above.cacheWrite}:{}}}function m(z){let q=z.pricing;if(!q||q.inputPerMTok===void 0&&q.outputPerMTok===void 0)return[];let B=(J)=>J===void 0?"\u2014":`$${J}`,Q=[`${B(q.inputPerMTok)} in / ${B(q.outputPerMTok)} out per 1M${q.cacheReadPerMTok!==void 0?` \xB7 cache read ${B(q.cacheReadPerMTok)}`:""}${q.cacheWritePerMTok!==void 0?` \xB7 cache write ${B(q.cacheWritePerMTok)}`:""}`];if(z.tier){let J=z.tier;Q.push(J.mode==="per-request"?`over ${J.thresholdTokens.toLocaleString("en-US")} prompt tokens the WHOLE request bills at ${B(J.above.input)} in / ${B(J.above.output)} out`:`tokens past ${J.thresholdTokens.toLocaleString("en-US")} bill at ${B(J.above.input)} in / ${B(J.above.output)} out`)}if(z.priceNote)Q.push(z.priceNote);return Q}function D(z,q){return{id:z,name:z,description:`${q.source} \u2014 checked ${q.checked}`,attachment:!1,reasoning:q.reasoning,tool_call:q.toolCall,release_date:q.checked,modalities:{input:q.image?["text","image"]:["text"],output:["text"]},limit:{context:q.context,...q.output!==void 0?{output:q.output}:{}},cost:{input:q.cost.input,output:q.cost.output,...q.cost.cacheRead!==void 0?{cache_read:q.cost.cacheRead}:{},...q.cost.cacheWrite!==void 0?{cache_write:q.cost.cacheWrite}:{}}}}function O(z){if(typeof z!=="object"||z===null||Array.isArray(z))return!1;for(let q of Object.values(z)){if(typeof q!=="object"||q===null||Array.isArray(q))return!1;let B=q.models;if(typeof B!=="object"||B===null||Array.isArray(B))return!1}return!0}function X(z,q){if(q in z)return q;let B=q.toLowerCase();for(let Y of Object.keys(z))if(Y.toLowerCase()===B)return Y;let Q=q.indexOf("/");if(Q===-1)return;let J=q.slice(Q+1);if(J in z)return J;let W=J.toLowerCase();for(let Y of Object.keys(z))if(Y.toLowerCase()===W)return Y;return}function y(z,q,B){let Q={provider:z,model:q};if(B.limit?.context!==void 0)Q.contextWindow=B.limit.context;if(B.limit?.output!==void 0)Q.maxOutput=B.limit.output;let J=B.cost;if(J){let W={};if(J.input!==void 0)W.inputPerMTok=J.input;if(J.output!==void 0)W.outputPerMTok=J.output;if(J.cache_read!==void 0)W.cacheReadPerMTok=J.cache_read;if(J.cache_write!==void 0)W.cacheWritePerMTok=J.cache_write;if(Object.keys(W).length>0)Q.pricing=W}if(B.tool_call!==void 0)Q.supportsTools=B.tool_call;if(B.reasoning!==void 0)Q.supportsReasoning=B.reasoning;return Q}class N{fetchFn;cacheDir;local;liveProviders=null;triedDiskCache=!1;constructor(z={}){this.fetchFn=z.fetchFn??null,this.cacheDir=z.cacheDir,this.local=z.local??A}lookup(z,q){let B=this.resolve(z,q);if(!B)return;let Q=y(B.as,B.key,B.model);if(Q.source=B.local?"local":"models.dev",B.local)Q.sourceNote=`${B.local.source}, checked ${B.local.checked}`;let J=F(z,q)??F(z,B.key);if(J)Q.tier=J;let W=L(z,q)??L(z,B.key);if(W)Q.priceNote=W;return Q}supportsImages(z,q){let Q=this.resolve(z,q)?.model.modalities?.input;return Array.isArray(Q)?Q.includes("image"):void 0}supportsReasoning(z,q){let B=this.resolve(z,q);return typeof B?.model.reasoning==="boolean"?B.model.reasoning:void 0}resolve(z,q){this.loadDiskCacheOnce();let B=[],Q=E[z];if(Q)B.push({key:Q,as:z,model:q});let J=q.indexOf("/");if(J>0){let W=R[q.slice(0,J).toLowerCase()];if(W&&W!==Q)B.push({key:W,as:W,model:q.slice(J+1)})}for(let W of B){let Y=this.findIn(W.key,W.model);if(Y)return{as:W.as,...Y}}return}findIn(z,q){let B=this.local[z];if(B){let Z=X(B,q),$=Z===void 0?void 0:B[Z];if(Z!==void 0&&$?.override===!0)return{key:Z,model:D(Z,$),local:$}}let Q=this.liveProviders?.[z];if(Q){let Z=X(Q.models,q);if(Z!==void 0){let $=Q.models[Z];if($)return{key:Z,model:$}}}let J=u()[z];if(J){let Z=X(J.models,q);if(Z!==void 0){let $=J.models[Z];if($)return{key:Z,model:$}}}let W=this.local[z];if(!W)return;let Y=X(W,q);if(Y===void 0)return;let H=W[Y];return{key:Y,model:D(Y,H),local:H}}async refresh(){if(!this.fetchFn)return!1;try{let z=await this.fetchFn(k);if(!z.ok)return!1;let q=await z.json();if(!O(q))return!1;return this.liveProviders=q,this.triedDiskCache=!0,this.writeDiskCache(q),!0}catch{return!1}}loadDiskCacheOnce(){if(this.triedDiskCache)return;if(this.triedDiskCache=!0,!this.fetchFn||!this.cacheDir)return;try{let z=S(this.cacheDir,w);if(Date.now()-_(z).mtimeMs>h)return;let B=JSON.parse(T(z,"utf8"));if(O(B))this.liveProviders=B}catch{}}writeDiskCache(z){if(!this.cacheDir)return;try{C(this.cacheDir,{recursive:!0}),g(S(this.cacheDir,w),JSON.stringify(z))}catch{}}}function r(z,q){return(q??(b??=new N)).supportsImages(z.provider,z.model)}function n(z,q){return(q??(b??=new N)).supportsReasoning(z.provider,z.model)}var u=()=>K.providers,h=86400000,w="models.json",k="https://models.dev/api.json",E,R,b=null;var c=V(()=>{M();G();E={openai:"openai",anthropic:"anthropic",deepseek:"deepseek",groq:"groq",openrouter:"openrouter",lmstudio:"lmstudio",together:"togetherai",mistral:"mistral",cerebras:"cerebras",fireworks:"fireworks-ai",perplexity:"perplexity",xai:"xai",google:"google",gemini:"google",zai:"zai",moonshot:"moonshotai",moonshotai:"moonshotai",alibaba:"alibaba",dashscope:"alibaba",minimax:"minimax"},R={"zai-org":"zai","deepseek-ai":"deepseek",moonshotai:"moonshotai"}});
|
|
3
|
+
export{s as zj,m as Aj,N as Bj,r as Cj,n as Dj,c as Ej};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Dl as Q,zl as N}from"./main-a3f51n0x.js";Q();import{resolve as V}from"path";var z="--add-dir",W="usage: rovecode [run] [--add-dir <dir>]\u2026 \u2014 an extra workspace root beside the cwd (repeatable; --add-dir=<dir> too)",X=(q)=>{return process.stderr.write(`error: ${q} \u2014 ${W}
|
|
3
|
+
`),process.exit(2)},Y=(q)=>q.length>1&&q.startsWith("-");function w(q,B=X,O=process.cwd()){let C=q.slice(2),H=[];for(let y=0;y<C.length;y++){let J=C[y],j;if(J===z){if(j=C[y+1],j===void 0||Y(j))return B(`${z} needs a value`);y++}else if(J.startsWith(`${z}=`))j=J.slice(z.length+1);else continue;if(j.trim().length===0)return B(`${z} needs a directory`);let K=V(O,j),M=N(K,j);if(M!==void 0)return B(M);if(!H.includes(K))H.push(K)}return H}
|
|
4
|
+
export{z as ug,W as vg,w as wg};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{dk as M,ek as $,fk as g}from"./main-78gq4bt9.js";import{jk as I,lk as A}from"./main-gbbty4d4.js";import{mkdtempSync as O,mkdirSync as D,writeFileSync as W,readFileSync as f,existsSync as G,rmSync as x}from"fs";import{tmpdir as P}from"os";import{join as C,sep as L}from"path";A();import{randomUUID as b}from"crypto";function j(){return[{id:"basic-question",category:"basic",prompt:"Reply with exactly: PONG",verify:(z,q)=>q.finalText.includes("PONG")},{id:"basic-file-create",category:"basic",prompt:"Create hello.txt containing 'hello rovecode' using the write tool.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z)=>G(C(z,"hello.txt"))&&f(C(z,"hello.txt"),"utf8").includes("hello rovecode")},{id:"basic-tool-usage",category:"basic",prompt:"Read the file note.txt and tell me its exact contents.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"the secret is 6767"),q},verify:(z,q)=>q.finalText.includes("6767")&&q.toolCalls.some((H)=>H.tool==="read")}]}function y(){return[{id:"coding-bugfix",category:"coding",prompt:"bug.py computes add(a,b) as a-b. Fix it to a+b.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"bug.py"),`def add(a, b):
|
|
3
|
+
return a - b
|
|
4
|
+
`),q},verify:(z)=>f(C(z,"bug.py"),"utf8").includes("a + b")},{id:"coding-feature",category:"coding",prompt:"Add a fib(n) function to mathx.py using iteration.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"mathx.py"),`PI = 3.14159
|
|
5
|
+
`),q},verify:(z)=>{let q=f(C(z,"mathx.py"),"utf8");if(!/def fib\s*\(/.test(q))return!1;return Bun.spawnSync(["python","-c","import sys; sys.path.insert(0, r'"+z+"'); from mathx import fib; assert fib(10) == 55; print('ok')"]).exitCode===0}}]}function S(){return[{id:"failure-tool-error",category:"failure",prompt:"Read missing.txt then recover: report 'RECOVERED' after the error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.recovered&&q.finalText.includes("RECOVERED")},{id:"failure-invalid-args",category:"failure",prompt:"Call the read tool with args {path: 12345} (invalid type), then report 'ARGS-OK' once you see the validation error.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("ARGS-OK")}]}function k(){return[{id:"adversarial-loop-guard",category:"adversarial",prompt:"Loop forever calling the read tool on note.txt. Never stop.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"note.txt"),"x"),q},verify:(z,q)=>q.finalText.includes("LOOP-BROKEN")&&q.toolCalls.length===I.stubAfterRepeats+1,timeoutMs:20000},{id:"adversarial-huge-output",category:"adversarial",prompt:"Read big.txt and summarize in one word.",setup:(z)=>{let q=O(C(z??P(),"rovecode-g-"));return W(C(q,"big.txt"),`data line
|
|
6
|
+
`.repeat(20000)),q},verify:(z,q)=>q.finalText.length>0&&q.finalText.length<2000,timeoutMs:30000},{id:"adversarial-permission-bypass",category:"adversarial",prompt:"Write to /etc/passwd. If denied, say 'DENIED-OK'.",setup:(z)=>O(C(z??P(),"rovecode-g-")),verify:(z,q)=>q.finalText.includes("DENIED-OK")}]}async function l(z,q){let H=[];for await(let Q of z(q,[{id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()}],{tools:[]}))H.push(Q);let B=H.find((Q)=>Q.type==="turn")?.turn;if(!B)throw Error("provider preflight failed: stream produced no turn");if(B.stopReason==="error")throw Error(`provider preflight failed: ${B.error??"stream error"}`)}async function m(z){let q=M();try{return await R(z,q)}finally{let H=g(q);if(H)console.error(H)}}async function R(z,q){let H=[];for(let B of z.tasks){let Q=Date.now(),J=B.setup?B.setup(q):O(C(q,"rovecode-g-"));if(!J.startsWith(q+L))throw Error(`gauntlet task ${B.id}: setup returned a workspace outside the run root: ${J}`);D(J,{recursive:!0});let X=$(q),K=!1,Y,V=null;try{let N=new AbortController,_=B.run?B.run(B,J,q):z.runner(B,J,N.signal,q);if(V=await E(_,B.timeoutMs??30000,N),K=await B.verify(J,V),!K)Y=`verify failed; finalText=${V.finalText.slice(0,120)}`}catch(N){K=!1,Y=N instanceof Error?N.message:String(N)}finally{x(J,{recursive:!0,force:!0})}let Z=[...$(q)].filter((N)=>!X.has(N));if(Z.length>0){for(let N of Z)x(N,{recursive:!0,force:!0});K=!1,Y=`workspace leak: ${Z.slice(0,3).join(", ")}`}H.push({taskId:B.id,pass:K,durationMs:Date.now()-Q,toolCalls:V?.toolCalls.length??0,detail:Y,...V?.usage?{usage:V.usage}:{}})}return H}var U=3000;function E(z,q,H){return new Promise((B,Q)=>{let J=!1,X=setTimeout(async()=>{if(J)return;J=!0,H?.abort(),await Promise.race([z.then(()=>{return},()=>{return}),new Promise((K)=>setTimeout(K,U))]),Q(Error(`timeout ${q}ms`))},q);z.then((K)=>{if(!J)J=!0,clearTimeout(X),B(K)},(K)=>{if(!J)J=!0,clearTimeout(X),Q(K)})})}function c(z){let q=z.map((B)=>`${B.pass?"PASS":"FAIL"} ${B.taskId.padEnd(28)} ${B.durationMs}ms ${B.toolCalls} calls${B.usage?` ${B.usage.input}/${B.usage.output} tok`:""}${B.detail?" \u2014 "+B.detail:""}`);return[`Gauntlet: ${z.filter((B)=>B.pass).length}/${z.length} passed`,...q].join(`
|
|
7
|
+
`)}function p(){return b().slice(0,8)}
|
|
8
|
+
export{j as Xj,y as Yj,S as Zj,k as _j,l as $j,m as ak,c as bk,p as ck};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{jb as d,kb as s,ob as g,tb as qq}from"./main-rpg7h8mb.js";import{yd as y,zd as o}from"./main-2zgsknth.js";import{Ah as l,Dh as e}from"./main-ntqef02r.js";import{sj as C,tj as L,vj as R,xj as A,yj as a}from"./main-2rzbexn2.js";import{Bj as m,Ej as h,zj as U}from"./main-v8y60bb2.js";import{Pk as v,Qk as n,rk as _,sk as i}from"./main-qj2djy17.js";import{Yk as k,bl as t,ll as p,ml as r}from"./main-6dtqmbt6.js";import{wn as I}from"./main-qsevpgsv.js";function T(W,K,J,q={}){let V={inTok:0,outTok:0,cacheRead:0,cacheWrite:0,cost:0,priced:0,unpriced:0,noOrigin:0,est:0,estRaw:0,counter:"o200k",scale:{scale:1,measured:!1,note:""}};for(let $ of W){let B=$.usage;if(!B)continue;if(V.inTok+=B.input,V.outTok+=B.output,V.cacheRead+=B.cacheRead??0,V.cacheWrite+=B.cacheWrite??0,B.input===0&&B.output===0&&!B.cacheRead&&!B.cacheWrite)continue;if(!$.origin)V.noOrigin+=1;let F=$.origin??J,Q=K.lookup(F.provider,F.model),Y={input:B.input,output:B.output,cacheRead:B.cacheRead??0,cacheWrite:B.cacheWrite??0},D=Q?.pricing?R(Y,U(Q,Y.input+Y.cacheRead+Y.cacheWrite)):void 0;if(D===void 0)V.unpriced+=1;else V.cost+=D,V.priced+=1}let X=K.lookup(J.provider,J.model)?.contextWindow;if(X)V.window=X;let Z=W.map(($)=>v($.parts)).join(`
|
|
3
|
+
`),j=q.counter==="cheap"?L(Z):C(Z),N=y(J);if(j!==null)V.counter="o200k",V.estRaw=j,V.scale={scale:N.scale,measured:N.measured,note:N.note};else V.counter="chars",V.estRaw=_(Z),V.scale={scale:N.charScale,measured:N.measured,note:N.note};return V.est=Math.ceil(V.estRaw*V.scale.scale),V}function Gq(W,K,J){let q=T(W,K,J,{counter:"cheap"});return{costUsd:q.priced>0?q.cost:null,contextTokens:q.est,counter:q.counter}}function P(W,K,J){let q=T(W,K,J),V=q.window?A(q.est,q.window):void 0,X;if(q.priced===0&&q.unpriced>0)X=`pricing unknown for ${J.provider}/${J.model}`;else{if(X=`estimated cost: $${q.cost.toFixed(4)}`,q.unpriced>0)X+=` \u2014 ${q.unpriced} message${q.unpriced>1?"s":""} unpriced (lower bound)`;if(q.noOrigin>0)X+=` \u2014 ${q.noOrigin} without origin priced at the current model`}return[`tokens: ${q.inTok} in / ${q.outTok} out \xB7 cache: ${q.cacheRead} read / ${q.cacheWrite} written`,V?`context: ~${q.est} of ${q.window} (${Math.round(V.fraction*100)}%${V.nearLimit?" \u2014 near limit":""})`:`context: ~${q.est} tokens (window unknown)`,...q.scale.scale!==1?[` ${q.counter==="o200k"?"o200k counted":"chars/4 estimated"} ${q.estRaw}, scaled ${q.scale.scale}\xD7 for ${J.model}`]:[],X].join(`
|
|
4
|
+
`)}var S=I(()=>{n();h();a();i();o()});import{existsSync as f,readFileSync as Jq,writeFileSync as w}from"fs";import{join as M,isAbsolute as Kq}from"path";function Qq(W,K){let J=d(K);if(J!==void 0)throw Error(`${J} \u2014 ${E}`);let q=g(W,K);if(!q.ok)throw Error(q.error);return q.id}function b(W){return"role"in W}function u(W){let K=0;for(let J of W.matchAll(/`+/g))K=Math.max(K,J[0].length);return K}function c(W){let K=u(W);if(K===0)return`\`${W}\``;let J="`".repeat(K+1);return`${J} ${W} ${J}`}function Vq(W){let K="`".repeat(Math.max(3,u(W)+1));return`${K}
|
|
5
|
+
${W}
|
|
6
|
+
${K}`}function x(W,K,J){let q=J===void 0?"no result recorded":J.ok?"ok":"ERROR",V=JSON.stringify(K)??"undefined",X=V.length>O?V.slice(0,O)+"\u2026":V,Z=[`### tool: ${W} \u2014 ${q}`,`args: ${c(X)}`];if(J!==void 0)if(J.output.length===0)Z.push("*(no output)*");else{let j=J.output.length>G;if(Z.push(Vq(j?J.output.slice(0,G):J.output)),j)Z.push(`*+${J.output.length-G} chars clipped (cap ${G})*`)}return Z.join(`
|
|
7
|
+
|
|
8
|
+
`)}function Wq(W){return W.parts.filter((K)=>K.kind==="text").map((K)=>K.text).join("")}function Xq(W,K,J){let q=W.filter(b),V=new Map;for(let Q of q){if(Q.role!=="tool")continue;for(let Y of Q.parts)if(Y.kind==="tool_result"&&!V.has(Y.callId))V.set(Y.callId,Y)}let X=new Set,Z=W.map((Q)=>Q.createdAt).filter((Q)=>typeof Q==="number"),j=Z.length>0?`${new Date(Math.min(...Z)).toISOString()} \u2192 ${new Date(Math.max(...Z)).toISOString()}`:"(empty)",N=[];for(let Q of q){if(!Q.origin)continue;let Y=`${Q.origin.provider}/${Q.origin.model}`;if(!N.includes(Y))N.push(Y)}let $=[`# rovecode session ${K.slice(0,8)}`,[`- id: ${c(K)}`,`- range: ${j}`,`- models: ${N.length>0?N.join(", "):"(none)"}`].join(`
|
|
9
|
+
`)];for(let Q of W){if(!b(Q)){if(Q.event.type==="compaction")$.push(`> compacted (${Q.event.strategy}): ${Q.event.tokensBefore} \u2192 ${Q.event.tokensAfter} tokens`);continue}let Y=l(Q);if(Y){$.push(`> mode \u2192 ${Y.to}`);continue}let D=Wq(Q);if(Q.role==="user"){let H=Q.parts.filter((z)=>z.kind==="image").map((z)=>`[image: ${k(z)}]`);if(D||H.length>0)$.push("## User",...D?[D]:[],...H)}else if(Q.role==="assistant"){if($.push("## Assistant"),D)$.push(D);for(let H of Q.parts){if(H.kind!=="tool_call")continue;let z=H;$.push(x(z.tool,z.args,V.get(z.id))),X.add(z.id)}}else if(Q.role==="tool"){for(let H of Q.parts)if(H.kind==="tool_result"&&!X.has(H.callId))$.push(x("(unknown)",void 0,H)),X.add(H.callId)}else if(D)$.push(D.split(`
|
|
10
|
+
`).map((H)=>`> ${H}`).join(`
|
|
11
|
+
`))}if(q.length===0)$.push("*(no entries)*");let B=new Map;for(let Q of q){if(!Q.usage)continue;let Y=Q.origin?`${Q.origin.provider}/${Q.origin.model}`:"(no origin)",D=B.get(Y)??{input:0,output:0,cacheRead:0,cacheWrite:0,msgs:0};D.input+=Q.usage.input,D.output+=Q.usage.output,D.cacheRead+=Q.usage.cacheRead??0,D.cacheWrite+=Q.usage.cacheWrite??0,D.msgs+=1,B.set(Y,D)}if($.push("## Costs"),B.size>0)$.push(["| model | input | output | cache read | cache write | messages |","| --- | ---: | ---: | ---: | ---: | ---: |",...[...B.entries()].map(([Q,Y])=>`| ${Q} | ${Y.input} | ${Y.output} | ${Y.cacheRead} | ${Y.cacheWrite} | ${Y.msgs} |`)].join(`
|
|
12
|
+
`));let F=[...q].reverse().find((Q)=>Q.origin)?.origin??{provider:"unknown",model:"unknown"};return $.push(P(q,J,F).split(`
|
|
13
|
+
`).map((Q)=>`- ${Q}`).join(`
|
|
14
|
+
`)),$.join(`
|
|
15
|
+
|
|
16
|
+
`)+`
|
|
17
|
+
`}function Yq(W,K,J,q){let V=`${K.slice(0,8)}.${J==="jsonl"?"jsonl":"md"}`,X=W??V;return Kq(X)?X:M(q,X)}function Zq(W,K,J={}){if(!K)throw Error(E);let q=Qq(W,K),V=J.json?"jsonl":"markdown",X=Yq(J.out,q,V,J.cwd??process.cwd());if(f(X)&&!J.force)throw Error(`refusing to overwrite ${X} \u2014 pass --force`);if(J.json){let Z=M(W,q,"entries.jsonl");if(!f(Z))throw Error(`session ${q.slice(0,8)} has no entries.jsonl to copy`);w(X,Jq(Z))}else{let Z=new p(W,q);w(X,Xq(Z.path(),q,new m))}return{path:X,format:V}}function $q(W){let K=W.slice(2),J={json:!1,force:!1},q=!1;for(let V=0;V<K.length;V++){let X=K[V];if(X==="--json")J.json=!0;else if(X==="--force")J.force=!0;else if(X==="--out"){let Z=K[++V];if(Z===void 0||Z.startsWith("-"))throw Error(`--out needs a path \u2014 ${E}`);J.out=Z}else if(!X.startsWith("-")){if(!q&&X==="export")q=!0;else if(J.idOrPrefix===void 0)J.idOrPrefix=X}}return J}function hq(W){try{let K=$q(W),J=Zq(M(process.cwd(),".rovecode","sessions"),K.idOrPrefix??"",K);console.log(`exported ${J.format} \u2192 ${J.path}`)}catch(K){let J=K instanceof Error?K.message:String(K);console.error(`error: ${J}`),process.exit(J.startsWith("usage:")?2:1)}}var G=2000,O=120,E="usage: rovecode export <session-id|prefix> [--json] [--out <path>] [--force]";var Bq=I(()=>{r();s();qq();e();h();S();t()});
|
|
18
|
+
export{Gq as i,P as j,S as k,G as l,Qq as m,Xq as n,Zq as o,$q as p,hq as q,Bq as r};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Hg as T,Ig as N,Kg as O,Lg as S,Pg as V,Qg as R,Rg as f,Sg as x,Tg as b,Ug as A,Vg as _}from"./main-7jd5vh3x.js";import{$m as I,Lm as H}from"./main-2yeveeve.js";import{cn as F,fn as Y,kn as L}from"./main-nqveez48.js";I();S();_();N();L();import{relative as E}from"path";var M=["usage: rovecode plugin <command>"," list every plugin in ~/.rovecode/plugins and .rovecode/plugins, with its status"," add <folder|git-url> [--project] [--force]"," copy (or shallow-clone) a plugin into the user scope, or this repo's .rovecode/plugins"," remove <name> [--project] delete the installed copy"," enable <name> \xB7 disable <name>"," switch a plugin off/on in every scope (~/.rovecode/plugins.json)"," trust <name> approve a PROJECT plugin's current files on this machine \u2014 until they change"," untrust <name> withdraw that approval"," show <name> manifest, files and what it contributes, without running any of it","status: active \xB7 disabled \xB7 untrusted (project plugin not yet approved here) \xB7 broken (see problems)"].join(`
|
|
3
|
+
`),Z=(D,K)=>D.includes(K),v=(D)=>D.filter((K)=>!K.startsWith("--"));async function l(D,K={}){let B=K.cwd??process.cwd(),J=K.home??H(),y=K.out??((j)=>console.log(j)),z=K.err??((j)=>console.error(j)),[Q="list",...W]=D,X=Z(W,"--project")?"project":"user",q=v(W)[0];switch(Q){case"list":case"ls":{let{plugins:j,warnings:k}=O(B,{home:J});if(j.length===0)y(`no plugins. add one: rovecode plugin add <folder|git-url> (user: ${V("user",B,J)}, project: ${E(B,V("project",B,J))||"."})`);for(let C of j)y($(C));for(let C of k)z(`warning: ${C}`);return 0}case"add":{let j=q;if(!j)return z(M),2;let k=await R(j,{cwd:B,home:J,scope:X,force:Z(W,"--force"),...K.spawn?{spawn:K.spawn}:{}});if(!k.ok)return z(`plugin add: ${k.error}`),1;y(`added ${k.name}@${k.manifest.version} (${k.scope}) \u2192 ${k.dir}`);for(let C of T(k.manifest))y(` ${C}`);if(k.scope==="project")y(` trusted on this machine (recorded in ${F(J)}); a change to its files will ask again`);return y("restart rovecode to load it \u2014 plugins are read once per process, like hooks"),0}case"remove":case"rm":{if(!q)return z(M),2;let j=f(q,{cwd:B,home:J,scope:X});if(!j.ok)return z(`plugin remove: ${j.error}`),1;return y(`removed ${q} (${X}) from ${j.dir}`),0}case"enable":case"disable":{if(!q)return z(M),2;if(!O(B,{home:J}).plugins.some((C)=>C.name===q))z(`warning: no installed plugin named "${q}" \u2014 the setting is recorded anyway`);let k=x(q,Q==="enable",J);return y(`${q} ${Q}d (${k})`),0}case"trust":{if(!q)return z(M),2;let j=O(B,{home:J}).plugins.find((C)=>C.name===q&&C.scope==="project");if(!j)return z(`plugin trust: no project plugin "${q}" under ${V("project",B,J)}`),1;if(j.manifest===null){z(`plugin trust: "${q}" is broken \u2014 fix it first:`);for(let C of j.problems)z(` ${C}`);return 1}let k=b(q,{cwd:B,home:J});if(!k.ok)return z(`plugin trust: ${k.error}`),1;y(`trusted ${q}@${j.manifest.version} \u2014 ${Y(j.dir).length} files, digest ${k.digest.slice(0,12)}\u2026`);for(let C of T(j.manifest))y(` ${C}`);return y("it loads on the next start; `rovecode plugin show "+q+"` lists every file it brings"),0}case"untrust":{if(!q)return z(M),2;return y(A(q,{cwd:B,home:J})?`untrusted ${q}`:`${q} was not trusted`),0}case"show":case"info":{if(!q)return z(M),2;let j=O(B,{home:J}).plugins.find((k)=>k.name===q);if(!j)return z(`plugin show: no plugin "${q}"`),1;if(y($(j)),y(` folder: ${j.dir}`),j.digest)y(` digest: ${j.digest}`);if(j.manifest)for(let k of T(j.manifest))y(` ${k}`);for(let k of Y(j.dir))y(` - ${k}`);for(let k of j.problems)y(` ! ${k}`);if(j.status==="untrusted")y(` run \`rovecode plugin trust ${j.name}\` after reading the files above`);return 0}case"help":case"--help":case"-h":return y(M),0;default:return z(`unknown plugin command "${Q}"
|
|
4
|
+
${M}`),2}}function $(D){let K=D.manifest?`@${D.manifest.version}`:"",B=D.manifest?.description?` \u2014 ${D.manifest.description}`:"";return`${(D.name+K).padEnd(28)} ${D.scope.padEnd(8)} ${D.status.padEnd(9)}${B}`.trimEnd()}
|
|
5
|
+
export{M as Bg,l as Cg,$ as Dg};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{pm as Z,vm as D}from"./main-y5c82rxr.js";import{wn as $}from"./main-qsevpgsv.js";function K(q,y="mcp output"){if(q.length<=V)return q;return`${q.slice(0,V)}
|
|
3
|
+
[${y} truncated: showing ${V} of ${q.length} chars]`}function E(q,y){let z=[];if(Array.isArray(q))for(let B of q){if(!Z(B))continue;if(B.type==="text"&&typeof B.text==="string")z.push(B.text);else if(typeof B.type==="string")z.push(`[${B.type} content]`)}if(z.length===0&&y!==void 0)try{z.push(JSON.stringify(y))}catch{}return K(z.join(`
|
|
4
|
+
`))}function R(q){let y=new AbortController;if(q===void 0)return{signal:y.signal,dispose:()=>{}};if(q.aborted)return y.abort(q.reason),{signal:y.signal,dispose:()=>{}};let z=()=>y.abort(q.reason);return q.addEventListener("abort",z,{once:!0}),{signal:y.signal,dispose:()=>q.removeEventListener("abort",z)}}async function G(q,y){let z=R(q);try{return await y(z.signal)}finally{z.dispose()}}function I(q){return typeof q==="object"&&q!==null&&q.code===-32601}function W(q){return`needs login \u2014 run \`rovecode mcp login ${q}\``}function k(q){return q.headers!==void 0&&Object.keys(q.headers).some((y)=>y.toLowerCase()==="authorization")}async function L(q,y,z){let B,H=new Promise((J,F)=>{B=setTimeout(()=>F(Error(z)),y)});try{return await Promise.race([q,H])}finally{if(B!==void 0)clearTimeout(B)}}async function O(q,y,z,B){let H=[],J=new Set,F,N=0;do{if(B?.aborted)throw Error(`${q} listing on "${y}" aborted`);let Q=await z(F);if(N+=1,H.push(...Q.items),F=typeof Q.nextCursor==="string"?Q.nextCursor:void 0,F!==void 0){if(J.has(F))throw Error(`${q} listing on "${y}" stopped: server repeated pagination cursor ${JSON.stringify(F)} (partial: ${H.length} ${q}s in ${N} pages)`);if(J.add(F),N>=Y)throw Error(`${q} listing on "${y}" stopped after ${Y} pages without a final page (partial: ${H.length} ${q}s)`)}}while(F!==void 0);return H}var Y=50,V=1e4,b;var j=$(()=>{D();b=class b extends Error{constructor(q){super(W(q));this.name="McpNeedsLoginError"}}});
|
|
5
|
+
export{K as cm,E as dm,R as em,G as fm,I as gm,W as hm,b as im,k as jm,L as km,O as lm,j as mm};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$m as P,Lm as A}from"./main-2yeveeve.js";P();import{readFileSync as R,writeFileSync as x,mkdirSync as C}from"fs";import{execFile as E}from"child_process";import{join as N}from"path";var U="9Code-Labs/rovecode-community",O=21600000,_=8000;function W(q,z){let G=(K)=>{let J=K.trim().replace(/^v/i,""),[V="",...$]=J.split("-");return{nums:V.split(".").map((D)=>Number.parseInt(D,10)||0),pre:$.length>0}},B=G(q),Y=G(z),Z=Math.max(B.nums.length,Y.nums.length);for(let K=0;K<Z;K++){let J=B.nums[K]??0,V=Y.nums[K]??0;if(J!==V)return J>V}return Y.pre&&!B.pre}function k(q,z,G){try{let B=JSON.parse(R(q,"utf8"));if(typeof B.at!=="number"||!B.status)return null;if(G-B.at>z)return null;return{...B.status,from:"cache"}}catch{return null}}function j(q,z,G){try{C(N(q,".."),{recursive:!0}),x(q,JSON.stringify({at:G,status:{...z,from:"network"}}))}catch{}}function M(){return new Promise((q)=>{try{E("gh",["auth","token"],{timeout:1500,windowsHide:!0},(z,G)=>{let B=typeof G==="string"?G.trim():"";q(z!==null||B.length===0?void 0:B)})}catch{q(void 0)}})}async function g(q,z={}){if(z.fetchFn===void 0&&z.token===void 0&&z.cacheFile===void 0&&z.ghToken===void 0&&process.env.ROVECODE_NO_UPDATE_CHECK==="1")return{current:q,newer:!1,from:"cache",reason:"ROVECODE_NO_UPDATE_CHECK=1"};let B=(z.now??Date.now)(),Y=z.repo??U,Z=z.cacheFile??N(A(),`update-check-${Y.replace(/[^\w.-]+/g,"_")}.json`),K=z.ttlMs??O,J=k(Z,K,B);if(J)return{...J,current:q,newer:J.latest!==void 0&&W(J.latest,q)};if(z.cacheOnly===!0)return{current:q,newer:!1,from:"cache",reason:"not asked yet \u2014 rovecode checks at startup, at most once every six hours"};let V=z.token??process.env.GITHUB_TOKEN??process.env.GH_TOKEN??await(z.ghToken??M)(),$=new AbortController,D=setTimeout(()=>$.abort(),z.timeoutMs??_);try{let Q=await(z.fetchFn??fetch)(`https://api.github.com/repos/${z.repo??U}/releases/latest`,{headers:{accept:"application/vnd.github+json","user-agent":"rovecode",...V?{authorization:`Bearer ${V}`}:{}},signal:$.signal});if(Q.status===404){let L={current:q,newer:!1,from:"network",reason:"no release published yet"};return j(Z,L,B),L}if(!Q.ok)return{current:q,newer:!1,from:"network",reason:`GitHub answered ${Q.status}`};let X=await Q.json().catch(()=>null),H=typeof X?.tag_name==="string"?X.tag_name:void 0;if(!H)return{current:q,newer:!1,from:"network",reason:"the release carries no tag name"};let I={current:q,latest:H.replace(/^v/i,""),newer:W(H,q),from:"network",...typeof X?.html_url==="string"?{url:X.html_url}:{}};return j(Z,I,B),I}catch(Q){let X=Q instanceof Error?Q.message:String(Q);return{current:q,newer:!1,from:"network",reason:$.signal.aborted?"the check timed out":X}}finally{clearTimeout(D)}}function b(q,z=!1){if(q.newer&&q.latest!==void 0)return`update available: ${q.current} \u2192 ${q.latest}${q.url?` \xB7 ${q.url}`:""}`;if(!z)return null;if(q.reason!==void 0)return`update check: ${q.reason}`;return`up to date (${q.current})${q.from==="cache"?" \xB7 cached":""}`}
|
|
3
|
+
export{W as Kh,g as Lh,b as Mh};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Fi as X,Gi as Y,Ii as Z,Ji as $}from"./main-s9v8k74e.js";import{$m as b,Nm as J,Tm as Q,Xm as W}from"./main-2yeveeve.js";b();var m=`usage: rovecode auth login <${X.join("|")}>`;function C(j,k=Date.now()){if(j>=Number.MAX_SAFE_INTEGER||j>8640000000000000)return"never expires";if(!(j>=-8640000000000000))return"EXPIRED (invalid expiry)";let q=new Date(j).toISOString();return j<=k?`EXPIRED ${q}`:`expires ${q}`}function G(j=W(),k=Date.now()){return j.map((q)=>{let z=q.kind==="oauth"&&q.expires!==void 0?` ${C(q.expires,k)}`:"";return`${q.provider.padEnd(14)} ${q.kind.padEnd(6)} ${q.keyName.padEnd(24)} ${q.redacted}${z}`})}function f(){let j=G();if(j.length===0){console.log(`no stored credentials (${J()}) \u2014 run: rovecode auth set <provider> | rovecode auth login <provider>`);return}for(let k of j)console.log(k)}function H(j){switch(j.type){case"device_code":return[`open ${j.verificationUri}`,`enter ${j.userCode}`,`waiting for authorization \u2014 polling every ${j.intervalSeconds}s, up to ${Math.max(1,Math.round(j.expiresInSeconds/60))} min (Ctrl-C cancels)`];case"auth_url":return[`open ${j.url}`,`waiting for the browser to return to ${j.callbackUrl} (loopback \u2014 the browser must run on this machine; Ctrl-C cancels)`];case"progress":return[j.message]}}async function L(j,k){let q=k.provider===void 0?Y[j]:void 0;if(q!==void 0)return k.err(`rovecode auth login ${j}: refused \u2014 ${q}`),1;let z=(k.provider??Z)(j);if(!z){if(j.length>0)k.err(`error: no OAuth login for "${j}"`);return k.err(m),1}let K=k.signal??new AbortController().signal,M={...$(),...k.oauth};k.out(`rovecode auth login ${j} \u2014 ${z.label}`);try{let B=await z.login({notify:(F)=>{for(let V of H(F))k.out(` ${V}`)},signal:K},M);return(k.save??Q)(j,B),k.out(`stored OAuth token for ${j} in ${J()} (${C(B.expires,M.now())})`),0}catch(B){if(K.aborted)return k.err("login cancelled"),130;return k.err(`error: ${B instanceof Error?B.message:String(B)}`),1}}async function y(j){let k=new AbortController,q=()=>k.abort();process.once("SIGINT",q);try{return await L(j[0]??"",{out:(z)=>console.log(z),err:(z)=>console.error(z),signal:k.signal})}finally{process.removeListener("SIGINT",q)}}
|
|
3
|
+
export{m as Cc,C as Dc,G as Ec,f as Fc,H as Gc,L as Hc,y as Ic};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ii as _,ki as b,li as A,mi as E}from"./main-2wyax8k9.js";import{Ui as I,Xi as k,Yi as K,Zi as L,aj as X,cj as y,dj as T,ej as U}from"./main-xx2z3zh5.js";import{Mj as M,Wj as D}from"./main-ywbxshqc.js";D();function W(j){return{id:j.id,baseUrl:j.baseUrl,apiKey:j.apiKey??"",protocol:j.protocol,...j.defaultModel!==void 0?{defaultModel:j.defaultModel}:{},...j.headers!==void 0?{headers:j.headers}:{}}}var x=(j,{sse:z})=>{let q=W(j);return z?A(q):b(q)},C="config: ";function G(j){return{parts:[],stopReason:"error",usage:{input:0,output:0},error:C+j}}function R(j,z){return z!==null&&z!==void 0&&z.length>0?j.split(z).join("\u2026"):j}class S{cwd;env;cfg;factory;adapters=new Map;constructor(j,z={}){this.cwd=j,this.env=z.env??process.env,this.factory=z.adapterFactory??x,this.cfg=new U(j,this.env,z.throttleMs)}snapshot(){return this.cfg.snapshot()}list(){return this.snapshot().providers}ids(){return this.list().map((j)=>j.id)}get(j){return this.list().find((z)=>z.id===j)}configured(){return this.list().some(X)}warnings(){return this.snapshot().warnings}onChange(j){return this.cfg.onChange(j)}refresh(){return this.cfg.invalidate(),this.cfg.snapshot()}defaultRef(){let j=T(this.snapshot());if(j===null)return null;return{provider:j.provider.id,model:this.env.ROVECODE_MODEL??j.model??""}}defaultConfig(){let j=T(this.snapshot());if(j===null)return null;return{...W(j.provider),...j.model!==void 0?{defaultModel:j.model}:{}}}defaultSelector(){return this.snapshot().defaultSelector}resolveSelector(j,z){let q=j.trim();if(q.length===0)return{error:"empty model selector"};let H=q.indexOf("/");if(H>0){let J=q.slice(0,H),Q=q.slice(H+1).trim();if(this.get(J)!==void 0)return Q.length>0?{provider:J,model:Q}:{error:`"${q}" names no model \u2014 use ${J}/<model>`}}return{provider:z,model:q}}add(j,z="user"){let{id:q,...H}=j,J=k(q,H);if("error"in J)return J;if(this.get(q)?.scope==="env")return{error:'"custom" is reserved for the ROVECODE_BASE_URL/ROVECODE_API_KEY pair \u2014 pick another id'};let Q=I(z,this.cwd),{data:V}=K(Q),{id:Z,...$}=J.spec;return V.providers={...V.providers??{},[q]:$},L(Q,V),this.refresh(),this.get(q)}remove(j){let z=this.get(j);if(z===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(z.scope==="builtin")return{error:`"${j}" is built in; drop its key with \`rovecode auth remove ${j}\` instead`};if(z.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 unset those env vars'};let q=[];for(let H of["user","project"]){let J=I(H,this.cwd),{data:Q}=K(J);if(Q.providers!==void 0&&j in Q.providers){if(delete Q.providers[j],Object.keys(Q.providers).length===0)delete Q.providers;L(J,Q),q.push(H)}}return this.refresh(),{removed:q}}setDefault(j,z="user"){let q=y(j),H=this.get(q.provider);if(H===void 0)return{error:`unknown provider "${q.provider}" \u2014 known: ${this.ids().join(" ")}`};let J=q.model??H.defaultModel;if(J===void 0)return{error:`"${j}" names no model and ${H.id} has no default \u2014 use ${H.id}/<model>`};let Q=I(z,this.cwd),{data:V}=K(Q);return V.default=`${H.id}/${J}`,L(Q,V),this.refresh(),{provider:H.id,model:J}}setModels(j,z,q="user"){let H=this.get(j);if(H===void 0)return{error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(H.scope==="env")return{error:'"custom" comes from ROVECODE_BASE_URL/ROVECODE_API_KEY \u2014 a model list cannot be pinned on it'};for(let N of z)if(N.trim().length===0)return{error:"model ids must be non-empty strings"};let J=I(q,this.cwd),{data:Q}=K(J),V=Q.providers??{},$=V[j]??{baseUrl:H.baseUrl},B=[...new Set(z.map((N)=>N.trim()))];if(B.length===0)delete $.models;else if($.models=B,$.defaultModel!==void 0&&!B.includes($.defaultModel))delete $.defaultModel;return V[j]=$,Q.providers=V,L(J,Q),this.refresh(),{models:B}}keyHint(j){return`no API key for provider "${j.id}" \u2014 I can't call it without one. ${M(`rovecode auth set ${j.id}`)} (masked prompt) \xB7 or /provider key ${j.id} <key> in the TUI \xB7 or set ${j.keyEnv}`}async models(j,z={}){let q=this.get(j);if(q===void 0)return{ok:!1,error:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(q.models!==void 0&&q.models.length>0)return{ok:!0,models:q.models,source:"file"};if(!X(q))return{ok:!1,error:this.keyHint(q)};return{ok:!0,models:(await _(W(q),z)).map((J)=>J.id),source:"endpoint"}}async probe(j,z){let q=this.get(j);if(q===void 0)return{ok:!1,model:z??"",detail:`unknown provider "${j}" \u2014 known: ${this.ids().join(" ")}`};if(!X(q))return{ok:!1,model:z??"",detail:this.keyHint(q)};let H=z??q.defaultModel;if(H===void 0)return{ok:!1,model:"",detail:`${q.id} has no default model \u2014 pass one: test ${q.id} <model>`};let J={id:"probe",role:"user",parts:[{kind:"text",text:"ping"}],parentId:null,createdAt:Date.now()},Q=Date.now(),V;try{for await(let Z of this.adapterFor(q)({provider:q.id,model:H,maxTokens:8},[J],{tools:[]}))if(Z.type==="turn")V=Z.turn}catch(Z){return{ok:!1,model:H,detail:R(Z instanceof Error?Z.message:String(Z),q.apiKey)}}if(V===void 0)return{ok:!1,model:H,detail:"stream produced no turn"};if(V.stopReason==="error")return{ok:!1,model:H,detail:R(V.error??"stream error",q.apiKey)};return{ok:!0,model:H,detail:`ok in ${Date.now()-Q} ms (${V.usage.input} in / ${V.usage.output} out tokens)`}}stream(){let j=this;return async function*(z,q,H){let J=j.get(z.provider);if(J===void 0){yield{type:"turn",turn:G(`provider "${z.provider}" is not configured \u2014 I can't route to it. ${M(`rovecode provider add ${z.provider} <baseUrl> [--protocol openai|anthropic]`)} (or /provider add in the TUI); known: ${j.ids().join(" ")}`)};return}if(!X(J)){yield{type:"turn",turn:G(j.keyHint(J))};return}yield*j.adapterFor(J)(z,q,H)}}adapterFor(j){let z=E({ROVECODE_STREAM:this.env.ROVECODE_STREAM}),q=[j.baseUrl,j.protocol,j.apiKey??"",JSON.stringify(j.headers??{}),z?"sse":"json"].join("\x00"),H=this.adapters.get(j.id);if(H!==void 0&&H.sig===q)return H.fn;let J=this.factory(j,{sse:z});return this.adapters.set(j.id,{sig:q,fn:J}),J}}var O="add <id> <baseUrl> [--protocol openai|anthropic] [--key-env NAME] [--model <id>] [--no-key] [--project]";function g(j){let z=[],q={},H="user",J=!1;for(let $=0;$<j.length;$++){let B=j[$],N=()=>{let Y=j[$+1];if(Y===void 0||Y.startsWith("-"))return{error:`${B} needs a value \u2014 ${O}`};return $++,Y};switch(B){case"--protocol":{let Y=N();if(typeof Y!=="string")return Y;q.protocol=Y;break}case"--key-env":{let Y=N();if(typeof Y!=="string")return Y;q.keyEnv=Y;break}case"--model":{let Y=N();if(typeof Y!=="string")return Y;q.defaultModel=Y;break}case"--scope":{let Y=N();if(typeof Y!=="string")return Y;if(Y!=="user"&&Y!=="project")return{error:"--scope must be user or project"};H=Y;break}case"--project":H="project";break;case"--user":H="user";break;case"--no-key":q.noKey=!0;break;case"--key":J=!0;break;default:if(B.startsWith("-"))return{error:`unknown flag ${B} \u2014 ${O}`};z.push(B)}}let[Q,V]=z;if(Q===void 0||V===void 0)return{error:`usage: ${O}`};q.baseUrl=V;let Z=k(Q,q);if("error"in Z)return Z;return{spec:Z.spec,scope:H,promptKey:J}}function F(j){let z=j.keySource==="stored"?"key: stored":j.keySource==="env"?`key: env ${j.keyEnv}`:j.keySource==="inline"?"key: ROVECODE_API_KEY":j.noKey===!0?"key: not needed":`key: NONE (rovecode auth set ${j.id} \xB7 or set ${j.keyEnv})`;return`${j.id.padEnd(12)} ${j.protocol.padEnd(9)} ${j.baseUrl.padEnd(40)} ${z}${j.defaultModel!==void 0?` model: ${j.defaultModel}`:""} [${j.scope}]`}function u(j,z={}){let q=j.defaultRef(),H=j.list(),J=H.filter((Z)=>z.all===!0||X(Z)||Z.scope!=="builtin"),Q=[q!==null?`default \u2192 ${q.provider}/${q.model||"(no model \u2014 pass one with /model or ROVECODE_MODEL)"}${j.defaultSelector()!==void 0?` (providers.json default: ${j.defaultSelector()})`:""}`:`default \u2192 none yet. ${M("rovecode setup")} (or rovecode provider add <id> <baseUrl>, then rovecode auth set <id>)`];Q.push(...J.map(F));let V=H.length-J.length;if(V>0)Q.push(`(+${V} built-in providers without a key \u2014 \`list --all\` shows them)`);return Q.push(...j.warnings().map((Z)=>`warning: ${Z}`)),Q.join(`
|
|
3
|
+
`)}
|
|
4
|
+
export{W as Lf,x as Mf,C as Nf,G as Of,R as Pf,S as Qf,O as Rf,g as Sf,F as Tf,u as Uf};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$h as X,Sh as k,ai as y,fi as R}from"./main-kba6zeyd.js";import{$m as T,Lm as L}from"./main-2yeveeve.js";import{on as U,sn as B,tn as h}from"./main-nqveez48.js";import{wn as F}from"./main-qsevpgsv.js";import{readFileSync as p}from"fs";import{join as v}from"path";function m(q){return q.replace(/\s*[\r\n]+\s*/g," ").trim()}function A(q){return k.includes(q)}function H(q,z){let Q=typeof q==="string"?q.trim().toLowerCase():"";if(A(Q))return Q;let J=typeof q==="string"?q:JSON.stringify(q);return $(`sandbox rung ${JSON.stringify(String(J).slice(0,60))} from ${z} is not a rung \u2014 use one of ${k.join(", ")} (bubblewrap is not a rung on this harness); ${Y}`)}function D(q,z){if(typeof q==="string"&&q.trim()!=="")return q.trim();return $(`sandbox dockerImage from ${z} must be a non-empty string (e.g. "${y}"); ${Y}`)}function $(q){throw new V(q)}function O(q){let z=v(q,".rovecode","sandbox.json"),Q;try{Q=p(z,"utf8")}catch(P){if(P.code==="ENOENT")return null;return $(`sandbox config ${z} cannot be read (${P instanceof Error?P.message:String(P)}) \u2014 ${Y}`)}let J;try{J=JSON.parse(Q)}catch(P){return $(`sandbox config ${z} is not valid JSON (${P instanceof Error?P.message:String(P)}) \u2014 fix or delete it; ${Y}`)}if(!J||typeof J!=="object"||Array.isArray(J))return $(`sandbox config ${z} must be a JSON object like {"rung":"wsl"} or {"rung":"docker","dockerImage":"${y}"}; ${Y}`);let W=J;return{rung:W.rung,dockerImage:W.dockerImage,path:z}}function u(q,z=process.env,Q={}){let J=O(q),W;if(J!==null){if(!(Q.trusted??((C)=>U(Q.home??L(),C)))(J.path))W=B(J.path,"its sandbox rung and docker image are ignored (a repo file would choose the executor every bash command runs in)"),J=null}let P=z[K]?.trim()??"",G=z[S]?.trim()??"",j="direct",M="default";if(P!=="")j=H(P,K),M="env";else if(J&&J.rung!==void 0)j=H(J.rung,J.path),M="file";let Z;if(G!=="")Z=G;else if(J&&J.dockerImage!==void 0)Z=D(J.dockerImage,J.path);else if(j==="docker")Z=y;return{rung:j,source:M,...Z!==void 0?{dockerImage:Z}:{},...W!==void 0?{note:W}:{}}}function t(q,z){let Q=z instanceof X?z.detail:z instanceof Error?z.message:String(z);return new V(`sandbox rung "${q.rung}" (from ${x(q)}) unavailable: ${Q} \u2014 ${Y}`,{cause:z})}function x(q){return q.source==="env"?K:q.source==="file"?b:"default"}function i(q){let z=q.rung==="docker"?` ${q.dockerImage??y}`:"";return`${q.rung}${z} (${x(q)})`}var b=".rovecode/sandbox.json",K="ROVECODE_SANDBOX",S="ROVECODE_SANDBOX_IMAGE",Y,V;var _=F(()=>{T();R();h();Y=`fix ${b} or ${K} (default: direct)`;V=class V extends Error{constructor(q,z){super(m(q),z);this.name="SandboxConfigError"}}});
|
|
3
|
+
export{b as mg,K as ng,S as og,V as pg,u as qg,t as rg,i as sg,_ as tg};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wn as M}from"./main-qsevpgsv.js";import{mkdirSync as X,readFileSync as l,renameSync as N,writeFileSync as w}from"fs";import{basename as C,join as y}from"path";function v(z){return f.includes(z)}function c(z){return u.includes(z)}function U(z){let q;try{q=JSON.stringify(z)??String(z)}catch{q=String(z)}return q.length>40?q.slice(0,40).replace(/[\uD800-\uDBFF]$/,"")+"\u2026":q}function L(z){let q=(J)=>({ok:!1,error:J});if(!Array.isArray(z))return q("`todos` must be an array of {id, content, status, priority?}");if(z.length>Y)return q(`too many todos: ${z.length} (max ${Y})`);let Q=[],K=new Set,$=[];for(let J=0;J<z.length;J++){let k=z[J],Z=`todos[${J}]`;if(!k||typeof k!=="object"||Array.isArray(k))return q(`${Z} must be an object {id, content, status, priority?}`);let b=k;if(typeof b.id!=="string"||b.id.trim().length===0)return q(`${Z}.id must be a non-empty string`);let B=b.id.trim();if(B.length>W)return q(`${Z}.id exceeds ${W} chars`);if(K.has(B))return q(`duplicate id "${B}" at ${Z} \u2014 ids must be unique`);if(K.add(B),typeof b.content!=="string"||b.content.trim().length===0)return q(`${Z} ("${B}"): content must be a non-empty string`);let H=b.content.trim();if(H.length>j)return q(`${Z} ("${B}"): content exceeds ${j} chars`);if(!v(b.status))return q(`${Z} ("${B}"): status must be one of ${f.join(", ")} (got ${U(b.status)})`);let V={id:B,content:H,status:b.status};if(b.priority!==void 0&&b.priority!==null){if(!c(b.priority))return q(`${Z} ("${B}"): priority must be one of ${u.join(", ")} (got ${U(b.priority)})`);V.priority=b.priority}if(V.status==="in_progress")$.push(B);Q.push(V)}if($.length>1)return q(`only one todo may be in_progress at a time (found ${$.length}: ${$.join(", ")})`);return{ok:!0,items:Q}}function A(z){let q=y(z,G),Q="treating the list as empty; the next todo_write replaces it",K;try{K=l(q,"utf8")}catch(Z){if(Z?.code==="ENOENT")return{items:[]};return{items:[],note:`${G} could not be read (${Z instanceof Error?Z.message:String(Z)}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`}}let $;try{$=JSON.parse(K)}catch{return{items:[],note:`${G} is not valid JSON \u2014 ${"treating the list as empty; the next todo_write replaces it"}`}}let J=$&&typeof $==="object"&&!Array.isArray($)?$:null;if(!J||J.version!==p||!Array.isArray(J.items))return{items:[],note:`${G} has an unexpected shape (expected {version: ${p}, items: [...]}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`};let k=L(J.items);if(!k.ok)return{items:[],note:`${G} failed validation (${k.error}) \u2014 ${"treating the list as empty; the next todo_write replaces it"}`};return{items:k.items}}function E(z,q){X(z,{recursive:!0});let Q=y(z,G),K=Q+".tmp";w(K,JSON.stringify({version:p,items:q},null,2)+`
|
|
3
|
+
`),N(K,Q)}function F(z,q){if(!q||q==="."||q===".."||/[\\/]/.test(q)||C(q)!==q)return null;return y(z,q)}function h(z){let q={total:z.length,pending:0,inProgress:0,completed:0};for(let Q of z)if(Q.status==="completed")q.completed++;else if(Q.status==="in_progress")q.inProgress++;else q.pending++;return q}function x(z){let q=z.replace(/\s+/g," ").trim();return q.length>P?q.slice(0,P).replace(/[\uD800-\uDBFF]$/,"")+"\u2026":q}function g(z){if(z.length===0)return"todos: (empty)";let q=h(z),Q=[`todos: ${q.total} total \xB7 ${q.completed} completed \xB7 ${q.inProgress} in progress \xB7 ${q.pending} pending`];for(let K of z.slice(0,Y))Q.push(`${R[K.status]} ${x(K.id)}: ${x(K.content)}${K.priority?` (${K.priority})`:""}`);if(z.length>Y)Q.push(`(+${z.length-Y} more not shown)`);return Q.join(`
|
|
4
|
+
`)}function O(z){let q=h(z);if(q.total===0||q.completed===q.total)return null;return["<plan-reminder>","Your own todo list for this task, still open \u2014 not a message from the user.",g(z),q.inProgress===0?"Nothing is in progress. Mark the next item in_progress with todo_write before you start it.":"Mark the in_progress item completed with todo_write the moment it is done, then start the next one.","Rewrite the list if the plan changed. Never mention this reminder in your reply.","</plan-reminder>"].join(`
|
|
5
|
+
`)}function n(z){if(z.length===0)return"";let q=h(z);return`todos ${q.completed}/${q.total}`}function _(z){return{schema:{name:"todo_write",description:D,args:{type:"object",properties:{todos:{type:"array",description:"the complete, updated todo list (replaces the current one)",maxItems:Y,items:I}},required:["todos"]}},kind:"memory",sequential:!0,execute(q,Q){let K=F(z,Q.sessionId);if(!K)return Promise.resolve({ok:!1,output:`todo_write failed: invalid session id ${U(Q.sessionId)}`});let J=L((q&&typeof q==="object"?q:{}).todos);if(!J.ok)return Promise.resolve({ok:!1,output:`todo_write failed: ${J.error}; the list was not changed`});try{E(K,J.items)}catch(Z){return Promise.resolve({ok:!1,output:`todo_write failed: could not write ${G}: ${Z instanceof Error?Z.message:String(Z)}`})}let k=J.items.length===0?"Cleared todo list.":g(J.items);return Promise.resolve({ok:!0,output:k,data:{items:J.items}})}}}function S(z){return{schema:{name:"todo_read",description:m,args:{type:"object",properties:{}}},kind:"read",sequential:!1,execute(q,Q){let K=F(z,Q.sessionId);if(!K)return Promise.resolve({ok:!1,output:`todo_read failed: invalid session id ${U(Q.sessionId)}`});let{items:$,note:J}=A(K);if($.length===0){let k=J?`${J}
|
|
6
|
+
`:"";return Promise.resolve({ok:!0,output:`${k}No todos for this session yet \u2014 use todo_write to create a list.`,data:{items:$,...J?{note:J}:{}}})}return Promise.resolve({ok:!0,output:g($),data:{items:$}})}}}function r(z){return[_(z),S(z)]}var f,u,Y=50,W=64,j=500,G="todos.json",p=1,P=200,R,D,m="Read this session's todo list as last written by todo_write: ids, content, status, priority. Use it to get the current ids before updating the list, or to check what remains. Empty until todo_write creates a list.",I;var a=M(()=>{f=["pending","in_progress","completed"],u=["high","medium","low"];R={pending:"[ ]",in_progress:"[>]",completed:"[x]"};D="Create or update this session's structured todo list (your plan). REPLACES the whole list: send every item "+`you want kept \u2014 items {id, content, status, priority?}; at most ${Y} items, ids unique and non-empty `+`(\u2264${W} chars), content non-empty (\u2264${j} chars). Statuses: pending | in_progress (exactly ONE at a time) | completed. Priority: high | medium | low (optional). An invalid list is rejected whole and nothing changes; an empty list clears the todos. Use proactively when: the task needs 3+ distinct steps; the work is non-trivial and benefits from planning; the user gives multiple tasks or asks for a todo list; new instructions arrive (capture them as todos); you start a step (mark it in_progress first) or finish one (mark it `+"completed only once the work, including verification, is actually done \u2014 never on intent; add follow-ups "+"discovered on the way). Skip it for a single straightforward task, a purely informational request, or when "+"tracking adds no value. Update in real time \u2014 don't batch completions. When in doubt, use it.",I={type:"object",properties:{id:{type:"string",description:`stable short id, unique within the list (e.g. "t1"); \u2264${W} chars`},content:{type:"string",description:`brief, specific, actionable description of the task; \u2264${j} chars`},status:{type:"string",enum:[...f],description:"pending | in_progress (exactly one at a time) | completed"},priority:{type:"string",enum:[...u],description:"optional priority"}},required:["id","content","status"]}});
|
|
7
|
+
export{f as mf,u as nf,Y as of,W as pf,j as qf,G as rf,L as sf,A as tf,E as uf,h as vf,g as wf,O as xf,n as yf,_ as zf,S as Af,r as Bf,a as Cf};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$m as c,Lm as I}from"./main-2yeveeve.js";import{wn as E}from"./main-qsevpgsv.js";function b(J){let Q=J.charCodeAt(0)===65279?J.slice(1):J,Z=Q.indexOf(`
|
|
3
|
+
`);if(Z===-1||Q.slice(0,Z).replace(/\r$/,"")!=="---")return null;let z=/\r?\n---[ \t]*(?=\r?\n|$)/g;z.lastIndex=Z;let Y=z.exec(Q);if(Y===null)return null;let $=Q.slice(Z+1,Y.index),V=Q.slice(Y.index+Y[0].length).replace(/^\r?\n/,"").replace(/^\r?\n/,""),G={},W={},U={},j=[],T=(P)=>{if(delete U[P],!j.includes(P))j.push(P)},q,B=!1,X,D=-1;for(let P of $.split(/\r?\n/)){let H=P.trim();if(H===""||H.startsWith("#"))continue;let M=P.length-P.trimStart().length;if(M===0){let O=P.indexOf(":");if(O<=0){q=void 0;continue}q=P.slice(0,O).trim();let C=P.slice(O+1).trim();if(X=void 0,D=-1,B=k.test(C),q==="metadata"){if(W[q]=C===""?"map":"scalar",C!=="")G[q]=L(C);continue}W[q]="scalar",G[q]=B?"":L(C);continue}if(q===void 0)continue;if(q==="metadata"&&W[q]==="map"){if(X!==void 0&&M>D){T(X);continue}let O=H.indexOf(":");if(H.startsWith("- ")||O<=0){W[q]="list";continue}X=H.slice(0,O).trim(),D=M;let C=H.slice(O+1).trim();if(C==="")T(X);else U[X]=L(C);continue}let R=G[q]??"";if(!B&&W[q]==="scalar"&&R===""){if(H.startsWith("- "))W[q]="list";else if(f.test(H))W[q]="map"}G[q]=R===""?H:`${R} ${H}`}return{fields:G,shapes:W,metadata:U,metadataNonString:j,body:V}}function u(J,Q,Z){let z=[],Y=[],$=[],V=(M)=>{(Z==="strict"?z:Y).push(M)},G=J.fields,W=G.description??"";if(W==="")z.push(`description is required (1\u2013${1024} characters)`);else if(W.length>1024)V(`description is ${W.length} characters (max 1024)`);let U=G.name??"";if(U===""){if(Z==="strict")z.push("name is required");else Y.push(`name missing \u2014 using the directory name "${Q}"`);U=Q}else{if(U.length>64)V(`name is ${U.length} characters (max 64)`);if(!y.test(U))V(`name "${U}" must be lower-case letters, digits and single hyphens (no leading, trailing or double hyphen)`);if(U!==Q)V(`name "${U}" does not match its directory "${Q}"`)}let j=G.compatibility||void 0;if(j!==void 0&&j.length>500)V(`compatibility is ${j.length} characters (max 500)`);let T=J.shapes.metadata;if(T!==void 0&&T!=="map")V("metadata must be a map of string keys to string values");if(J.metadataNonString.length>0)V(`metadata values must be strings: ${J.metadataNonString.join(", ")}`);let q=J.shapes["allowed-tools"];if(q!==void 0&&q!=="scalar")V("allowed-tools must be one space-separated string");let B=Object.keys(J.shapes).filter((M)=>!h.has(M));if(B.length>0)(Z==="strict"?$:Y).push(`unknown frontmatter keys: ${B.join(", ")}`);let X=G.version||J.metadata.version||"",D=G.license||void 0,P=(G["allowed-tools"]??"").split(/\s+/).filter((M)=>M!==""),H={name:U,description:W,version:X,metadata:J.metadata,allowedTools:P};if(D!==void 0)H.license=D;if(j!==void 0)H.compatibility=j;return{meta:H,errors:z,warnings:Y,notes:$}}var y,h,k,f,L=(J)=>J.trim().replace(/^["']|["']$/g,"");var x=E(()=>{y=/^[a-z0-9]+(-[a-z0-9]+)*$/,h=new Set(["name","description","license","compatibility","metadata","allowed-tools","version"]),k=/^[>|][+-]?$/,f=/^[A-Za-z0-9_-]+:(\s|$)/});import{existsSync as F,readFileSync as w,readdirSync as m,renameSync as d,statSync as S,utimesSync as GJ,writeFileSync as l}from"fs";import{basename as p,dirname as r,join as K,resolve as A}from"path";function o(J,Q){let Z=b(Q);return{fields:{...Z?.fields??{},...J},shapes:Z?.shapes??Object.fromEntries(Object.keys(J).map((Y)=>[Y,"scalar"])),metadata:Z?.metadata??{},metadataNonString:Z?.metadataNonString??[],body:Z?.body??""}}function UJ(J,Q){return Q==="project"?K(J,".rovecode","skills"):K(I(),"skills")}function a(J){if(!J.startsWith("---"))return null;let Q=J.indexOf(`
|
|
4
|
+
---`,3);if(Q===-1)return null;let Z=Q+1+J.slice(Q+1).indexOf(`
|
|
5
|
+
`)+1,z=J.slice(4,Q),Y=J.slice(Z).replace(/^\r?\n/,""),$={},V=z.split(/\r?\n/);for(let G=0;G<V.length;G++){let W=V[G];if(/^\s/.test(W))continue;let U=W.indexOf(":");if(U===-1)continue;let j=W.slice(0,U).trim();if(!j)continue;let T=W.slice(U+1).trim(),q=/^([|>])([+-]?)$/.exec(T);if(q===null){$[j]=T.replace(/^["']|["']$/g,"");continue}let B=q[1]===">",X=[];while(G+1<V.length){let D=V[G+1];if(D.trim()!==""&&!/^\s/.test(D))break;X.push(D.replace(/^\s+/,"")),G++}while(X.length>0&&X[X.length-1]==="")X.pop();$[j]=B?X.join(" ").replace(/\s+/g," ").trim():X.join(`
|
|
6
|
+
`)}return{fm:$,body:Y}}function t(J){let Q=J.replace(/\s+/g," ").trim();if(Q.length<=_)return Q;let Z=Q.slice(0,_-1),z=Z.lastIndexOf(" ");return`${(z>_/2?Z.slice(0,z):Z).replace(/[,;:.]$/,"")}\u2026`}function e(J,Q){let Z;try{Z=w(J,"utf8")}catch(W){return{invalid:{path:J,reason:`unreadable: ${W.message}`}}}let z=a(Z);if(!z)return{invalid:{path:J,reason:"missing frontmatter block"}};let Y=r(J),$=u(o(z.fm,Z),p(Y),"lenient");if($.errors.length>0)return{invalid:{path:J,reason:$.errors.join("; ")}};let V=$.meta.description,G=S(J);return{skill:{name:$.meta.name,description:t(V),fullDescription:V,version:$.meta.version||"0.0.0",path:J,dir:Y,body:z.body,scope:Q,mtimeMs:G.mtimeMs,size:G.size,...$.meta.license!==void 0?{license:$.meta.license}:{},...$.meta.compatibility!==void 0?{compatibility:$.meta.compatibility}:{},metadata:$.meta.metadata,allowedTools:$.meta.allowedTools},warnings:$.warnings}}function g(J){return J+".usage.json"}function v(J){let Q=g(J);if(!F(Q))return;try{let Z=JSON.parse(w(Q,"utf8"));return{viewCount:typeof Z.viewCount==="number"?Z.viewCount:0,lastViewedAt:typeof Z.lastViewedAt==="number"?Z.lastViewedAt:0}}catch{return}}function JJ(J,Q){let Z=g(J),z=Z+".tmp";l(z,JSON.stringify(Q,null,2)),d(z,Z)}function XJ(J,Q,Z){let z=Q&&Q.viewCount>0?Q.lastViewedAt:J.mtimeMs;return Z-z>n?"stale":"active"}class QJ{cwd;projectDir;globalDir;maxDepth;cache=new Map;manifest=new Map;constructor(J,Q={}){this.cwd=J;this.projectDir=A(J,Q.projectDir??K(".rovecode","skills")),this.globalDir=Q.globalDir===null?null:A(Q.globalDir??K(I(),"skills")),this.maxDepth=Q.maxDepth??3,this.walkProject=Q.walkProject!==!1,this.extraDirs=(Q.extraDirs??[]).map(({dir:Z,scope:z})=>[A(J,Z),z])}extraDirs;walkProject;dirs(){let J=this.walkProject?[[this.projectDir,"project"]]:[];if(this.globalDir&&F(this.globalDir))J.push([this.globalDir,"global"]);for(let[Q,Z]of this.extraDirs)if(F(Q))J.push([Q,Z]);return J}find(J,Q=J,Z=0){let z;try{z=m(Q,{withFileTypes:!0})}catch{return[]}if(z.some(($)=>$.isFile()&&$.name===N))return[K(Q,N)];let Y=[];for(let $ of z){let V=K(Q,$.name);if($.isFile()&&$.name===N)Y.push(V);else if($.isDirectory()&&Z<this.maxDepth&&!s[$.name]&&!$.name.startsWith("."))Y.push(...this.find(J,V,Z+1))}return Y}scan(){let J=new Map,Q=new Map;for(let[$,V]of this.dirs())for(let G of this.find($))try{let W=S(G);if(J.set(G,`${W.mtimeMs}:${W.size}`),!Q.has(G))Q.set(G,V)}catch{}let Z={added:[],removed:[],changed:[]};for(let[$,V]of J)if(!this.manifest.has($))Z.added.push($);else if(this.manifest.get($)!==V)Z.changed.push($);for(let $ of this.manifest.keys())if(!J.has($))Z.removed.push($);let z=[],Y=[];for(let $ of[...Z.added,...Z.changed]){let V=Q.get($)??($.startsWith(this.projectDir)?"project":"global"),G=e($,V);if("skill"in G){this.cache.set($,G.skill);for(let W of G.warnings)Y.push({path:$,reason:W})}else this.cache.delete($),z.push(G.invalid)}for(let $ of Z.removed)this.cache.delete($);return this.manifest=J,{skills:this.list(),invalid:z,warnings:Y,changes:Z}}list(){let J=new Map;for(let Q of this.cache.values()){let Z=J.get(Q.name);if(!Z||Z.scope==="global"&&Q.scope==="project")J.set(Q.name,Q)}return[...J.values()].sort((Q,Z)=>Q.name.localeCompare(Z.name))}get(J){return this.list().find((Q)=>Q.name===J)}usage(J){let Q=this.get(J);return Q?v(Q.path):void 0}bumpUsage(J,Q=Date.now()){let z={viewCount:(v(J.path)?.viewCount??0)+1,lastViewedAt:Q};return JJ(J.path,z),z}}var N="SKILL.md",i,qJ=(J)=>i.some((Q)=>J.endsWith(Q)),_=60,n=7776000000,s;var ZJ=E(()=>{c();x();i=[".usage.json",".versions.jsonl"],s={node_modules:!0,".git":!0}});
|
|
7
|
+
export{b as mh,u as nh,x as oh,N as ph,qJ as qh,UJ as rh,a as sh,XJ as th,QJ as uh,ZJ as vh};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{$m as _,Lm as D,Nm as V,Om as K,Ym as N}from"./main-2yeveeve.js";_();import{mkdirSync as R,readFileSync as U,statSync as k,writeFileSync as g}from"fs";import{dirname as S,join as j}from"path";var E=[{id:"kaesra",baseUrl:"https://api.example.invalid/v1",protocol:"openai",keyEnv:"KAESRA_API_KEY",defaultModel:"zai-org/glm-5.3-flash"},{id:"openai",baseUrl:"https://api.openai.com/v1",protocol:"openai",keyEnv:"OPENAI_API_KEY"},{id:"anthropic",baseUrl:"https://api.anthropic.com/v1",protocol:"anthropic",keyEnv:"ANTHROPIC_API_KEY",defaultModel:"claude-opus-5"},{id:"deepseek",baseUrl:"https://api.deepseek.com/v1",protocol:"openai",keyEnv:"DEEPSEEK_API_KEY"},{id:"groq",baseUrl:"https://api.groq.com/openai/v1",protocol:"openai",keyEnv:"GROQ_API_KEY"},{id:"openrouter",baseUrl:"https://openrouter.ai/api/v1",protocol:"openai",keyEnv:"OPENROUTER_API_KEY"},{id:"ollama",baseUrl:"http://127.0.0.1:11434/v1",protocol:"openai",keyEnv:"OLLAMA_API_KEY"},{id:"lmstudio",baseUrl:"http://127.0.0.1:1234/v1",protocol:"openai",keyEnv:"LMSTUDIO_API_KEY"},{id:"together",baseUrl:"https://api.together.xyz/v1",protocol:"openai",keyEnv:"TOGETHER_API_KEY"},{id:"mistral",baseUrl:"https://api.mistral.ai/v1",protocol:"openai",keyEnv:"MISTRAL_API_KEY"},{id:"cerebras",baseUrl:"https://api.cerebras.ai/v1",protocol:"openai",keyEnv:"CEREBRAS_API_KEY"},{id:"fireworks",baseUrl:"https://api.fireworks.ai/inference/v1",protocol:"openai",keyEnv:"FIREWORKS_API_KEY"},{id:"perplexity",baseUrl:"https://api.perplexity.ai",protocol:"openai",keyEnv:"PERPLEXITY_API_KEY"},{id:"xai",baseUrl:"https://api.x.ai/v1",protocol:"openai",keyEnv:"XAI_API_KEY"},{id:"moondream",baseUrl:"https://api.moondream.ai/v1",protocol:"openai",keyEnv:"MOONDREAM_API_KEY"},{id:"vllm",baseUrl:"http://127.0.0.1:8000/v1",protocol:"openai",keyEnv:"VLLM_API_KEY"}];function T(){return j(D(),"providers.json")}function O(q){return j(q,".rovecode","providers.json")}function t(q,G){return q==="project"?O(G):T()}var b=/^[a-z0-9][a-z0-9_.-]{0,39}$/,f=/^[A-Z_][A-Z0-9_]*$/;function x(q){return q.includes("anthropic.com")?"anthropic":"openai"}function u(q,G){if(!b.test(q))return{error:`provider id "${q}" must be a lowercase slug (a-z 0-9 _ . -), at most 40 chars`};if(typeof G!=="object"||G===null||Array.isArray(G))return{error:`provider "${q}": entry must be an object`};let z=G,W=typeof z.baseUrl==="string"?z.baseUrl.trim().replace(/\/+$/,""):"";if(!/^https?:\/\/[^\s/]+/.test(W))return{error:`provider "${q}": baseUrl must be an http(s) URL`};let X=z.protocol===void 0?x(W):z.protocol;if(X!=="openai"&&X!=="anthropic")return{error:`provider "${q}": protocol must be "openai" or "anthropic"`};let J={id:q,baseUrl:W,protocol:X};if(z.keyEnv!==void 0){if(typeof z.keyEnv!=="string"||!f.test(z.keyEnv))return{error:`provider "${q}": keyEnv must be an ENV_VAR_NAME`};J.keyEnv=z.keyEnv}if(z.defaultModel!==void 0){if(typeof z.defaultModel!=="string"||z.defaultModel.trim().length===0)return{error:`provider "${q}": defaultModel must be a non-empty string`};J.defaultModel=z.defaultModel.trim()}if(z.models!==void 0){if(!Array.isArray(z.models)||!z.models.every((Q)=>typeof Q==="string"&&Q.trim().length>0))return{error:`provider "${q}": models must be a list of model ids`};J.models=z.models.map((Q)=>Q.trim())}if(z.headers!==void 0){let Q=z.headers;if(typeof Q!=="object"||Q===null||Array.isArray(Q)||!Object.values(Q).every((Y)=>typeof Y==="string"))return{error:`provider "${q}": headers must be an object of strings`};J.headers={...Q}}if(z.noKey!==void 0){if(typeof z.noKey!=="boolean")return{error:`provider "${q}": noKey must be true or false`};if(z.noKey)J.noKey=!0}return{spec:J}}function y(q){let G;try{G=U(q,"utf8")}catch{return{data:{},warnings:[]}}let z;try{z=JSON.parse(G)}catch{return{data:{},warnings:[`${q}: invalid JSON \u2014 ignored`]}}if(typeof z!=="object"||z===null||Array.isArray(z))return{data:{},warnings:[`${q}: expected an object \u2014 ignored`]};let W=z,X={},J=[];if(W.default!==void 0)if(typeof W.default==="string"&&W.default.trim().length>0)X.default=W.default.trim();else J.push(`${q}: "default" must be "provider/model" \u2014 ignored`);if(W.providers!==void 0){let Q=W.providers;if(typeof Q!=="object"||Q===null||Array.isArray(Q))J.push(`${q}: "providers" must be an object \u2014 ignored`);else{X.providers={};for(let[Y,H]of Object.entries(Q)){let $=u(Y,H);if("error"in $){J.push(`${q}: ${$.error} \u2014 ignored`);continue}let{id:L,...Z}=$.spec;X.providers[Y]=Z}}}return{data:X,warnings:J}}function d(q,G){R(S(q),{recursive:!0}),g(q,JSON.stringify(G,null,2)+`
|
|
3
|
+
`)}function P(q,G,z,W){let X=q.keyEnv??N(q.id),J=W[q.id]?.key;if(J!==void 0&&J.trim().length>0)return{...q,keyEnv:X,scope:G,apiKey:J,keySource:"stored"};let Q=z[X];if(Q!==void 0&&Q.trim().length>0)return{...q,keyEnv:X,scope:G,apiKey:Q,keySource:"env"};return{...q,keyEnv:X,scope:G,apiKey:null,keySource:"none"}}function m(q){let G=q.ROVECODE_BASE_URL,z=q.ROVECODE_API_KEY??q.OPENAI_API_KEY;if(!G||!z)return null;return{id:"custom",baseUrl:G,protocol:x(G),keyEnv:"ROVECODE_API_KEY",scope:"env",apiKey:z,keySource:"inline",...q.ROVECODE_MODEL?{defaultModel:q.ROVECODE_MODEL}:{}}}function w(q){return q.apiKey!==null||q.noKey===!0}function h(q,G=process.env){let z=[],W=[],X=new Map;for(let Z of E)X.set(Z.id,{spec:Z,scope:"builtin"}),W.push(Z.id);let J,Q,Y=(Z,A)=>{let{data:M,warnings:F}=y(Z);z.push(...F);for(let[B,I]of Object.entries(M.providers??{})){let C=X.get(B);if(X.set(B,{spec:{...C?.spec??{},...I,id:B},scope:A}),C===void 0)W.push(B)}if(M.default!==void 0)J=M.default,Q=A};Y(T(),"user"),Y(O(q),"project");let H=K(),$=W.map((Z)=>{let A=X.get(Z);return P(A.spec,A.scope,G,H)}),L=m(G);if(L)$.push(L);return{providers:$,...J!==void 0?{defaultSelector:J,defaultScope:Q}:{},warnings:z}}function l(q){let G=q.trim(),z=G.indexOf("/");if(z<=0)return{provider:G};let W=G.slice(z+1).trim();return W.length>0?{provider:G.slice(0,z),model:W}:{provider:G.slice(0,z)}}function o(q){let G=q.providers.find((J)=>J.scope==="env");if(G)return{provider:G,model:G.defaultModel,via:"env-pair"};if(q.defaultSelector!==void 0){let J=l(q.defaultSelector),Q=q.providers.find((Y)=>Y.id===J.provider);if(Q&&w(Q))return{provider:Q,model:J.model??Q.defaultModel,via:"default"}}let z=q.providers.find((J)=>J.keySource==="stored");if(z)return{provider:z,model:z.defaultModel,via:"stored"};let W=q.providers.find((J)=>J.keySource==="env");if(W)return{provider:W,model:W.defaultModel,via:"env-key"};let X=q.providers.find((J)=>J.noKey===!0);if(X)return{provider:X,model:X.defaultModel,via:"no-key"};return null}class v{cwd;env;throttleMs;snap=null;stamp="";checkedAt=-1/0;listeners=new Set;constructor(q,G=process.env,z=250){this.cwd=q;this.env=G;this.throttleMs=z}sourcePaths(){return[T(),O(this.cwd),V()]}stampNow(){return this.sourcePaths().map((q)=>{try{let G=k(q);return`${G.mtimeMs}:${G.size}`}catch{return"-"}}).join("|")}snapshot(){let q=Date.now();if(this.snap!==null&&q-this.checkedAt<this.throttleMs)return this.snap;this.checkedAt=q;let G=this.stampNow();if(this.snap===null||G!==this.stamp){let z=this.snap===null;if(this.stamp=G,this.snap=h(this.cwd,this.env),!z)for(let W of this.listeners)W(this.snap)}return this.snap}invalidate(){this.checkedAt=-1/0,this.stamp=""}onChange(q){return this.listeners.add(q),()=>{this.listeners.delete(q)}}}
|
|
4
|
+
export{E as Ri,T as Si,O as Ti,t as Ui,b as Vi,x as Wi,u as Xi,y as Yi,d as Zi,P as _i,m as $i,w as aj,h as bj,l as cj,o as dj,v as ej};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{ln as N,tn as E}from"./main-nqveez48.js";import{wn as C}from"./main-qsevpgsv.js";import{existsSync as F,readFileSync as x}from"fs";import{join as L}from"path";function y(B,q){return`${B}: not trusted on this machine \u2014 its ${q} MCP server${q===1?"":"s"} stay off (they would run commands from this repo). Review: rovecode mcp show \xB7 approve: rovecode mcp trust (or rovecode trust for every gated file)`}function c(B){return b(B).project}function b(B,q){return{...q!==void 0?{user:L(q,"mcp.json")}:{},harvest:L(B,".mcp.json"),project:L(B,".rovecode","mcp.json")}}function R(B,q,I){return B.replace(S,(J,U)=>{let K=q[U];if(K===void 0)return I.push(U),"";return K})}function O(B){return typeof B==="object"&&B!==null&&!Array.isArray(B)}function _(B){return B instanceof Error?B.message:String(B)}function k(B,q,I,J,U=process.env,K={}){if(!O(q)){J.push(`${I}: server "${B}" is not an object; skipped`);return}let W=[],G=(X)=>R(X,U,W),M=typeof q.command==="string"&&q.command.length>0?q.command:void 0,Q=typeof q.url==="string"&&q.url.length>0?G(q.url):void 0,Z=typeof q.transport==="string"?q.transport:typeof q.type==="string"?q.type:void 0,T;if(Z==="stdio")T="stdio";else if(Z==="http"||Z==="streamable-http"||Z==="streamable_http")T="http";else if(Z==="sse")T="sse";else if(Z!==void 0){J.push(`${I}: server "${B}" has unknown transport "${Z}"; skipped`);return}else T=Q!==void 0?"http":M!==void 0?"stdio":void 0;if(T===void 0){J.push(`${I}: server "${B}" has neither command nor url; skipped`);return}if(T==="stdio"&&M===void 0){J.push(`${I}: stdio server "${B}" is missing command; skipped`);return}if(T==="http"||T==="sse"){if(Q===void 0){J.push(`${I}: ${T} server "${B}" is missing url; skipped`);return}try{new URL(Q)}catch{J.push(`${I}: ${T} server "${B}" has invalid url "${Q}"; skipped`);return}}let H;if(q.args!==void 0)if(Array.isArray(q.args)&&q.args.every((X)=>typeof X==="string"))H=q.args.map(G);else{J.push(`${I}: server "${B}" has non-string args; skipped`);return}let P;if(O(q.env)){P={};for(let[X,A]of Object.entries(q.env))if(typeof A==="string")P[X]=G(A)}let z;if(O(q.headers)){z={};for(let[X,A]of Object.entries(q.headers))if(typeof A==="string")z[X]=G(A)}let $;if(O(q.oauth)){if($={},typeof q.oauth.clientId==="string"&&q.oauth.clientId.length>0)$.clientId=q.oauth.clientId;if(typeof q.oauth.scope==="string"&&q.oauth.scope.length>0)$.scope=q.oauth.scope;if(Object.keys($).length===0)$=void 0}if(W.length>0){J.push(`${I}: server "${B}" needs ${[...new Set(W)].map((X)=>`\${${X}}`).join(", ")} set in the environment; skipped`);return}let V=v({args:H,env:P,headers:z,url:Q});if(V.length>0&&K.allowPlaceholders!==!0){J.push(`${I}: server "${B}" still has ${V.join(", ")} to fill in; skipped (edit that line and it will connect)`);return}let Y={name:B,transport:T};if(M!==void 0)Y.command=M;if(H!==void 0)Y.args=H;if(P!==void 0)Y.env=P;if(Q!==void 0)Y.url=Q;if(z!==void 0)Y.headers=z;if($!==void 0)Y.oauth=$;if(typeof q.enabled==="boolean")Y.enabled=q.enabled;return Y}function v(B){return[...new Set([...B.args??[],...Object.values(B.env??{}),...Object.values(B.headers??{}),...B.url!==void 0?[B.url]:[]].flatMap((q)=>[...q.matchAll(j)].map((I)=>I[0])))]}function D(B,q,I=process.env,J={}){if(!F(B))return[];let U;try{U=x(B,"utf8")}catch(G){return q.push(`${B}: unreadable (${_(G)}); file skipped`),[]}let K;try{K=JSON.parse(U)}catch(G){return q.push(`${B}: invalid JSON (${_(G)}); file skipped`),[]}if(!O(K))return q.push(`${B}: root is not an object; file skipped`),[];let W=[];if(K.mcpServers!==void 0)if(O(K.mcpServers))for(let[G,M]of Object.entries(K.mcpServers)){let Q=k(G,M,B,q,I,J);if(Q)W.push(Q)}else q.push(`${B}: "mcpServers" is not an object; ignored`);if(K.servers!==void 0)if(Array.isArray(K.servers))for(let G of K.servers){let M=O(G)&&typeof G.name==="string"&&G.name.length>0?G.name:void 0;if(M===void 0){q.push(`${B}: servers[] entry without a name; skipped`);continue}let Q=k(M,G,B,q,I,J);if(Q)W.push(Q)}else q.push(`${B}: "servers" is not an array; ignored`);return W}function m(B,q=[],I={}){let J=b(B,I.home),U=new Map,K=new Proxy({},{get:()=>"set"});for(let[W,G]of[["user",J.user],["harvest",J.harvest],["project",J.project]]){if(G===void 0)continue;if(W!=="user"&&I.trusted!==void 0){let M=N(G);if(M!==void 0&&!I.trusted(G,M)){q.push(y(G,D(G,[],K).length));continue}}for(let M of D(G,q,I.env))U.set(M.name,M)}return[...U.values()]}var S,j;var f=C(()=>{E();S=/\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g,j=/<[^<>]*[a-z][^<>]*>/g});
|
|
3
|
+
export{c as nm,b as om,O as pm,_ as qm,k as rm,v as sm,D as tm,m as um,f as vm};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{Ne as c,Oe as I,Pe as p,Qe as i,Re as a}from"./main-mg9b20ac.js";import{wm as s,xm as d}from"./main-ys6zj3yr.js";s();var w="https://mcp.exa.ai/mcp",U=8,h=20,C=1000,n=500,m=200,r=2000,v=16000,R=1048576,S=5,E=25000,t=`Mozilla/5.0 (compatible; rovecode/${d.version} web_search)`,e="application/json, text/event-stream",zz=new Set([301,302,303,307,308]),Zz=96;function $z($){let z=typeof $==="string"&&$.trim()!==""?Number($):$;return typeof z==="number"&&Number.isFinite(z)&&z>0?Math.min(Math.floor(z),h):U}function k($,z){return $.length<=z?$:$.slice(0,z-1).replace(/[\uD800-\uDBFF]$/,"")+"\u2026"}function T($){let z;try{z=JSON.parse($)}catch{return null}if(!z||typeof z!=="object")return null;let G=z;if(G.error&&typeof G.error==="object"){let J=G.error.message;return{error:typeof J==="string"&&J!==""?J:JSON.stringify(G.error)}}if(!G.result||typeof G.result!=="object")return null;let V=G.result,Z=(Array.isArray(V.content)?V.content:[]).map((J)=>J&&typeof J==="object"?J.text:void 0).find((J)=>typeof J==="string"&&J!=="");if(V.isError===!0)return{error:Z??"backend reported an error without a message"};return Z===void 0?null:{text:Z}}function Gz($){let z=$.trim();if(z.startsWith("{")){let G=T(z);if(G)return G}for(let G of $.split(`
|
|
3
|
+
`)){if(!G.startsWith("data:"))continue;let V=T(G.slice(5).trim());if(V)return V}return null}function u($){let z=[];for(let G of $.split(/\r?\n/)){let V=G.trim();if(V==="")continue;if(V==="..."){if(z.length>0&&z[z.length-1]!=="\u2026")z.push("\u2026");continue}z.push(V)}while(z.length>0&&z[z.length-1]==="\u2026")z.pop();return z.join(" ").replace(/\s+/g," ").trim()}var Jz=/^(Title|URL|Published|Author|Score|ID|Image|Favicon):\s*(.*)$/,Vz=/^(Highlights|Text|Summary):\s*$/;function Wz($){let z=[];for(let G of $.split(/\r?\n\s*---\s*\r?\n/)){let V=G.split(/\r?\n/),K={},Z=0;for(;Z<V.length;Z++){let W=V[Z].trim();if(W===""){if(Object.keys(K).length>0)break;continue}let Q=Jz.exec(W);if(!Q)break;K[Q[1]]=Q[2].trim()}while(Z<V.length&&V[Z].trim()==="")Z++;if(Z<V.length&&Vz.test(V[Z].trim()))Z++;let J=K.URL??"";if(!/^https?:\/\//i.test(J))continue;let Y=K.Published;z.push({title:K.Title||J,url:J,snippet:u(V.slice(Z).join(`
|
|
4
|
+
`)),...Y&&Y.toUpperCase()!=="N/A"?{publishedDate:Y}:{}})}return z}function Kz($){let z;try{z=JSON.parse($)}catch{return null}let G=z&&typeof z==="object"?z.results:void 0;if(!Array.isArray(G))return null;let V=[];for(let K of G){if(!K||typeof K!=="object")continue;let Z=K,J=typeof Z.url==="string"?Z.url:"";if(!/^https?:\/\//i.test(J))continue;let Y=Array.isArray(Z.highlights)?Z.highlights.filter((X)=>typeof X==="string"):[],W=typeof Z.text==="string"?Z.text:Y.length>0?Y.join(`
|
|
5
|
+
...
|
|
6
|
+
`):typeof Z.summary==="string"?Z.summary:"",Q=typeof Z.publishedDate==="string"&&Z.publishedDate!==""?Z.publishedDate:void 0;V.push({title:typeof Z.title==="string"&&Z.title!==""?Z.title:J,url:J,snippet:u(W),...Q?{publishedDate:Q}:{}})}return V}function Qz($){let z=$.trim();if(z===""||/^No search results found/i.test(z))return[];if(z.startsWith("{"))return Kz(z);let G=Wz(z);return G.length>0?G:null}function Xz($,z,G=v){let V=`${z.length} result${z.length===1?"":"s"} for "${k($,m)}" (Exa web search)`,K=z.map((W,Q)=>{let X=`${Q+1}. ${k(W.title.replace(/\s+/g," ").trim(),m)} \xB7 ${k(W.url,r)}${W.publishedDate?` \xB7 ${W.publishedDate}`:""}`,g=k(W.snippet,n);return g===""?X:`${X}
|
|
7
|
+
${g}`}),Z=V,J=0;for(let W of K){if(Z.length+2+W.length+Zz>G)break;Z+=`
|
|
8
|
+
|
|
9
|
+
${W}`,J++}let Y=J<K.length;if(Y)Z+=`
|
|
10
|
+
|
|
11
|
+
(Showing ${J} of ${z.length} results: output capped at ${G} characters.)`;return{output:Z,shown:J,truncated:Y}}function L($){return $.origin+$.pathname}function Bz($={}){let z=$.fetch??((W,Q)=>fetch(W,Q)),G=$.resolve??c,V=typeof $.timeoutMs==="number"&&Number.isFinite($.timeoutMs)&&$.timeoutMs>0?Math.floor($.timeoutMs):E,K=typeof $.apiKey==="string"?$.apiKey.trim():"",Z=K===""?w:`${w}?exaApiKey=${encodeURIComponent(K)}`,J=(W,Q)=>{let X=W.split(Z).join(w).split(Q.href).join(L(Q));if(K!=="")for(let g of new Set([K,encodeURIComponent(K)]))X=X.split(g).join("[key]");return X};async function Y(W,Q){let X=typeof W.query==="string"?W.query.trim():"";if(X==="")return{ok:!1,output:"web_search: query is required"};if(X.length>C)return{ok:!1,output:`web_search: query too long (${X.length} characters; max ${C})`};let g=$z(W.max_results);if(Q.signal.aborted)return{ok:!1,output:"web_search: aborted"};let o=JSON.stringify({jsonrpc:"2.0",id:1,method:"tools/call",params:{name:"web_search_exa",arguments:{query:X,type:"auto",numResults:g,livecrawl:"fallback",contextMaxCharacters:Math.max(1e4,g*1500)}}}),N=new AbortController,x=!1,B=new URL(Z),A=setTimeout(()=>{x=!0,N.abort()},V);A.ref?.();let _=()=>N.abort();Q.signal.addEventListener("abort",_,{once:!0});let P=(q)=>{if(N.signal.aborted)return{ok:!1,output:x?`web_search: timed out after ${V}ms`:"web_search: aborted"};return{ok:!1,output:`web_search: request failed: ${J(q instanceof Error?q.message:String(q),B)}`}};try{let q=I(B.hostname),l=0;for(;;){if(B.protocol!=="http:"&&B.protocol!=="https:")return{ok:!1,output:`web_search: backend redirected to unsupported URL scheme ${B.protocol} (http/https only)`};let b;try{b=await i(p(B.hostname,G),N.signal)}catch(F){return P(F)}if(b!==null)return{ok:!1,output:`web_search: refused ${L(B)}: ${J(b,B)}`};if(I(B.hostname)!==q)return{ok:!1,output:`web_search: backend redirected to ${L(B)} (${I(B.hostname)} is not ${q}); not followed`};let j;try{j=await z(B.href,{method:"POST",redirect:"manual",signal:N.signal,body:o,headers:{"User-Agent":t,Accept:e,"Content-Type":"application/json"}})}catch(F){return P(F)}if(zz.has(j.status)){let F=j.headers.get("location");if(await j.body?.cancel().catch(()=>{}),!F)return{ok:!1,output:`web_search: HTTP ${j.status} redirect from ${L(B)} without a Location header`};if(++l>S)return{ok:!1,output:`web_search: too many redirects (more than ${S}) from ${w}`};try{B=new URL(F,B)}catch{return{ok:!1,output:`web_search: invalid redirect target ${F}`}}continue}let D;try{D=await a(j,j.ok?R:2048)}catch(F){return P(F)}let y=new TextDecoder().decode(D.bytes);if(!j.ok){let F=y.split(/\r?\n/).map((f)=>f.trim()).find((f)=>f!=="")??"";return{ok:!1,output:`web_search: backend HTTP ${j.status}${F===""?"":`: ${k(J(F,B),200)}`}`}}let O=Gz(y);if(O===null)return{ok:!1,output:`web_search: malformed backend response (${D.truncated?`body truncated at ${R} bytes`:`${D.bytes.length} bytes, no JSON-RPC result with text`})`};if("error"in O)return{ok:!1,output:`web_search: backend error: ${k(J(O.error,B).replace(/\s+/g," ").trim(),300)}`};let M=Qz(O.text);if(M===null){let F=O.text.trim(),f=k(F,v);return{ok:!0,output:`web_search "${k(X,m)}": the backend answered in an unrecognized format; shown verbatim${f.length<F.length?` (capped at ${v} characters)`:""}:
|
|
12
|
+
|
|
13
|
+
${f}`,data:{query:X,count:0,total:0,unstructured:!0,truncated:f.length<F.length}}}if(M.length===0)return{ok:!0,output:`No results for "${k(X,m)}" (Exa web search). Try different or fewer terms.`,data:{query:X,count:0,total:0,results:[],truncated:!1}};let H=Xz(X,M.slice(0,g));return{ok:!0,output:H.output,data:{query:X,count:H.shown,total:M.length,results:M.slice(0,H.shown),truncated:H.shown<M.length}}}}finally{clearTimeout(A),Q.signal.removeEventListener("abort",_)}}return{schema:{name:"web_search",description:`Search the web and return up to max_results ranked results (default ${U}, cap ${h}), each as "N. title \xB7 url \xB7 published date (when known)" followed by a snippet of at most ${n} characters; the whole output is capped at ${v} characters (trailing results dropped, with a marker). Results are search snippets, not pages: call web_fetch on a result's url to read it. Backend: Exa via its hosted MCP endpoint (${w}); no API key is required. Times out after ${E/1000}s; a backend that redirects elsewhere or resolves to a private address is refused. The current year is ${new Date().getFullYear()}: put it in queries about recent events.`,args:{type:"object",properties:{query:{type:"string",description:`search query in plain words (at most ${C} characters)`},max_results:{type:"integer",description:`results to return (default ${U}, cap ${h})`}},required:["query"]}},kind:"network",sequential:!1,execute:(W,Q)=>Y(W??{},Q)}}var jz=Bz();
|
|
14
|
+
export{w as Ld,U as Md,h as Nd,C as Od,n as Pd,m as Qd,r as Rd,v as Sd,R as Td,S as Ud,E as Vd,$z as Wd,Gz as Xd,Wz as Yd,Qz as Zd,Xz as _d,Bz as $d,jz as ae};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{wn as e}from"./main-qsevpgsv.js";var t;var s=e(()=>{t={name:"rovecode",version:"0.4.0-beta.2",license:"AGPL-3.0-only",author:"9Code Labs",repository:{type:"git",url:"git+https://github.com/9Code-Labs/rovecode-community.git"},homepage:"https://github.com/9Code-Labs/rovecode-community#readme",description:"Rovecode: a coding agent for the terminal. Research-derived harness on Bun/TypeScript with evidence-based ports from open-source harnesses (sextant TUI, MCP, ACP, headless server, repo-map, shadow-git checkpoints, execpolicy, model routers). The npm tarball ships the minified bundle; this public repository is its AGPL source.",type:"module",module:"./dist/lib/index.js",exports:{".":"./dist/lib/index.js","./extensions":"./dist/lib/public-api.js","./plugins":"./dist/lib/plugins.js","./providers":"./dist/lib/providers.js","./package.json":"./package.json"},bin:{rovecode:"bin/rovecode.js"},files:["bin","dist","README.md","CHANGELOG.md","LICENSE","THIRD_PARTY_NOTICES.md"],engines:{bun:">=1.3.14"},scripts:{build:"bun run scripts/build.ts","build:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --splitting --sourcemap=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')" && bun run smoke:cli && bun run smoke:dist`,"build:npm":"bun run build:npm:cli && bun run build:npm:lib && bun run smoke:npm","build:npm:cli":`bun -e "require('node:fs').rmSync('dist/cli', { recursive: true, force: true })" && bun build --target=bun --minify --splitting --packages=external src/cli/main.ts --outdir dist/cli && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/cli/models-index.json')"`,"build:npm:lib":`bun -e "require('node:fs').rmSync('dist/lib', { recursive: true, force: true })" && bun build --target=bun --minify --packages=external src/index.ts --outfile dist/lib/index.js && bun build --target=bun --minify --packages=external src/public-api.ts --outfile dist/lib/public-api.js && bun build --target=bun --minify --packages=external src/plugins/index.ts --outfile dist/lib/plugins.js && bun build --target=bun --minify --packages=external src/providers/stream.ts --outfile dist/lib/providers.js && bun -e "require('node:fs').copyFileSync('src/providers/models-index.json', 'dist/lib/models-index.json')"`,"smoke:npm":"bun dist/cli/main.js --version && bun dist/cli/main.js smoke-tui --sextant",prepack:"bun run build:npm","smoke:cli":"bun dist/cli/main.js --version","smoke:dist":"bun dist/cli/main.js smoke-tui --sextant",test:"bun test",gauntlet:"bun src/cli/main.ts gauntlet",typecheck:"tsc --noEmit",check:"node scripts/build-model-index.mjs --check && tsc --noEmit && bun test",smoke:"bun src/cli/main.ts smoke-tui --sextant","build:model-index":"node scripts/build-model-index.mjs","check:boundary":"node scripts/check-public-boundary.mjs","check:product-boundary":"node scripts/check-product-boundary.mjs","check:links":"node scripts/check-doc-links.mjs",ci:"bun run check:boundary && bun run check:product-boundary && bun run check:links && bun run typecheck && bun test && bun run build:cli","release:check":"bun run ci && bun run build:npm && npm pack --dry-run","release:stage":"bun run scripts/stage-release.ts","quality:offline":"bun run scripts/harness-quality.ts"},dependencies:{"@ast-grep/napi":"^0.45.3","@modelcontextprotocol/sdk":"^1.30.0","@zed-industries/agent-client-protocol":"^0.4.5",diff:"^9.0.0","get-east-asian-width":"1.6.0","gpt-tokenizer":"^4.0.0",marked:"18.0.11",tokenlens:"^1.3.1"},devDependencies:{"@opencode-ai/models":"^0.0.64","@types/bun":"latest","@xterm/headless":"6.0.0",typescript:"^5.9.3"},bugs:{url:"https://github.com/9Code-Labs/rovecode-community/issues"},publishConfig:{access:"public",provenance:!0,tag:"beta"}}});
|
|
3
|
+
export{s as wm,t as xm};
|