@tangle-network/agent-app 3.0.27 → 3.0.28
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/dist/chat-routes/index.js +5 -1
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/sandbox-producer.d.ts +6 -0
- package/dist/{chunk-5OE6SCHS.js → chunk-4XFPMDIM.js} +15 -4
- package/dist/{chunk-5OE6SCHS.js.map → chunk-4XFPMDIM.js.map} +1 -1
- package/dist/public-consultation/index.js +1 -1
- package/dist/turn-health/index.js +2 -1
- package/dist/turn-health/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -182,5 +182,11 @@ export declare function providerRetryNotice(event: {
|
|
|
182
182
|
}): string | undefined;
|
|
183
183
|
/** A terminal provider wait (`…, reset at <ISO>`, agent-container provider-retry-wait.ts) as one sentence. */
|
|
184
184
|
export declare function providerResetSentence(message: string): string | undefined;
|
|
185
|
+
/** The typed code for a harness whose model refused its key, so a product can tell it from other stream failures. */
|
|
186
|
+
export declare const MODEL_KEY_REFUSED_CODE = "model.key_refused";
|
|
187
|
+
/** A harness whose model provider refused its key ("Invalid API key", OpenCode's `OPENCODE_ERROR`) as plain words, true
|
|
188
|
+
* both for a newly started box whose harness called the model before its minted key was in place (it recovers within
|
|
189
|
+
* minutes) and for a key that is wrong. The raw error goes to the log and the failure note, never to the person. */
|
|
190
|
+
export declare function modelKeyRefusedSentence(message: string): string | undefined;
|
|
185
191
|
/** Create a sandbox chat producer that manages chat turn routing with logging and interaction rendering options */
|
|
186
192
|
export declare function createSandboxChatProducer(options: SandboxChatProducerOptions): ChatTurnRouteProducer;
|
|
@@ -1511,6 +1511,11 @@ function providerResetSentence(message) {
|
|
|
1511
1511
|
const cause = message.split("; the provider asked")[0]?.trim();
|
|
1512
1512
|
return `The model provider refused the call (${cause}); try again after ${utcTime(at)} on ${at.toISOString().slice(0, 10)}.`;
|
|
1513
1513
|
}
|
|
1514
|
+
var MODEL_KEY_REFUSED_CODE = "model.key_refused";
|
|
1515
|
+
function modelKeyRefusedSentence(message) {
|
|
1516
|
+
if (!/\binvalid api key\b|\b401\b[^\n]*\b(?:unauthori[sz]ed|api key)\b/i.test(message)) return void 0;
|
|
1517
|
+
return "The assistant's model refused its access key, so this message was not answered. If the assistant has just started, send it again in a minute; if this repeats, tell the team.";
|
|
1518
|
+
}
|
|
1514
1519
|
function sandboxStreamErrorMessage(data) {
|
|
1515
1520
|
const record = asRecord(data);
|
|
1516
1521
|
const message = asString(record?.message) ?? asString(record?.error);
|
|
@@ -1539,7 +1544,8 @@ function sandboxStreamFailureDiagnostic(error) {
|
|
|
1539
1544
|
diagnosticText = "[unserializable diagnostics]";
|
|
1540
1545
|
}
|
|
1541
1546
|
}
|
|
1542
|
-
const
|
|
1547
|
+
const keyRefused = modelKeyRefusedSentence(message);
|
|
1548
|
+
const userMessage = providerResetSentence(message) ?? keyRefused ?? [
|
|
1543
1549
|
"The sandbox model stream stopped before a clean completion.",
|
|
1544
1550
|
`Error: ${message}`,
|
|
1545
1551
|
"Please retry. If it repeats, send these support details to the team."
|
|
@@ -1553,6 +1559,7 @@ function sandboxStreamFailureDiagnostic(error) {
|
|
|
1553
1559
|
} else if (error instanceof ModelFailoverExhaustedError) {
|
|
1554
1560
|
code = error.upstreamCode ?? code;
|
|
1555
1561
|
}
|
|
1562
|
+
if (keyRefused) code = MODEL_KEY_REFUSED_CODE;
|
|
1556
1563
|
return { userMessage, failureNote, code };
|
|
1557
1564
|
}
|
|
1558
1565
|
function createSandboxChatProducer(options) {
|
|
@@ -1710,13 +1717,15 @@ function createSandboxChatProducer(options) {
|
|
|
1710
1717
|
}
|
|
1711
1718
|
if (event.type === "error") {
|
|
1712
1719
|
const message = sandboxStreamErrorMessage(event.data);
|
|
1713
|
-
const
|
|
1720
|
+
const keyRefused = modelKeyRefusedSentence(message);
|
|
1721
|
+
if (keyRefused) log("[chat-routes] model key refused", { code: MODEL_KEY_REFUSED_CODE, error: message });
|
|
1722
|
+
const errorContent = providerResetSentence(message) ?? keyRefused ?? (projectionState.fullText.trim() ? `The sandbox model stream stopped before a clean completion.
|
|
1714
1723
|
|
|
1715
1724
|
Error: ${message}` : `The sandbox agent returned an error before producing a visible answer.
|
|
1716
1725
|
|
|
1717
1726
|
Error: ${message}`);
|
|
1718
1727
|
if (options.errorNotice) {
|
|
1719
|
-
yield* emitErrorNotice(errorContent, sandboxStreamErrorCode(event.data));
|
|
1728
|
+
yield* emitErrorNotice(errorContent, keyRefused ? MODEL_KEY_REFUSED_CODE : sandboxStreamErrorCode(event.data));
|
|
1720
1729
|
} else if (options.includeErrorText !== false) {
|
|
1721
1730
|
const errorDelta = projectionState.fullText ? `
|
|
1722
1731
|
|
|
@@ -4164,6 +4173,8 @@ export {
|
|
|
4164
4173
|
streamWithModelFailover,
|
|
4165
4174
|
providerRetryNotice,
|
|
4166
4175
|
providerResetSentence,
|
|
4176
|
+
MODEL_KEY_REFUSED_CODE,
|
|
4177
|
+
modelKeyRefusedSentence,
|
|
4167
4178
|
createSandboxChatProducer,
|
|
4168
4179
|
withProducerStream,
|
|
4169
4180
|
cancelChatTurn,
|
|
@@ -4177,4 +4188,4 @@ export {
|
|
|
4177
4188
|
createChatTurnRoutes,
|
|
4178
4189
|
streamChatRouteAsSandboxEvents
|
|
4179
4190
|
};
|
|
4180
|
-
//# sourceMappingURL=chunk-
|
|
4191
|
+
//# sourceMappingURL=chunk-4XFPMDIM.js.map
|