charness 4.1.0 → 4.1.1
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 +23 -0
- package/DEVELOPMENT.md +1 -1
- package/SETUP.md +34 -8
- package/dist/adapters/claudeJsonStreamAdapter.d.ts +60 -5
- package/dist/adapters/claudeJsonStreamAdapter.d.ts.map +1 -1
- package/dist/adapters/claudeJsonStreamAdapter.js +128 -14
- package/dist/adapters/claudeJsonStreamAdapter.js.map +1 -1
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +164 -31
- package/dist/bot.js.map +1 -1
- package/dist/connectors/jira/answerSink.d.ts +8 -0
- package/dist/connectors/jira/answerSink.d.ts.map +1 -1
- package/dist/connectors/jira/answerSink.js +15 -0
- package/dist/connectors/jira/answerSink.js.map +1 -1
- package/dist/connectors/jira/config.d.ts +16 -0
- package/dist/connectors/jira/config.d.ts.map +1 -1
- package/dist/connectors/jira/config.js +21 -2
- package/dist/connectors/jira/config.js.map +1 -1
- package/dist/connectors/jira/connector.d.ts +10 -3
- package/dist/connectors/jira/connector.d.ts.map +1 -1
- package/dist/connectors/jira/connector.js +21 -3
- package/dist/connectors/jira/connector.js.map +1 -1
- package/dist/connectors/jira/inbound.d.ts +200 -18
- package/dist/connectors/jira/inbound.d.ts.map +1 -1
- package/dist/connectors/jira/inbound.js +814 -43
- package/dist/connectors/jira/inbound.js.map +1 -1
- package/dist/connectors/jira/prompt.d.ts +46 -0
- package/dist/connectors/jira/prompt.d.ts.map +1 -1
- package/dist/connectors/jira/prompt.js +123 -15
- package/dist/connectors/jira/prompt.js.map +1 -1
- package/dist/connectors/jira/trigger.d.ts +27 -4
- package/dist/connectors/jira/trigger.d.ts.map +1 -1
- package/dist/connectors/jira/trigger.js +35 -1
- package/dist/connectors/jira/trigger.js.map +1 -1
- package/dist/connectors/jira/triggerLog.d.ts +60 -5
- package/dist/connectors/jira/triggerLog.d.ts.map +1 -1
- package/dist/connectors/jira/triggerLog.js +116 -7
- package/dist/connectors/jira/triggerLog.js.map +1 -1
- package/dist/connectors/telegram/commands/runners.d.ts +28 -1
- package/dist/connectors/telegram/commands/runners.d.ts.map +1 -1
- package/dist/connectors/telegram/commands/runners.js +75 -40
- package/dist/connectors/telegram/commands/runners.js.map +1 -1
- package/dist/connectors/telegram/sendOutcome.d.ts +3 -1
- package/dist/connectors/telegram/sendOutcome.d.ts.map +1 -1
- package/dist/connectors/telegram/sendOutcome.js.map +1 -1
- package/dist/connectors/telegram/telegramFailureRetry.d.ts +8 -0
- package/dist/connectors/telegram/telegramFailureRetry.d.ts.map +1 -1
- package/dist/connectors/telegram/telegramFailureRetry.js +8 -0
- package/dist/connectors/telegram/telegramFailureRetry.js.map +1 -1
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/de.js +4 -0
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +4 -0
- package/dist/i18n/en.js.map +1 -1
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/es.js +4 -0
- package/dist/i18n/es.js.map +1 -1
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +4 -0
- package/dist/i18n/fr.js.map +1 -1
- package/dist/i18n/hi.d.ts.map +1 -1
- package/dist/i18n/hi.js +4 -0
- package/dist/i18n/hi.js.map +1 -1
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ja.js +4 -0
- package/dist/i18n/ja.js.map +1 -1
- package/dist/i18n/ka.d.ts.map +1 -1
- package/dist/i18n/ka.js +4 -0
- package/dist/i18n/ka.js.map +1 -1
- package/dist/i18n/pt.d.ts.map +1 -1
- package/dist/i18n/pt.js +4 -0
- package/dist/i18n/pt.js.map +1 -1
- package/dist/i18n/ru.d.ts.map +1 -1
- package/dist/i18n/ru.js +4 -0
- package/dist/i18n/ru.js.map +1 -1
- package/dist/i18n/uk.d.ts.map +1 -1
- package/dist/i18n/uk.js +4 -0
- package/dist/i18n/uk.js.map +1 -1
- package/dist/i18n/uz.d.ts.map +1 -1
- package/dist/i18n/uz.js +4 -0
- package/dist/i18n/uz.js.map +1 -1
- package/dist/i18n/zh.d.ts.map +1 -1
- package/dist/i18n/zh.js +4 -0
- package/dist/i18n/zh.js.map +1 -1
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +2 -1
- package/dist/i18n.js.map +1 -1
- package/dist/requests/requestHeader.d.ts.map +1 -1
- package/dist/requests/requestHeader.js +1 -0
- package/dist/requests/requestHeader.js.map +1 -1
- package/dist/requests/types.d.ts +4 -1
- package/dist/requests/types.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.d.ts +31 -1
- package/dist/requests/wakeUpEngine.d.ts.map +1 -1
- package/dist/requests/wakeUpEngine.js +94 -2
- package/dist/requests/wakeUpEngine.js.map +1 -1
- package/dist/requests/wakeUpRules.d.ts +7 -0
- package/dist/requests/wakeUpRules.d.ts.map +1 -1
- package/dist/requests/wakeUpRules.js +14 -0
- package/dist/requests/wakeUpRules.js.map +1 -1
- package/dist/scheduler/engine.d.ts +17 -4
- package/dist/scheduler/engine.d.ts.map +1 -1
- package/dist/scheduler/engine.js +55 -10
- package/dist/scheduler/engine.js.map +1 -1
- package/dist/scheduler/mcpBoot.d.ts +6 -2
- package/dist/scheduler/mcpBoot.d.ts.map +1 -1
- package/dist/scheduler/mcpBoot.js +7 -1
- package/dist/scheduler/mcpBoot.js.map +1 -1
- package/dist/scheduler/mcpSurface.d.ts.map +1 -1
- package/dist/scheduler/mcpSurface.js +18 -9
- package/dist/scheduler/mcpSurface.js.map +1 -1
- package/dist/sendErrorClassifier.d.ts +6 -0
- package/dist/sendErrorClassifier.d.ts.map +1 -1
- package/dist/sendErrorClassifier.js +9 -0
- package/dist/sendErrorClassifier.js.map +1 -1
- package/dist/startupPromptBuffer.d.ts +8 -8
- package/dist/startupPromptBuffer.d.ts.map +1 -1
- package/dist/startupPromptBuffer.js +7 -5
- package/dist/startupPromptBuffer.js.map +1 -1
- package/dist/testTimings.d.ts +3 -2
- package/dist/testTimings.d.ts.map +1 -1
- package/dist/testTimings.js +3 -1
- package/dist/testTimings.js.map +1 -1
- package/dist/threadRouting.d.ts +23 -0
- package/dist/threadRouting.d.ts.map +1 -1
- package/dist/threadRouting.js +28 -0
- package/dist/threadRouting.js.map +1 -1
- package/dist/trackers/taskAgentSlots.d.ts +42 -3
- package/dist/trackers/taskAgentSlots.d.ts.map +1 -1
- package/dist/trackers/taskAgentSlots.js +31 -11
- package/dist/trackers/taskAgentSlots.js.map +1 -1
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/fileSendPlan.d.ts +30 -8
- package/dist/utils/fileSendPlan.d.ts.map +1 -1
- package/dist/utils/fileSendPlan.js +37 -12
- package/dist/utils/fileSendPlan.js.map +1 -1
- package/dist/utils/fileSendService.d.ts +1 -1
- package/dist/utils/fileSendService.d.ts.map +1 -1
- package/dist/utils/fileSendService.js +9 -1
- package/dist/utils/fileSendService.js.map +1 -1
- package/dist/utils/imageDimensions.d.ts +32 -0
- package/dist/utils/imageDimensions.d.ts.map +1 -0
- package/dist/utils/imageDimensions.js +181 -0
- package/dist/utils/imageDimensions.js.map +1 -0
- package/dist/utils/jsonStreamHost.d.ts +35 -9
- package/dist/utils/jsonStreamHost.d.ts.map +1 -1
- package/dist/utils/jsonStreamHost.js +59 -16
- package/dist/utils/jsonStreamHost.js.map +1 -1
- package/dist/utils/lostWork.d.ts +8 -2
- package/dist/utils/lostWork.d.ts.map +1 -1
- package/dist/utils/lostWork.js +9 -5
- package/dist/utils/lostWork.js.map +1 -1
- package/dist/utils/promptDelivery.d.ts +11 -2
- package/dist/utils/promptDelivery.d.ts.map +1 -1
- package/dist/utils/promptDelivery.js +3 -3
- package/dist/utils/promptDelivery.js.map +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.1.1 — 2026-11-17
|
|
6
|
+
|
|
7
|
+
**The pairing line of `/runners` — a secret that lets whoever holds it pair a machine to your host — now comes to you in a private message from the bot, no longer in General, where every member of the group could read it.**
|
|
8
|
+
Before, **+ Pair a new runner** posted the line in General, readable by anyone in the group (topic talkers included) for the ten minutes it lives. Now the bot sends it to the admin who tapped the button (or typed the address it asked for) in that admin's private chat with the bot, as the same message — the explanation, the line, the row that picks how many jobs the new machine runs at once — and General gets one plain line that names who got it — «The pairing line was sent to <their first name> in a private message.» (their @username, or «you», if Telegram gave no first name) — so an admin who asked but did not get the line, because another admin used the address they were offered, looks in the right chat. The row works in that chat (a tap there is accepted from a group admin because the chat is theirs, also when they are not the owner and the bot serves no private chat of theirs), and the message turns into «paired» or «expired» there as it did in General. An admin who never opened a private chat with the bot (Telegram refuses with 403), or who blocked it, gets the line in General as before, after a line that says to open a private chat with the bot — named by its @username — and press Start so the next one comes privately; any other failure to send it still closes the code. The owner who runs `/runners` in their own private chat with the bot has the line right there, with no note. Pairing messages recorded by an earlier version still turn into «paired» or «expired».
|
|
9
|
+
|
|
10
|
+
**A screenshot or picture bigger than 2560 pixels on its longest side now reaches you as a file at full resolution, not as a photo Telegram has shrunk.**
|
|
11
|
+
Telegram keeps a photo at its own size only up to 2560 px on the longest side and shrinks anything bigger to that (measured on the live bot: a 3840 × 2160 screenshot arrived as 2560 × 1440, a 1000 × 6000 one as 427 × 2560), and it re-encodes every photo as JPEG. When the agent sends an image with `send_file_to_user` or `send_messages_to_user`, the bot now reads its size from the file header: an image up to 2560 px stays an inline photo, a bigger one goes as a document, the original file. The same goes for an image Telegram would refuse as a photo (a side ratio over 20) and for one whose size cannot be read. In an album one such image makes the whole album documents, and the agent's tool texts now say so; `as_file: true` still sends any image as a file, which the tool texts suggest for a small image whose text must stay crisp.
|
|
12
|
+
|
|
13
|
+
**After a restart the bot no longer stops receiving your Telegram messages while an agent waits for your answer and a scheduled run was missed.**
|
|
14
|
+
Before, a scheduled run (a heartbeat, or a check that fails and wakes its agent) missed while the bot was down was replayed one run after another when the bot started, and the start waited for each delivery before it began listening to Telegram. A run bound to a topic whose agent was mid-turn — waiting for your answer to its pinned question — waits for that agent (up to 10 minutes each), and your answer could not arrive because the bot was not listening yet: no topic got a message until the waits ran out, and the same again at every restart. Now the start only begins the catch-ups and goes on: the bot listens at once, your answer reaches the agent, and each missed run is still delivered once, as soon as its agent is free. The catch-ups of different topics no longer wait for one another either (those of one topic still go one after another, so an agent is never handed two runs together), and a stuck one no longer keeps the jobs stored after it from being armed.
|
|
15
|
+
|
|
16
|
+
**A Jira comment written while the AI works on an issue now reaches its agent — the issue no longer has to be unassigned and assigned again to get a word through.**
|
|
17
|
+
Before, a comment on an issue already handed to the AI account (assigned to it in one of its trigger statuses) never reached the agent: a comment was no trigger at all, and an @-mention by the person who had handed the issue over was recorded as «covered» with nothing posted — the agent finished the work it had and never saw «also move it to Done». Now, with a `trustedGroup`, every poll reads the new comments of a handed issue, and a trusted person's comment (author and last editor trusted; an app's or an automation's comment — a build notice, a rule — still rides the next prompt) reaches the agent: while a hand-over request is open, as an issue update of that request — no new request, the turn it is in ends first, the one hand-back stays — and when no request is open but the issue is still the AI's, as a request of its own whose answer goes to the commenter. A comment made while the bot was down is still delivered, once: the bot remembers the newest comment each prompt was built from, so a restart, a compaction or a fresh session never delivers an old comment again. An outsider's comment is recorded and ignored, its text withheld as before. If the work finished before the comment got to the agent — also when its answer handed the issue back before the bot's next look — it still gets it, and its answer becomes a comment. A comment on an issue the AI took up itself goes to the request that is working on it — on that issue (a mention it acts on), or on an issue linked to it (one it created and builds in another issue's run, say; when several linked issues are at work, the one the AI itself linked it to) — and never opens a second agent. The answer to that work is a comment on its own issue, so the AI answers the commenter on the commented issue with a comment of its own there, mentioning them. On an issue NOT handed to the AI only an @-mention reaches it; a follow-up mention by the person whose mention it is acting on goes into that work. As a guard against an account that comments as the agent's own tools (each comment would come back as the next update), an issue gets at most 20 updates in 24 hours: past that, new comments wait until the oldest of them is a day old and reach the AI then — a follow-up @-mention too, also after a restart — and the issue says so in one comment, at most once a day. The agent must comment only as the AI account. The new `jira.json` key `wakeOnComment` turns it off (`false`); absent, it is on wherever `trustedGroup` is set, and `true` without a group refuses the start. See SETUP.md, «Jira setup».
|
|
18
|
+
|
|
19
|
+
**A Jira mention can now ask the AI to do things, not only to answer: with `"mentionMode": "act"` in `jira.json`, a trusted person's explicit ask in an @-mention — create or split issues, take a transition, change the assignee, take up the work — is carried out, whatever the issue's status and assignee.**
|
|
20
|
+
Before, the prompt of every mention told the agent to change nothing (no code, no commits, no Jira edits) and to answer that the issue had to be assigned to it first. Now, in act mode, the note says to do what the comment explicitly asks as the agent's own rules allow, and to answer a question only with an answer; a hand-over the agent is working on goes on. Once the AI took the issue up (assigned it to itself), a later comment reaches the acting mention's work; while the issue is not handed to it, only a follow-up @-mention does — by the same person it goes into that work. An acting mention counts as one of the bot's task agents (it waits in the same queue, with the same comment, when all are busy — and keeps its place past the mention window and across a restart), and its answer is a comment that hands nothing back. `"answer"` (the default) keeps the answer-only mentions; `"act"` without a `trustedGroup` refuses the start, and the start logs which mode is on.
|
|
21
|
+
|
|
22
|
+
**A Jira request whose agent was cut off by a restart is resumed at once — no longer after the 90-minute backstop.**
|
|
23
|
+
Before, when charness came back (a redeploy, a crash) and an issue's agent process had not survived, the open request waited until nothing had been seen working on it for 90 minutes; only then did the bot wake the session — a container recreated mid-build cost an hour and a half of work on every issue in flight. A process that died with its own background work pending got a note that waited for the same backstop. Now the boot wakes every such open request right away — 30 seconds apart, so several agents do not start at once — with a reminder that the session was resumed (or the request's prompt again, when the agent never read it), and the lost-work note rides that wake. A request that waits for something of its own (a retry, a follow-up after a progress note, a usage-limit wait) is left to it; a conversation woken this way less than 10 minutes ago is left to the backstop, so a crash loop never becomes a wake loop. A Jira agent that crashes while the bot keeps running, with no background work pending, still waits for the backstop. Telegram topics keep their own resume, with one change: a note about lost background work that the agent was not told yet now also rides a reminder the bot sends about an open request, not only the next message.
|
|
24
|
+
|
|
25
|
+
**A prompt the Claude agent never received is no longer counted as delivered: a write into the agent's input that fails now fails the post, which is retried — and a slow-starting agent is waited for up to two minutes instead of five seconds.**
|
|
26
|
+
Before, a resumed Claude session that was still starting could leave its input full for more than five seconds; the write then gave up with `EAGAIN`, the error was only logged, and the bot believed the prompt delivered — a Jira hand-over seen this way was never read by its agent (and a long prompt could be left half-written, breaking the next one). Now a prompt to an agent that was just started waits until the agent shows it reads its input (it answers the start handshake, or writes anything), and the write then waits for as long as the agent keeps reading, giving up only after two minutes without a byte read. A write that fails makes the post fail — also when the prompt waited for the session to start — and a Jira request gets its usual retries (about 1, 5 and 15 minutes later). In a Telegram topic your own message (text, voice, a file, an album, and what was held back during a usage-limit wait when it goes to the next session) no longer waits for the write — a reminder, a scheduled run or a retry the bot sends still does: the topic stays responsive (`/esc` included), and if the write of your message fails the topic says «⚠️ The agent did not get your last message … Send it again.» (every language; an album's prompt that fails says the same instead of «failed to download the file»). A prompt left half-written is never followed by another in the same process: the process is stopped (killed if the stop fails) and the conversation resumes in a fresh one with the next prompt; the same prompt torn twice is logged loudly.
|
|
27
|
+
|
|
5
28
|
## 4.1.0 — 2026-11-16
|
|
6
29
|
|
|
7
30
|
**A «🔧 tool» status line is no longer left under a reply that was already posted, or under a question the agent asked.**
|
package/DEVELOPMENT.md
CHANGED
|
@@ -182,7 +182,7 @@ A flow does not wait out the production windows in real time: its env file sets
|
|
|
182
182
|
of named overrides (`src/testTimings.ts`: `telegramSendIntervalMs` — the global send pacer's 2 s, `telegramSendOperationDeadlineMs` — a send
|
|
183
183
|
queue call's 30 s deadline, `jiraPollIntervalMs` —
|
|
184
184
|
below the 10 s floor of `jira.json`, `requestTurnPollMs` — the wake-up engine's 10 s poll of the turns it watches,
|
|
185
|
-
`requestSweepIntervalMs` and `requestFirstPostRetryDelayMs` — the wake-up engine's minutes, `limitProbeDelayMs` — the two-minute probe of an unconfirmed usage limit, `stateSaveDebounceMs` — `state.json`'s
|
|
185
|
+
`requestSweepIntervalMs` and `requestFirstPostRetryDelayMs` — the wake-up engine's minutes, `requestRestartWakeStaggerMs` — the 30 s between the wakes of tracker requests whose process a boot found gone, `limitProbeDelayMs` — the two-minute probe of an unconfirmed usage limit, `stateSaveDebounceMs` — `state.json`'s
|
|
186
186
|
500 ms save debounce, `openCodeServerUpBudgetMs` — the OpenCode server's 60 s of retries, `backgroundHoldMaxMs` — the 6 h the
|
|
187
187
|
agent's own pending work holds a json-stream process, `adoptedTailFirstReadMs` — the 300 ms from the boot's release of an
|
|
188
188
|
adopted json-stream session to the first read of its output, `todoReminderPollMs` and `todoReminderIntervalMs` — the todo
|
package/SETUP.md
CHANGED
|
@@ -284,7 +284,7 @@ your chosen providers need them.
|
|
|
284
284
|
| `SCHEDULER_MCP_PORT` | an OS-chosen free loopback port | You need a stable, explicitly chosen port; it must differ from this instance's `OPENCODE_URL` port |
|
|
285
285
|
| `CLAUDE_SCRAPE_DEBUG` | off | You are debugging Claude tmux scraping (the deprecated tmux backend) and need full RAW/FILTERED chunks |
|
|
286
286
|
| `AGENT_IDLE_MINUTES` | `55` | A json-stream Claude topic idle for this long is compacted (when `/compact_on_idle` allows) and its process stopped; the session sleeps and the next message resumes it — shorten it only for a test; a non-positive or non-numeric value keeps the default |
|
|
287
|
-
| `REQUEST_BACKSTOP_MINUTES` | `90` | A request (a Jira hand-over, a message in an answers-only topic) with nothing seen working on it for this long is re-posted to its session — shorten it only for a test; a non-positive or non-numeric value keeps the default |
|
|
287
|
+
| `REQUEST_BACKSTOP_MINUTES` | `90` | A request (a Jira hand-over, a message in an answers-only topic) with nothing seen working on it for this long is re-posted to its session — shorten it only for a test; a non-positive or non-numeric value keeps the default. A Jira request whose agent process a restart (or a crash with its own work pending) left behind does not wait for it: it is resumed at once, 30 s apart per issue |
|
|
288
288
|
| `TMUX_SOCKET_NAME` | — (the default tmux server) | The instance must run its agents on its OWN tmux server (`tmux -L <name>`; any plain name except `default`). Recommended for a second instance on one host: at boot an instance kills every agent session on its server that its own state does not know |
|
|
289
289
|
| `ENV_FILE` | — | Absolute path of the ONLY env file to read — no `~/.config/charness/.env`, no `$PWD/.env`; its values win over the inherited environment. Set it in the launching environment, never inside an env file (the start refuses that). `scripts/run-isolated.sh <env-file>` (in a checkout) starts an instance with a clean environment plus this variable |
|
|
290
290
|
| `CONNECTORS` | `telegram` | Experimental: the surfaces this instance serves, as a comma list — see [Jira setup](#jira-setup). An instance that lists `jira` refuses to start on Node below 22.12 and without `ENV_FILE`, `TMUX_SOCKET_NAME` and `DATA_DIR/jira.json`, and — with Telegram off — with a `TELEGRAM_BOT_TOKEN` or any `ATLASSIAN_*` variable in its environment. Any instance refuses to start on a `DATA_DIR` that holds conversations of a surface it does not serve |
|
|
@@ -400,7 +400,7 @@ had run locally. Without a runner nothing changes for anyone, and agents are not
|
|
|
400
400
|
**Pair it (the normal way).** Needs this machine's ordinary `sshd` (key login on) with an address the runner can reach — nothing else is
|
|
401
401
|
opened or changed, no root, no VPN — and on the runner machine `ssh`, `tar`, `curl` or `wget`, and a way to reach nodejs.org (no Node.js needed: the pairing installs the runner its own). In General send `/runners` → **+ Pair a new
|
|
402
402
|
runner**; the first time the bot asks which address runners dial (the `runnerHost` row of the [instance settings](#instance-settings-settingsjson)) and
|
|
403
|
-
proposes the public address it finds. It
|
|
403
|
+
proposes the public address it finds. It sends ONE line (valid 10 minutes, single use) with the words that explain it — to you in a private message of the bot, not into General, which the whole group reads (open a private chat with the bot and press Start first, or the line is posted in General): pasted in an admin account's terminal
|
|
404
404
|
on the runner machine it pairs a standard user there (`runner` unless you change the last word of the line) and installs its always-on service
|
|
405
405
|
in one go; without admin rights, the same line run from the terminal of that account itself (without its leading `sudo`, its last word being that
|
|
406
406
|
account's name) pairs it only, with `charness-runner service install` afterwards to keep it running. An
|
|
@@ -801,6 +801,8 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
|
|
|
801
801
|
"trustedGroup": "ai-trusted",
|
|
802
802
|
"trustedApps": ["<an app account's id>"],
|
|
803
803
|
"wakeOnMention": true,
|
|
804
|
+
"mentionMode": "answer",
|
|
805
|
+
"wakeOnComment": true,
|
|
804
806
|
"pollIntervalSeconds": 30,
|
|
805
807
|
"runBudgetPer24h": 5,
|
|
806
808
|
"model": "opus",
|
|
@@ -836,9 +838,31 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
|
|
|
836
838
|
`trustedGroup` the key is refused — without a group everyone is trusted anyway. A listed id adds no trust
|
|
837
839
|
to a person's account: people stay trusted by membership alone.
|
|
838
840
|
|
|
839
|
-
`wakeOnMention` (optional) decides whether an @-mention of the AI account in a comment wakes it
|
|
840
|
-
|
|
841
|
-
|
|
841
|
+
`wakeOnMention` (optional) decides whether an @-mention of the AI account in a comment wakes it, without the
|
|
842
|
+
issue being handed over; absent, it is on exactly when `trustedGroup` is set, and `true` without a group is
|
|
843
|
+
refused — without one, anyone who can comment could start the AI.
|
|
844
|
+
|
|
845
|
+
`mentionMode` (optional, needs `trustedGroup` for `"act"`) decides what such a mention asks of the agent:
|
|
846
|
+
`"answer"` (the default) — an answer only, it changes nothing; `"act"` — when a trusted person's comment
|
|
847
|
+
explicitly asks it to do something (create or split issues, take a transition, change the assignee, take up the
|
|
848
|
+
work), it does it as its own rules allow, whatever the issue's status and assignee, and a question is still only
|
|
849
|
+
answered. An acting mention counts as a task agent (see below) and still hands nothing back. The agent's rules
|
|
850
|
+
(its project's `CLAUDE.md`) decide what it may do; the start logs which mode is on.
|
|
851
|
+
|
|
852
|
+
`wakeOnComment` (optional) decides whether a comment on an issue HANDED to the AI — assigned to it in one of its
|
|
853
|
+
trigger statuses — reaches the agent: a comment by a trusted person (not an app's or an automation's) while the
|
|
854
|
+
AI works on the issue is added to that work at the end of its current step, and one written after it finished,
|
|
855
|
+
while the issue is still assigned to it, starts a new request — and one written while it worked that reaches it only
|
|
856
|
+
after its answer handed the issue back still gets to it, answered by a comment. Absent, it is on exactly when
|
|
857
|
+
`trustedGroup` is set; `true` without a group is refused; `false` keeps the old behaviour, where such a comment
|
|
858
|
+
reached the agent only with its next hand-over. The start logs which. **The agent must comment only as the AI
|
|
859
|
+
account** (the `answer_request` tool does): a comment it writes in Jira under any other account of the trusted group —
|
|
860
|
+
an operator's token in its own tools, say — comes back to it as a person's comment, and then its answer, and so on.
|
|
861
|
+
As a guard, an issue gets at most 20 such updates in 24 hours; past that, new comments wait until the oldest update
|
|
862
|
+
is a day old and reach the agent then, and one line goes to the log saying until when. The issue gets one comment
|
|
863
|
+
from the AI saying so, at most once a day: comments that keep coming wait again the same way without another one.
|
|
864
|
+
A comment on an issue the AI created or took up while working on ANOTHER issue goes to that work; the AI answers
|
|
865
|
+
its author on the commented issue with a comment of its own.
|
|
842
866
|
|
|
843
867
|
`projects` maps each served project key to its folder under `WORK_ROOT` and the status names in which an
|
|
844
868
|
assigned issue is a request; the agent loads that folder's project memory (`CLAUDE.md`, `.claude/`, … in it
|
|
@@ -860,8 +884,9 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
|
|
|
860
884
|
**How many agents run at once.** The AI works on at most 5 issues at the same time, all projects together — set
|
|
861
885
|
`taskAgents.maxConcurrent` in [`settings.json`](#instance-settings-settingsjson) (`0` = no limit; read without a
|
|
862
886
|
restart). An issue handed over beyond that gets one comment saying it is queued, stays assigned to the AI and starts by
|
|
863
|
-
itself when an agent hands its issue back, the one that waited longest first — also across a restart.
|
|
864
|
-
|
|
887
|
+
itself when an agent hands its issue back, the one that waited longest first — also across a restart. A comment that
|
|
888
|
+
starts a request and an acting mention (`mentionMode: "act"`) wait the same way; an @-mention that only answers is never
|
|
889
|
+
held back, and a lower number never stops an agent that is already working.
|
|
865
890
|
|
|
866
891
|
5. Start it with a clean environment, so nothing of the calling shell reaches it:
|
|
867
892
|
|
|
@@ -874,7 +899,8 @@ connector behaves is described in [`src/connectors/jira/README.md`](src/connecto
|
|
|
874
899
|
The start refuses a missing `ENV_FILE`, `TMUX_SOCKET_NAME` or `jira.json`, an `OPENCODE_URL` on the default
|
|
875
900
|
port, a `TELEGRAM_BOT_TOKEN` or any `ATLASSIAN_*` variable when Telegram is off, a token that belongs to
|
|
876
901
|
another account, an unknown project or status, a `trustedGroup` the site does not have or the AI account
|
|
877
|
-
may not read, a `trustedApps
|
|
902
|
+
may not read, a `trustedApps`, a `wakeOnComment: true` or a `mentionMode: "act"` without a `trustedGroup`, and a
|
|
903
|
+
`DATA_DIR` holding another surface's state. An unreachable Jira does not refuse the start —
|
|
878
904
|
polling backs off and resumes.
|
|
879
905
|
|
|
880
906
|
The agent sessions of a Jira instance run without the user-level Claude settings, hooks and skills, with the
|
|
@@ -4,7 +4,7 @@ import type { SessionKey } from '../sessionKey';
|
|
|
4
4
|
import type { ClaudeConfigDirApplyResult, ClaudeConfigDirReader, ClaudeRateLimitSink, ClaudeTurnCostSink } from './claudeConfigDir';
|
|
5
5
|
import { ClaudeStreamLineReader } from '../utils/claudeStreamJson';
|
|
6
6
|
import { type McpHealOutcome } from '../utils/claudeMcpHeal';
|
|
7
|
-
import { type JsonStreamSessionPaths, type StdoutTailState } from '../utils/jsonStreamHost';
|
|
7
|
+
import { writeFifoText, type JsonStreamSessionPaths, type StdoutTailState } from '../utils/jsonStreamHost';
|
|
8
8
|
import { type SessionLaunchDefaultsReader } from './sessionLaunchDefaults';
|
|
9
9
|
import { type LostWork } from '../utils/lostWork';
|
|
10
10
|
import { type ScheduledJob } from '../utils/claudeScheduledJobs';
|
|
@@ -60,6 +60,19 @@ export interface StreamSession {
|
|
|
60
60
|
fifoFd: number;
|
|
61
61
|
/** Serialises FIFO writes so control frames and user turns keep wire order. */
|
|
62
62
|
stdinWriteChain: Promise<void>;
|
|
63
|
+
/**
|
|
64
|
+
* A frame was left half-written in the stdin FIFO (its reader stopped taking bytes mid-frame): whatever is written
|
|
65
|
+
* after it would be read as the rest of that line, so nothing is — every later write fails at once, and the process
|
|
66
|
+
* is suspended so the conversation's next trigger resumes it in a fresh one.
|
|
67
|
+
*/
|
|
68
|
+
isStdinBroken: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* The CLI has shown that it reads its stdin: it answered the initialize handshake, or wrote any output. A freshly
|
|
71
|
+
* spawned (resumed) CLI may read nothing for a long while — seen live: the handshake timed out after 15 s and the
|
|
72
|
+
* first prompt met a full FIFO 5 s later — so a user turn waits for this before it is written (see
|
|
73
|
+
* {@link ClaudeJsonStreamAdapter.waitForReadingInput}). Always set for an adopted process: it has been reading.
|
|
74
|
+
*/
|
|
75
|
+
isReadingInput: boolean;
|
|
63
76
|
/** `stdout.jsonl` tail bookkeeping (byte offsets + stateful utf8 decode). */
|
|
64
77
|
tail: StdoutTailState;
|
|
65
78
|
pollTimer: NodeJS.Timeout | null;
|
|
@@ -264,9 +277,15 @@ export declare class ClaudeJsonStreamAdapter extends EventEmitter implements Age
|
|
|
264
277
|
readonly lifecycle: JsonStreamLifecycle;
|
|
265
278
|
/** How long the agent's own pending work holds the process after its last turn (`utils/jsonStreamPendingWork.ts`). */
|
|
266
279
|
private pendingWorkHoldMs;
|
|
280
|
+
/**
|
|
281
|
+
* `writeFifo` replaces the stdin FIFO write (tests only: a reader that stalls or stops mid-frame cannot be made
|
|
282
|
+
* portably with a real pipe).
|
|
283
|
+
*/
|
|
267
284
|
constructor(options?: {
|
|
268
285
|
lifecycle: JsonStreamLifecycle;
|
|
269
286
|
backgroundHoldMs?: number;
|
|
287
|
+
writeFifo?: typeof writeFifoText;
|
|
288
|
+
stdinStallTimeoutMs?: number;
|
|
270
289
|
});
|
|
271
290
|
/** Emits incremental text deltas (like the tmux scrape) → the transports
|
|
272
291
|
* synthesise continuation (`getDmDraftContinuation` / group delta path). */
|
|
@@ -275,6 +294,14 @@ export declare class ClaudeJsonStreamAdapter extends EventEmitter implements Age
|
|
|
275
294
|
readonly selfGreetsOnStart = false;
|
|
276
295
|
private readonly sessions;
|
|
277
296
|
private readonly claudePath;
|
|
297
|
+
private readonly writeFifo;
|
|
298
|
+
/** How long a user turn waits for a CLI that reads nothing, and a write for a reader that takes nothing (tests shorten it). */
|
|
299
|
+
private readonly stdinStallTimeoutMs;
|
|
300
|
+
/**
|
|
301
|
+
* How often each user prompt was left half-written, by conversation and the request it names (else its text): a second tear
|
|
302
|
+
* of the same request's prompt — a re-post may be rebuilt with other text — is logged loudly. Dropped once one of its writes lands.
|
|
303
|
+
*/
|
|
304
|
+
private readonly tornPromptCounts;
|
|
278
305
|
private displayPrefsReader;
|
|
279
306
|
private seenWatermarkWriter;
|
|
280
307
|
private jsonStreamTailWriter;
|
|
@@ -520,15 +547,43 @@ export declare class ClaudeJsonStreamAdapter extends EventEmitter implements Age
|
|
|
520
547
|
*/
|
|
521
548
|
getLatestCompactionSummary(key: SessionKey): Promise<string | null>;
|
|
522
549
|
sendInput(key: SessionKey, input: string): void;
|
|
550
|
+
/**
|
|
551
|
+
* @description {@link sendInput} that resolves once the user turn is written WHOLE into the CLI's stdin, and rejects
|
|
552
|
+
* when it could not be (`EAGAIN` past the stall budget, a dead reader, a broken stream): the prompt never reached the
|
|
553
|
+
* agent, and its caller is told so instead of believing it delivered. The state a turn start sets is set before the
|
|
554
|
+
* first await, as `sendInput` always did; a write that failed takes back its unconsumed-input count, and the busy flag
|
|
555
|
+
* when nothing of the CLI was seen since. A session that is not active drops the input, as before (logged).
|
|
556
|
+
*/
|
|
557
|
+
sendInputAndWait(key: SessionKey, input: string): Promise<void>;
|
|
523
558
|
sendSignal(key: SessionKey, _signal: string): void;
|
|
524
559
|
sendEscape(key: SessionKey): void;
|
|
525
560
|
private sendInterrupt;
|
|
526
|
-
/** Write one user turn, counting it until Claude echoes it back (it has read it). */
|
|
561
|
+
/** Write one user turn, counting it until Claude echoes it back (it has read it); settles as its write does. */
|
|
527
562
|
private writeUserMessage;
|
|
528
|
-
/**
|
|
529
|
-
*
|
|
530
|
-
*
|
|
563
|
+
/**
|
|
564
|
+
* Enqueue one stream-json frame onto the stdin FIFO. The per-session chain keeps wire order and waits out a full
|
|
565
|
+
* buffer (see `writeFifoText`); the returned promise is THIS frame's write — it resolves once the frame is written
|
|
566
|
+
* whole and rejects when it is not (logged here, so a caller may leave it: the chain's own handler keeps it from being
|
|
567
|
+
* an unhandled rejection). A frame left half-written breaks the stream: see {@link StreamSession.isStdinBroken}.
|
|
568
|
+
*/
|
|
531
569
|
private writeStdin;
|
|
570
|
+
/**
|
|
571
|
+
* Hold a user turn until the CLI shows it reads its stdin ({@link StreamSession.isReadingInput}). After the stall budget
|
|
572
|
+
* the turn is written anyway — a CLI that never answers the handshake must still get its prompts — and the write then
|
|
573
|
+
* has the budget of its own; a stop under way ends the wait (nothing was written).
|
|
574
|
+
*/
|
|
575
|
+
private waitForReadingInput;
|
|
576
|
+
/**
|
|
577
|
+
* A user prompt was left half-written. Counted per conversation and text: the same prompt torn again means the CLI
|
|
578
|
+
* keeps stopping mid-prompt on every retry — said loudly, while the prompt stays pending with its request's retries.
|
|
579
|
+
*/
|
|
580
|
+
private noteTornPrompt;
|
|
581
|
+
/**
|
|
582
|
+
* A frame was left half-written: nothing more is written into the stream, and the process is suspended — the
|
|
583
|
+
* conversation keeps its id and its next trigger resumes it in a fresh process, with a stdin of its own. A suspend that
|
|
584
|
+
* fails must not leave a live process nobody can write to: it is killed, and the tail poll's exit check ends the session.
|
|
585
|
+
*/
|
|
586
|
+
private breakStdin;
|
|
532
587
|
private onStdout;
|
|
533
588
|
private applyStdoutLines;
|
|
534
589
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claudeJsonStreamAdapter.d.ts","sourceRoot":"","sources":["../../src/adapters/claudeJsonStreamAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEtC,OAAO,KAAK,EACV,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAEhB,gBAAgB,EAChB,kBAAkB,EAClB,gBAAgB,EAChB,WAAW,EACX,oBAAoB,EACpB,oBAAoB,EACpB,gBAA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AE,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAoB1H,wGAAwG;IACxG,OAAO,CAAC,2BAA2B;IAWnC,OAAO,CAAC,WAAW;CAqBpB"}
|
|
@@ -91,6 +91,15 @@ exports.claudeJsonStreamUsageLogPrefix = '[ClaudeJson] usage ';
|
|
|
91
91
|
/** How long to wait for the `initialize` control-response handshake before
|
|
92
92
|
* proceeding without the interactive control channel (questions unavailable). */
|
|
93
93
|
const initializeHandshakeTimeoutMs = 15000;
|
|
94
|
+
/** The first request id a prompt names (its header, or a reminder's): what a re-post with rebuilt text has in common. */
|
|
95
|
+
const promptRequestIdRe = /\breq_[A-Za-z0-9_-]+/;
|
|
96
|
+
/** The key of a prompt in the torn-prompt counts: its conversation and the request it names, else its text. */
|
|
97
|
+
function getTornPromptKey(session, text) {
|
|
98
|
+
const requestId = promptRequestIdRe.exec(text)?.[0];
|
|
99
|
+
return `${(0, sessionKey_1.keyToString)(session.key)}\u0000${requestId ?? (0, crypto_1.createHash)('sha256').update(text).digest('hex')}`;
|
|
100
|
+
}
|
|
101
|
+
/** How often a user turn held for a CLI that does not read yet looks again (`waitForReadingInput`). */
|
|
102
|
+
const readingInputPollMs = 100;
|
|
94
103
|
/** Whether an adopted session's live state is not rebuilt yet: held until the boot's release, or replaying its downtime tail. */
|
|
95
104
|
function checkIsSessionReplayPending(session) {
|
|
96
105
|
return session.isTailHeld || session.adoptCatchUpOffset !== null;
|
|
@@ -144,10 +153,16 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
144
153
|
lifecycle;
|
|
145
154
|
/** How long the agent's own pending work holds the process after its last turn (`utils/jsonStreamPendingWork.ts`). */
|
|
146
155
|
pendingWorkHoldMs;
|
|
156
|
+
/**
|
|
157
|
+
* `writeFifo` replaces the stdin FIFO write (tests only: a reader that stalls or stops mid-frame cannot be made
|
|
158
|
+
* portably with a real pipe).
|
|
159
|
+
*/
|
|
147
160
|
constructor(options = { lifecycle: 'idle' }) {
|
|
148
161
|
super();
|
|
149
162
|
this.lifecycle = options.lifecycle;
|
|
150
163
|
this.pendingWorkHoldMs = options.backgroundHoldMs ?? jsonStreamPendingWork_1.pendingWorkHoldDefaultMs;
|
|
164
|
+
this.writeFifo = options.writeFifo ?? jsonStreamHost_1.writeFifoText;
|
|
165
|
+
this.stdinStallTimeoutMs = options.stdinStallTimeoutMs ?? jsonStreamHost_1.fifoWriteStallTimeoutMs;
|
|
151
166
|
this.name = options.lifecycle === 'perTurn' ? adapterNames_1.claudePerTurnAdapterName : adapterNames_1.claudeJsonStreamAdapterName;
|
|
152
167
|
this.label = options.lifecycle === 'perTurn' ? 'Claude Code (per-turn)' : 'Claude Code (stream)';
|
|
153
168
|
}
|
|
@@ -158,6 +173,14 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
158
173
|
selfGreetsOnStart = false;
|
|
159
174
|
sessions = new Map();
|
|
160
175
|
claudePath = (0, resolveBinary_1.resolveClaudeBinary)();
|
|
176
|
+
writeFifo;
|
|
177
|
+
/** How long a user turn waits for a CLI that reads nothing, and a write for a reader that takes nothing (tests shorten it). */
|
|
178
|
+
stdinStallTimeoutMs;
|
|
179
|
+
/**
|
|
180
|
+
* How often each user prompt was left half-written, by conversation and the request it names (else its text): a second tear
|
|
181
|
+
* of the same request's prompt — a re-post may be rebuilt with other text — is logged loudly. Dropped once one of its writes lands.
|
|
182
|
+
*/
|
|
183
|
+
tornPromptCounts = new Map();
|
|
161
184
|
displayPrefsReader = null;
|
|
162
185
|
seenWatermarkWriter = null;
|
|
163
186
|
jsonStreamTailWriter = null;
|
|
@@ -349,7 +372,7 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
349
372
|
const session = {
|
|
350
373
|
key, workDir, sessionId,
|
|
351
374
|
pid, paths, fifoFd,
|
|
352
|
-
stdinWriteChain: Promise.resolve(),
|
|
375
|
+
stdinWriteChain: Promise.resolve(), isStdinBroken: false, isReadingInput: false,
|
|
353
376
|
tail: (0, jsonStreamHost_1.createStdoutTailState)(0),
|
|
354
377
|
pollTimer: null, pollDelayMs: pollBackoff_1.basePollIntervalMs, unchangedStreak: 0,
|
|
355
378
|
isOversizeWarned: false, lastPersistedTailOffset: 0,
|
|
@@ -686,7 +709,7 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
686
709
|
const session = {
|
|
687
710
|
key, workDir, sessionId: claudeSessionId,
|
|
688
711
|
pid, paths, fifoFd,
|
|
689
|
-
stdinWriteChain: Promise.resolve(),
|
|
712
|
+
stdinWriteChain: Promise.resolve(), isStdinBroken: false, isReadingInput: true,
|
|
690
713
|
tail: (0, jsonStreamHost_1.createStdoutTailState)(startOffset),
|
|
691
714
|
pollTimer: null, pollDelayMs: pollBackoff_1.basePollIntervalMs, unchangedStreak: 0,
|
|
692
715
|
isOversizeWarned: false, lastPersistedTailOffset: startOffset,
|
|
@@ -1164,11 +1187,23 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
1164
1187
|
// Input (S3)
|
|
1165
1188
|
// ─────────────────────────────────────────────────────────────────────────
|
|
1166
1189
|
sendInput(key, input) {
|
|
1190
|
+
// A failed write is logged by the write itself; a caller that must know awaits `sendInputAndWait`.
|
|
1191
|
+
void this.sendInputAndWait(key, input).catch(() => { });
|
|
1192
|
+
}
|
|
1193
|
+
/**
|
|
1194
|
+
* @description {@link sendInput} that resolves once the user turn is written WHOLE into the CLI's stdin, and rejects
|
|
1195
|
+
* when it could not be (`EAGAIN` past the stall budget, a dead reader, a broken stream): the prompt never reached the
|
|
1196
|
+
* agent, and its caller is told so instead of believing it delivered. The state a turn start sets is set before the
|
|
1197
|
+
* first await, as `sendInput` always did; a write that failed takes back its unconsumed-input count, and the busy flag
|
|
1198
|
+
* when nothing of the CLI was seen since. A session that is not active drops the input, as before (logged).
|
|
1199
|
+
*/
|
|
1200
|
+
sendInputAndWait(key, input) {
|
|
1167
1201
|
const session = this.sessions.get((0, sessionKey_1.keyToString)(key));
|
|
1168
1202
|
if (!session?.isActive) {
|
|
1169
1203
|
console.warn(`[ClaudeJson] sendInput to inactive session ${(0, sessionKey_1.keyToString)(key)} dropped`);
|
|
1170
|
-
return;
|
|
1204
|
+
return Promise.resolve();
|
|
1171
1205
|
}
|
|
1206
|
+
const wasBusy = session.isBusy;
|
|
1172
1207
|
// A fresh user turn begins → reset the answer cursor so its first tail is a
|
|
1173
1208
|
// new message (the bot also flips `needsNewMessage` for delta adapters).
|
|
1174
1209
|
session.currentResponseText = '';
|
|
@@ -1178,11 +1213,18 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
1178
1213
|
// A fresh turn resets the idle-watchdog clock: without this a session that
|
|
1179
1214
|
// sat idle for minutes (busy=false, clock stale) would trip the watchdog on
|
|
1180
1215
|
// its very next poll — before claude has a chance to emit the first token.
|
|
1181
|
-
|
|
1216
|
+
const turnStartedAt = Date.now();
|
|
1217
|
+
session.lastStdoutActivityAt = turnStartedAt;
|
|
1182
1218
|
// The turn in flight is persisted at once (same offset, flipped flag): a restart
|
|
1183
1219
|
// during a long, silent tool call finds no frame after the offset to rebuild it.
|
|
1184
1220
|
this.jsonStreamTailWriter?.(key, buildTailRecord(session, session.lastPersistedTailOffset));
|
|
1185
|
-
this.writeUserMessage(session, input)
|
|
1221
|
+
return this.writeUserMessage(session, input).catch((error) => {
|
|
1222
|
+
// Nothing of this turn reached the CLI: it is not owed an echo, and — unless the CLI showed life since — it is as busy as it was.
|
|
1223
|
+
session.unconsumedInputCount = Math.max(0, session.unconsumedInputCount - 1);
|
|
1224
|
+
if (session.lastStdoutActivityAt === turnStartedAt)
|
|
1225
|
+
session.isBusy = wasBusy;
|
|
1226
|
+
throw error;
|
|
1227
|
+
});
|
|
1186
1228
|
}
|
|
1187
1229
|
sendSignal(key, _signal) {
|
|
1188
1230
|
this.sendInterrupt(key);
|
|
@@ -1213,21 +1255,90 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
1213
1255
|
// and any bare `/esc` mid-turn). Consumed by the next `handleTurnEnd`.
|
|
1214
1256
|
session.swallowNextAbortError = true;
|
|
1215
1257
|
}
|
|
1216
|
-
/** Write one user turn, counting it until Claude echoes it back (it has read it). */
|
|
1258
|
+
/** Write one user turn, counting it until Claude echoes it back (it has read it); settles as its write does. */
|
|
1217
1259
|
writeUserMessage(session, content) {
|
|
1218
1260
|
session.unconsumedInputCount += 1;
|
|
1219
|
-
this.writeStdin(session, { type: 'user', message: { role: 'user', content } });
|
|
1261
|
+
return this.writeStdin(session, { type: 'user', message: { role: 'user', content } }, { userText: content });
|
|
1220
1262
|
}
|
|
1221
|
-
/**
|
|
1222
|
-
*
|
|
1223
|
-
*
|
|
1224
|
-
|
|
1263
|
+
/**
|
|
1264
|
+
* Enqueue one stream-json frame onto the stdin FIFO. The per-session chain keeps wire order and waits out a full
|
|
1265
|
+
* buffer (see `writeFifoText`); the returned promise is THIS frame's write — it resolves once the frame is written
|
|
1266
|
+
* whole and rejects when it is not (logged here, so a caller may leave it: the chain's own handler keeps it from being
|
|
1267
|
+
* an unhandled rejection). A frame left half-written breaks the stream: see {@link StreamSession.isStdinBroken}.
|
|
1268
|
+
*/
|
|
1269
|
+
writeStdin(session, obj, options = {}) {
|
|
1225
1270
|
const line = JSON.stringify(obj) + '\n';
|
|
1226
|
-
session.
|
|
1227
|
-
|
|
1228
|
-
|
|
1271
|
+
const checkIsAbandoned = () => session.isStopping || !session.isActive;
|
|
1272
|
+
const write = session.stdinWriteChain.then(async () => {
|
|
1273
|
+
if (session.isStdinBroken)
|
|
1274
|
+
throw new Error('the stdin stream is broken: a frame before this one was left half-written');
|
|
1275
|
+
// A user turn waits for a CLI that reads: written into a FIFO nobody drains, a big prompt is left half-written.
|
|
1276
|
+
if (options.userText !== undefined)
|
|
1277
|
+
await this.waitForReadingInput(session, checkIsAbandoned);
|
|
1278
|
+
return this.writeFifo(session.fifoFd, line, { checkIsAbandoned, stallTimeoutMs: this.stdinStallTimeoutMs });
|
|
1279
|
+
});
|
|
1280
|
+
if (options.userText !== undefined) {
|
|
1281
|
+
const promptKey = getTornPromptKey(session, options.userText);
|
|
1282
|
+
void write.then(() => this.tornPromptCounts.delete(promptKey), () => { });
|
|
1283
|
+
}
|
|
1284
|
+
session.stdinWriteChain = write.catch((e) => {
|
|
1285
|
+
console.error(`[ClaudeJson] stdin write failed for ${(0, sessionKey_1.keyToString)(session.key)}:`, e instanceof Error ? e.message : e);
|
|
1286
|
+
if (e instanceof jsonStreamHost_1.FifoWriteError && e.isTorn && !session.isStopping && session.isActive) {
|
|
1287
|
+
if (options.userText !== undefined)
|
|
1288
|
+
this.noteTornPrompt(session, options.userText);
|
|
1289
|
+
this.breakStdin(session);
|
|
1290
|
+
}
|
|
1291
|
+
});
|
|
1229
1292
|
// New input → output expected shortly; snap the tail poll back to base.
|
|
1230
1293
|
this.snapPollToBase(session);
|
|
1294
|
+
return write;
|
|
1295
|
+
}
|
|
1296
|
+
/**
|
|
1297
|
+
* Hold a user turn until the CLI shows it reads its stdin ({@link StreamSession.isReadingInput}). After the stall budget
|
|
1298
|
+
* the turn is written anyway — a CLI that never answers the handshake must still get its prompts — and the write then
|
|
1299
|
+
* has the budget of its own; a stop under way ends the wait (nothing was written).
|
|
1300
|
+
*/
|
|
1301
|
+
async waitForReadingInput(session, checkIsAbandoned) {
|
|
1302
|
+
const startedAt = Date.now();
|
|
1303
|
+
while (!session.isReadingInput) {
|
|
1304
|
+
if (checkIsAbandoned())
|
|
1305
|
+
throw new jsonStreamHost_1.FifoWriteError('the write was abandoned: the process is being stopped', 0, 1);
|
|
1306
|
+
if (Date.now() - startedAt >= this.stdinStallTimeoutMs) {
|
|
1307
|
+
console.warn(`[ClaudeJson] ${(0, sessionKey_1.keyToString)(session.key)}: the CLI showed no sign of reading its input for ${Math.round(this.stdinStallTimeoutMs / 1000)} s (no handshake answer, no output); the prompt is written anyway`);
|
|
1308
|
+
return;
|
|
1309
|
+
}
|
|
1310
|
+
await new Promise((resolve) => setTimeout(resolve, readingInputPollMs));
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* A user prompt was left half-written. Counted per conversation and text: the same prompt torn again means the CLI
|
|
1315
|
+
* keeps stopping mid-prompt on every retry — said loudly, while the prompt stays pending with its request's retries.
|
|
1316
|
+
*/
|
|
1317
|
+
noteTornPrompt(session, text) {
|
|
1318
|
+
const promptKey = getTornPromptKey(session, text);
|
|
1319
|
+
const count = (this.tornPromptCounts.get(promptKey) ?? 0) + 1;
|
|
1320
|
+
this.tornPromptCounts.set(promptKey, count);
|
|
1321
|
+
if (count >= 2) {
|
|
1322
|
+
console.error(`[ClaudeJson] ${(0, sessionKey_1.keyToString)(session.key)}: the SAME prompt (${text.length} chars) was left half-written ${count} times: its CLI stops reading its input in the middle of it. It stays pending — its request keeps its retries — but it will not get through until that is fixed`);
|
|
1323
|
+
}
|
|
1324
|
+
}
|
|
1325
|
+
/**
|
|
1326
|
+
* A frame was left half-written: nothing more is written into the stream, and the process is suspended — the
|
|
1327
|
+
* conversation keeps its id and its next trigger resumes it in a fresh process, with a stdin of its own. A suspend that
|
|
1328
|
+
* fails must not leave a live process nobody can write to: it is killed, and the tail poll's exit check ends the session.
|
|
1329
|
+
*/
|
|
1330
|
+
breakStdin(session) {
|
|
1331
|
+
session.isStdinBroken = true;
|
|
1332
|
+
console.error(`[ClaudeJson] ${(0, sessionKey_1.keyToString)(session.key)}: a stdin frame was left half-written; nothing more is written to this process, it is suspended and its next prompt resumes the conversation`);
|
|
1333
|
+
void this.suspendSession(session.key).catch((e) => {
|
|
1334
|
+
console.warn(`[ClaudeJson] suspending ${(0, sessionKey_1.keyToString)(session.key)} after its broken stdin failed (${e instanceof Error ? e.message : String(e)}); killing its process`);
|
|
1335
|
+
try {
|
|
1336
|
+
process.kill(session.pid, 'SIGKILL');
|
|
1337
|
+
}
|
|
1338
|
+
catch {
|
|
1339
|
+
// Gone already: the tail poll's exit check finds that too.
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1231
1342
|
}
|
|
1232
1343
|
// ─────────────────────────────────────────────────────────────────────────
|
|
1233
1344
|
// Output parsing (S2) + control channel (S4)
|
|
@@ -1251,6 +1362,8 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
1251
1362
|
const msg = (0, claudeStreamJson_1.parseStreamJsonLine)(line);
|
|
1252
1363
|
if (!msg)
|
|
1253
1364
|
continue;
|
|
1365
|
+
// Any output: the CLI is up, and a user turn held for it may be written.
|
|
1366
|
+
session.isReadingInput = true;
|
|
1254
1367
|
for (const action of (0, claudeStreamJson_1.classifyClaudeStreamMessage)(msg)) {
|
|
1255
1368
|
this.applyAction(session, action);
|
|
1256
1369
|
}
|
|
@@ -1278,6 +1391,7 @@ class ClaudeJsonStreamAdapter extends events_1.EventEmitter {
|
|
|
1278
1391
|
*/
|
|
1279
1392
|
handleControlResponse(session, action) {
|
|
1280
1393
|
if (session.pendingInitResolve && action.requestId === session.initRequestId) {
|
|
1394
|
+
session.isReadingInput = true;
|
|
1281
1395
|
session.pendingInitResolve();
|
|
1282
1396
|
return;
|
|
1283
1397
|
}
|