@commonlyai/cli 0.1.292 → 0.1.294
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/package.json
CHANGED
|
@@ -879,7 +879,7 @@ const publicWitnessError = ({ code, tool, error }) => {
|
|
|
879
879
|
? `Commonly MCP server ${tool} was not shown connected`
|
|
880
880
|
: `Commonly tool ${tool} failed in a way the model must not narrate`;
|
|
881
881
|
const failure = new Error(
|
|
882
|
-
`public seat withheld this turn's reply: ${what} (${reason}), so
|
|
882
|
+
`public seat withheld this turn's reply: ${what} (${reason}), so the CLI posted no reply for it (posts the agent made through its tools stay) and the CLI does not ack the event (one the agent already checkpointed stays acked)`,
|
|
883
883
|
);
|
|
884
884
|
failure.code = code;
|
|
885
885
|
return failure;
|
|
@@ -816,7 +816,7 @@ const publicToolFailedError = ({ tool, error }) => {
|
|
|
816
816
|
const reason = String(error).replace(/\s+/g, ' ').slice(0, 160) || '(empty error)';
|
|
817
817
|
const failure = new Error(
|
|
818
818
|
`public seat withheld this turn's reply: Commonly tool ${tool} failed in a way the model must not narrate `
|
|
819
|
-
+ `(${reason}), so
|
|
819
|
+
+ `(${reason}), so the CLI posted no reply for it (posts the agent made through its tools stay) and the CLI does not ack the event (one the agent already checkpointed stays acked)`,
|
|
820
820
|
);
|
|
821
821
|
failure.code = PUBLIC_TOOL_FAILED_CODE;
|
|
822
822
|
return failure;
|
package/src/lib/adapters/pi.js
CHANGED
|
@@ -56,6 +56,7 @@ import {
|
|
|
56
56
|
import { fileURLToPath } from 'url';
|
|
57
57
|
import {
|
|
58
58
|
adapterFailure,
|
|
59
|
+
describeUpstreamRefusal,
|
|
59
60
|
readUpstreamRefusal,
|
|
60
61
|
spawnCredentials,
|
|
61
62
|
} from '../upstream-refusal.js';
|
|
@@ -552,22 +553,27 @@ export const extractReply = (stdout) => {
|
|
|
552
553
|
if (event?.type === 'agent_end') finished = event.willRetry !== true && lastStop === 'stop';
|
|
553
554
|
if (event?.type === 'error') errors.push(String(event.message || event.error || 'error'));
|
|
554
555
|
}
|
|
555
|
-
return { text, sawAssistant, finished, errors };
|
|
556
|
+
return { text, sawAssistant, finished, lastStop, errors };
|
|
556
557
|
};
|
|
557
558
|
|
|
558
559
|
// A turn that printed an interim message and then ended without finishing. A
|
|
559
560
|
// crash keeps its cause, so a quota line in stderr or a refusal on the stream
|
|
560
561
|
// still classifies. A signal (143, 129, or a null code) has neither: stderr then
|
|
561
562
|
// holds pi's startup warnings, and a refusal on the stream may be one pi was
|
|
562
|
-
// recovering from, like an overflow's 400.
|
|
563
|
+
// recovering from, like an overflow's 400. A clean exit that ended on an error
|
|
564
|
+
// has only the stream: its stderr is those warnings too, and the refusal stands.
|
|
563
565
|
const stoppedTurnFailure = (reply, {
|
|
564
566
|
code, signal, stderr, credentials,
|
|
565
567
|
}) => {
|
|
566
568
|
const killed = Boolean(signal) || code === 143 || code === 129;
|
|
569
|
+
const cleanExit = code === 0;
|
|
567
570
|
const upstream = killed ? null : reply.upstream;
|
|
568
571
|
const failure = adapterFailure(
|
|
569
572
|
'pi',
|
|
570
|
-
reply.errors.join(' | ')
|
|
573
|
+
reply.errors.join(' | ')
|
|
574
|
+
|| (cleanExit ? describeUpstreamRefusal(upstream) : '')
|
|
575
|
+
|| (killed || cleanExit ? '' : stderr.trim().slice(-600))
|
|
576
|
+
|| upstream?.detail
|
|
571
577
|
|| 'the turn stopped before it finished',
|
|
572
578
|
{ credentials, exitCode: code, limit: 600 },
|
|
573
579
|
);
|
|
@@ -668,6 +674,14 @@ const runPi = ({
|
|
|
668
674
|
const tail = (reply.errors.join(' | ') || stderr).trim().slice(-600);
|
|
669
675
|
return reject(new Error(`pi exited ${code}: ${tail}`));
|
|
670
676
|
}
|
|
677
|
+
// A refused turn exits 0 too, so here the stream is what says the text was
|
|
678
|
+
// interim. Posting it would answer with half a turn (F258). The last stop
|
|
679
|
+
// decides, not `reply.upstream`, which outlives a refusal pi recovered from.
|
|
680
|
+
if (code === 0 && reply.sawAssistant && !reply.finished && reply.lastStop === 'error') {
|
|
681
|
+
return reject(stoppedTurnFailure(reply, {
|
|
682
|
+
code, signal, stderr, credentials,
|
|
683
|
+
}));
|
|
684
|
+
}
|
|
671
685
|
return resolve(reply);
|
|
672
686
|
});
|
|
673
687
|
});
|