@shumkov/orchestra 0.10.12 → 0.10.14
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.
|
@@ -384,8 +384,8 @@ mcp.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
|
384
384
|
'than flattened. Canonical use: send a plan as `- [ ] step` items, then edit ' +
|
|
385
385
|
'that same message_id with the WHOLE list again and `- [x]` on completed ' +
|
|
386
386
|
'steps — check items off as you go and the user watches one bubble update, ' +
|
|
387
|
-
'and one final time when the work ends, every item resolved and
|
|
388
|
-
'
|
|
387
|
+
'and one final time when the work ends, every item resolved and nothing ' +
|
|
388
|
+
'left bold. ' +
|
|
389
389
|
'Also fine for a short one-line status. An edit REPLACES the body, so always ' +
|
|
390
390
|
're-send the full text. An edit is TEXT-ONLY: image markdown degrades to its ' +
|
|
391
391
|
'caption and cannot add media to a bubble (send media with `reply(files:)`). ' +
|
|
@@ -1038,24 +1038,25 @@ class CliProcess extends Process {
|
|
|
1038
1038
|
' watches ONE message fill in, live.',
|
|
1039
1039
|
'4. Always re-send the WHOLE list — an edit REPLACES the body, so a partial',
|
|
1040
1040
|
' re-send loses everything you left out.',
|
|
1041
|
-
'5. Mark the item you are working on RIGHT NOW
|
|
1042
|
-
' `- [ ]
|
|
1043
|
-
'
|
|
1044
|
-
'
|
|
1045
|
-
'
|
|
1041
|
+
'5. Mark the item you are working on RIGHT NOW by making its text BOLD:',
|
|
1042
|
+
' `- [ ] **Проверяю конфиги…**` — the whole item text wrapped in `**`.',
|
|
1043
|
+
' Exactly one item is bold at a time; when the item completes it becomes',
|
|
1044
|
+
' plain `- [x]` and the bold moves to the next one. The user sees at a',
|
|
1045
|
+
' glance what is happening right now.',
|
|
1046
1046
|
'6. Delivering the final answer COMPLETES the last step, so CLOSE THE',
|
|
1047
1047
|
' CHECKLIST OUT: immediately after that final `reply`, edit that same',
|
|
1048
1048
|
' `message_id` one last time, ticking every remaining item and removing',
|
|
1049
|
-
' the
|
|
1050
|
-
' a lingering
|
|
1049
|
+
' the bold. Its final state is all `- [x]`, nothing bold. A turn that',
|
|
1050
|
+
' ends with a lingering bold item on the checklist is a CONTRACT',
|
|
1051
|
+
' VIOLATION — the user is',
|
|
1051
1052
|
' left looking at work that reads as abandoned one item from the end,',
|
|
1052
1053
|
' however good the answer was.',
|
|
1053
1054
|
' But NEVER tick an item you did not actually complete — a false `- [x]`',
|
|
1054
1055
|
' is worse than an unfinished list. When work stops early — a step fails,',
|
|
1055
1056
|
' is skipped, turns out to be blocked — the close-out edit still happens:',
|
|
1056
|
-
' remove the
|
|
1057
|
+
' remove the bold, leave that item unticked, and name the reason ON its',
|
|
1057
1058
|
' line, e.g. `- [ ] Деплой — заблокировано: нет доступа к VPS`. The',
|
|
1058
|
-
' lingering
|
|
1059
|
+
' lingering bold is the violation; an honestly labelled unfinished item',
|
|
1059
1060
|
' is not.',
|
|
1060
1061
|
'',
|
|
1061
1062
|
'HARD RULE — a checkbox is a COMMITMENT, not decoration, and this applies to',
|
|
@@ -1838,6 +1838,7 @@ class ProcessManager {
|
|
|
1838
1838
|
*/
|
|
1839
1839
|
_wireCallbacks(proc) {
|
|
1840
1840
|
const capturedGeneration = proc.generationId ?? null;
|
|
1841
|
+
let abnormalTerminationReported = false;
|
|
1841
1842
|
const hasCapturedGeneration = () => (
|
|
1842
1843
|
capturedGeneration == null
|
|
1843
1844
|
|| proc.generationId === capturedGeneration
|
|
@@ -1847,6 +1848,39 @@ class ProcessManager {
|
|
|
1847
1848
|
&& !this._retiring.has(proc)
|
|
1848
1849
|
&& hasCapturedGeneration()
|
|
1849
1850
|
);
|
|
1851
|
+
const reportAbnormalTermination = (event, exitCode = null) => {
|
|
1852
|
+
const verifiedSafeCodexStartupRelease = (
|
|
1853
|
+
event === 'close'
|
|
1854
|
+
&& this._isCodex(proc)
|
|
1855
|
+
&& this._starting.has(proc.sessionKey)
|
|
1856
|
+
&& proc.startupReleaseSafe === true
|
|
1857
|
+
&& proc.closed === true
|
|
1858
|
+
&& proc.state === 'Closed'
|
|
1859
|
+
);
|
|
1860
|
+
if (
|
|
1861
|
+
abnormalTerminationReported
|
|
1862
|
+
|| verifiedSafeCodexStartupRelease
|
|
1863
|
+
|| this._shuttingDown
|
|
1864
|
+
|| this._retiring.has(proc)
|
|
1865
|
+
|| (this._retirementIntents.get(proc.sessionKey) ?? 0) > 0
|
|
1866
|
+
|| !isCurrentGeneration()
|
|
1867
|
+
) return;
|
|
1868
|
+
abnormalTerminationReported = true;
|
|
1869
|
+
const callback = this.callbacks.onAbnormalTermination;
|
|
1870
|
+
if (typeof callback !== 'function') return;
|
|
1871
|
+
const evidence = Object.freeze({
|
|
1872
|
+
event,
|
|
1873
|
+
backend: proc.backend,
|
|
1874
|
+
generationId: capturedGeneration,
|
|
1875
|
+
exitCode: Number.isSafeInteger(exitCode) ? exitCode : null,
|
|
1876
|
+
});
|
|
1877
|
+
try { callback(proc.sessionKey, evidence, proc); }
|
|
1878
|
+
catch (error) {
|
|
1879
|
+
this.logger.error?.(
|
|
1880
|
+
`[pm:${proc.label}] onAbnormalTermination threw: ${error.message}`,
|
|
1881
|
+
);
|
|
1882
|
+
}
|
|
1883
|
+
};
|
|
1850
1884
|
for (const [cbName, eventName] of Object.entries(CALLBACK_TO_EVENT)) {
|
|
1851
1885
|
const fn = this.callbacks[cbName];
|
|
1852
1886
|
if (typeof fn !== 'function') continue;
|
|
@@ -1914,6 +1948,7 @@ class ProcessManager {
|
|
|
1914
1948
|
// 'close': process closed itself (iteration loop exited or
|
|
1915
1949
|
// _closeQuery returned). Remove from the Map + signal LRU.
|
|
1916
1950
|
proc.on('close', (...args) => {
|
|
1951
|
+
reportAbnormalTermination('close', args[0]);
|
|
1917
1952
|
if (!this._isCodex(proc)) {
|
|
1918
1953
|
if (
|
|
1919
1954
|
!this._retiring.has(proc)
|
|
@@ -1980,6 +2015,7 @@ class ProcessManager {
|
|
|
1980
2015
|
// We don't re-spawn proactively: an idle disconnected session shouldn't
|
|
1981
2016
|
// burn LRU budget. Lazy respawn on next message is the right shape.
|
|
1982
2017
|
proc.on('bridge-disconnected', () => {
|
|
2018
|
+
reportAbnormalTermination('bridge-disconnected');
|
|
1983
2019
|
this.logger.warn?.(`[pm:${proc.label}] channels bridge disconnected — killing dead instance for lazy respawn`);
|
|
1984
2020
|
// Serialize with start/replacement/kill. Re-check object identity after
|
|
1985
2021
|
// the gate so a late disconnect from an old generation cannot kill its
|
|
@@ -248,6 +248,7 @@ class SdkProcess extends Process {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
async _runIteration() {
|
|
251
|
+
let closeEmitted = false;
|
|
251
252
|
try {
|
|
252
253
|
for await (const msg of this.query) {
|
|
253
254
|
await this._handleEvent(msg);
|
|
@@ -256,9 +257,12 @@ class SdkProcess extends Process {
|
|
|
256
257
|
} catch (err) {
|
|
257
258
|
this._failAllPendings(err);
|
|
258
259
|
this.emit('close', err.code === 'AbortError' ? 0 : 1);
|
|
260
|
+
closeEmitted = true;
|
|
259
261
|
} finally {
|
|
262
|
+
const alreadyClosed = this.closed;
|
|
260
263
|
this.closed = true;
|
|
261
264
|
this.inFlight = false;
|
|
265
|
+
if (!closeEmitted && !alreadyClosed) this.emit('close', 0);
|
|
262
266
|
this.emit('idle');
|
|
263
267
|
}
|
|
264
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shumkov/orchestra",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.14",
|
|
4
4
|
"description": "Transport-agnostic session engine for Claude Code and the native Codex app-server: spawn, steer, supervise, observe turns, and recover.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "index.js",
|