@tangle-network/agent-app 3.0.25 → 3.0.26
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/default-backend.d.ts +5 -4
- 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 +7 -0
- package/dist/{chunk-FYWWQRLA.js → chunk-IV2QLOA2.js} +35 -10
- package/dist/chunk-IV2QLOA2.js.map +1 -0
- package/dist/public-consultation/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-FYWWQRLA.js.map +0 -1
|
@@ -175,5 +175,12 @@ export interface SandboxChatProducerOptions {
|
|
|
175
175
|
errorNotice?: boolean;
|
|
176
176
|
log?: (message: string, meta?: Record<string, unknown>) => void;
|
|
177
177
|
}
|
|
178
|
+
/** A harness's provider retry wait (OpenCode's raw `retry` status) as one sentence: the provider's words and the next attempt. */
|
|
179
|
+
export declare function providerRetryNotice(event: {
|
|
180
|
+
type: string;
|
|
181
|
+
data?: unknown;
|
|
182
|
+
}): string | undefined;
|
|
183
|
+
/** A terminal provider wait (`…, reset at <ISO>`, agent-container provider-retry-wait.ts) as one sentence. */
|
|
184
|
+
export declare function providerResetSentence(message: string): string | undefined;
|
|
178
185
|
/** Create a sandbox chat producer that manages chat turn routing with logging and interaction rendering options */
|
|
179
186
|
export declare function createSandboxChatProducer(options: SandboxChatProducerOptions): ChatTurnRouteProducer;
|
|
@@ -1498,6 +1498,19 @@ function applyTerminalUsage(reported, usage) {
|
|
|
1498
1498
|
if (reported.cacheWriteTokens !== void 0) usage.cacheWriteTokens = reported.cacheWriteTokens;
|
|
1499
1499
|
if (reported.harnessCostUsd !== void 0) usage.harnessCostUsd = reported.harnessCostUsd;
|
|
1500
1500
|
}
|
|
1501
|
+
var utcTime = (at) => `${at.toISOString().slice(11, 19)} UTC`;
|
|
1502
|
+
function providerRetryNotice(event) {
|
|
1503
|
+
const retry = event.type === "raw" ? asRecord(asRecord(event.data)?.event) : void 0;
|
|
1504
|
+
if (retry?.type !== "retry" || !(Number(retry.next) > 0)) return void 0;
|
|
1505
|
+
const cause = asString(retry.message)?.trim() || "no reason given";
|
|
1506
|
+
return `The model provider refused the call (${cause}), so the turn retries at ${utcTime(new Date(Number(retry.next)))}.`;
|
|
1507
|
+
}
|
|
1508
|
+
function providerResetSentence(message) {
|
|
1509
|
+
const at = new Date(message.match(/reset at (\d{4}-\d{2}-\d{2}T[\d:.]+Z)/)?.[1] ?? NaN);
|
|
1510
|
+
if (Number.isNaN(at.getTime())) return void 0;
|
|
1511
|
+
const cause = message.split("; the provider asked")[0]?.trim();
|
|
1512
|
+
return `The model provider refused the call (${cause}); try again after ${utcTime(at)} on ${at.toISOString().slice(0, 10)}.`;
|
|
1513
|
+
}
|
|
1501
1514
|
function sandboxStreamErrorMessage(data) {
|
|
1502
1515
|
const record = asRecord(data);
|
|
1503
1516
|
const message = asString(record?.message) ?? asString(record?.error);
|
|
@@ -1526,7 +1539,7 @@ function sandboxStreamFailureDiagnostic(error) {
|
|
|
1526
1539
|
diagnosticText = "[unserializable diagnostics]";
|
|
1527
1540
|
}
|
|
1528
1541
|
}
|
|
1529
|
-
const userMessage = [
|
|
1542
|
+
const userMessage = providerResetSentence(message) ?? [
|
|
1530
1543
|
"The sandbox model stream stopped before a clean completion.",
|
|
1531
1544
|
`Error: ${message}`,
|
|
1532
1545
|
"Please retry. If it repeats, send these support details to the team."
|
|
@@ -1639,6 +1652,12 @@ function createSandboxChatProducer(options) {
|
|
|
1639
1652
|
yield toProducerWireEvent(record);
|
|
1640
1653
|
continue;
|
|
1641
1654
|
}
|
|
1655
|
+
const retry = providerRetryNotice(event);
|
|
1656
|
+
if (retry) {
|
|
1657
|
+
const notice = noticePart("warning", `warning-${++projectionState.warningCount}`, retry);
|
|
1658
|
+
recordPersistedPart(notice, void 0, noticePartKey(notice.id));
|
|
1659
|
+
yield { type: "notice", id: notice.id, noticeKind: "warning", text: retry };
|
|
1660
|
+
}
|
|
1642
1661
|
if (event.type === "warning") {
|
|
1643
1662
|
const message = asString(event.data?.message);
|
|
1644
1663
|
if (message) {
|
|
@@ -1691,11 +1710,11 @@ function createSandboxChatProducer(options) {
|
|
|
1691
1710
|
}
|
|
1692
1711
|
if (event.type === "error") {
|
|
1693
1712
|
const message = sandboxStreamErrorMessage(event.data);
|
|
1694
|
-
const errorContent = projectionState.fullText.trim() ? `The sandbox model stream stopped before a clean completion.
|
|
1713
|
+
const errorContent = providerResetSentence(message) ?? (projectionState.fullText.trim() ? `The sandbox model stream stopped before a clean completion.
|
|
1695
1714
|
|
|
1696
1715
|
Error: ${message}` : `The sandbox agent returned an error before producing a visible answer.
|
|
1697
1716
|
|
|
1698
|
-
Error: ${message}
|
|
1717
|
+
Error: ${message}`);
|
|
1699
1718
|
if (options.errorNotice) {
|
|
1700
1719
|
yield* emitErrorNotice(errorContent, sandboxStreamErrorCode(event.data));
|
|
1701
1720
|
} else if (options.includeErrorText !== false) {
|
|
@@ -3636,12 +3655,16 @@ function createDefaultChatBackend(projectId, env, config, bindings, modelPolicy)
|
|
|
3636
3655
|
modelPolicy,
|
|
3637
3656
|
modelFailover: false,
|
|
3638
3657
|
errorNotice: true,
|
|
3639
|
-
openEvents: ({ model: model2, signal })
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
|
|
3643
|
-
|
|
3644
|
-
|
|
3658
|
+
openEvents: async function* ({ model: model2, signal }) {
|
|
3659
|
+
const own = config.providers?.[model2];
|
|
3660
|
+
const provider = typeof own === "function" ? await own(args) : own;
|
|
3661
|
+
yield* streamSandboxPrompt(
|
|
3662
|
+
provider ? { ...shell, provider } : shell,
|
|
3663
|
+
box,
|
|
3664
|
+
normalizeChatPromptForSandbox(args.prompt),
|
|
3665
|
+
{ ...promptOptions(args), model: model2, signal }
|
|
3666
|
+
);
|
|
3667
|
+
}
|
|
3645
3668
|
};
|
|
3646
3669
|
}
|
|
3647
3670
|
};
|
|
@@ -4141,6 +4164,8 @@ export {
|
|
|
4141
4164
|
MAX_EMPTY_TURN_RETRIES,
|
|
4142
4165
|
resolveEmptyTurnRetries,
|
|
4143
4166
|
streamWithModelFailover,
|
|
4167
|
+
providerRetryNotice,
|
|
4168
|
+
providerResetSentence,
|
|
4144
4169
|
createSandboxChatProducer,
|
|
4145
4170
|
withProducerStream,
|
|
4146
4171
|
cancelChatTurn,
|
|
@@ -4154,4 +4179,4 @@ export {
|
|
|
4154
4179
|
createChatTurnRoutes,
|
|
4155
4180
|
streamChatRouteAsSandboxEvents
|
|
4156
4181
|
};
|
|
4157
|
-
//# sourceMappingURL=chunk-
|
|
4182
|
+
//# sourceMappingURL=chunk-IV2QLOA2.js.map
|