Repository navigation
fix(server): 遅いWebSocket接続でPTY出力をバイト上限で遮断 - #41
Open
yukihamada wants to merge 6 commits into
Open
yukihamada wants to merge 6 commits into
yukihamada wants to merge 6 commits into
Conversation
Adopt the agent-first CLI convention from block/buzz so a caller can branch
on the exit code alone without parsing human-readable output.
- src/cli/exit-code.ts: 0 success / 1 user / 2 network / 3 auth / 4 other /
5 conflict, plus exitCodeForError() mapping named and tagged errors onto it
- run.ts: replace 10 undifferentiated process.exit(1) calls with classified
codes; auth failures now exit 3 so callers stop retrying in a loop
- run.ts: --format json now keeps stdout a pure event stream and emits every
warning (unknown agent, share URL, auto-rejected permission) to stderr as a
structured {type:diagnostic} record instead of ANSI-styled prose
- error records carry exitCode so a consumer reads the classification from the
stream as well as from the process status
Verified: 9/9 unit tests, 30/30 turbo typecheck, oxlint 0 errors, and
measured exit=1 with pure-JSON stderr across the usage-error paths.
Subprocess tests remain failing in this environment on the base commit too
(SENTE_CONFIG in the ambient shell overrides SENTE_CONFIG_CONTENT), so the
new end-to-end assertions were dropped rather than left red.
The contract landed in `sente run` (86d041f) but `sente tui` still used bare `process.exitCode = 1`. All five sites are pre-launch argument validation (--replay, --mini with network flags, unsupported --mini-only options, --fork without a session, and worker connection failure), so all five are ExitCode.User — the classification is unchanged, but it is now stated instead of implied, and a future change cannot silently drift. TUI remains interactive: it does not gain --format json, so no structured output is added here. Verified: 30/30 turbo typecheck, oxlint 0 errors, measured exit=1 for --replay and --fork, and no new failures against the baseline.
…dicate The launcher already used 75 (SENTE_RESTART_EXIT_CODE) for the TUI's "compact and resume" request, but it was invisible to the contract — a supervisor reading exit-code.ts would have classified it as Other and retried it like a transient failure. - ExitCode.Restart = 75, deliberately outside 0-5 so it cannot collide - shouldRestart(code): true only for Network(2), Other(4) and Restart(75). Permanent failures (User 1, Auth 3, Conflict 5) return false. The predicate exists because launchd KeepAlive restarts on any exit: a bad flag or an expired key becomes an infinite loop. That is not hypothetical — it burned ~4.3M credits over three days in 2026-09. Verified: 14/14 unit tests including the KeepAlive cases, 30/30 typecheck.
…gh release (the manual Sente distribution recipe) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
高級モデルは1ターンで数千〜数万クレジットを消費しうる。残高が尽きると
推論が止まり Sente が黙るため、**モデルを選ぶ直前**に気づけるようにした。
- util/credits.ts を追加
- creditsRemaining(): provider 層が last-route.json へ退避した
x-teai-credits-remaining を読む。ファイル無し/破損/非数値は null
- isPremiumModel(): cost.output が閾値(15)を超えるモデルを高級と判定。
cost 不明なモデルは誤検知を避けるため false
- LOW_CREDITS_THRESHOLD = 10_000cr
- context/local.tsx の model.set() と model.cycle() に警告を接続
(/models からの選択と Fキー循環の両経路をカバー)
残高不明な場合は何も出さない — 推測でユーザーの選択を邪魔しないため。
検証: bun typecheck クリーン / bun test 206 pass 0 fail
クライアントが読み切れない間もPTY出力を溜め込みメモリを圧迫し得たため、 未送信バイト数に上限を設け、超過時は安全に切断する。 回帰テスト3件で固定。
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
クライアントが読み切れない間もPTY出力を溜め込みメモリを圧迫し得たため、未送信バイト数に上限を設け、超過時は安全に切断する。
検証: 回帰テスト3件・型検査成功(ローカル実施)