omnius 1.0.180 → 1.0.182
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/index.js +220 -38
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -563701,7 +563701,7 @@ ${description}`
|
|
|
563701
563701
|
const responseText = firstChoice ? String(firstChoice.message?.content ?? "") : "";
|
|
563702
563702
|
const outcome = this.recordThinkOutcome(responseText, effectiveThink === true);
|
|
563703
563703
|
const independentOutcome = effectiveThink !== true ? classifyThinkOutcome(responseText) : null;
|
|
563704
|
-
const shouldRecoverFromEmpty = responseFormat !== void 0 && independentOutcome !== null && (independentOutcome === "empty_after_strip" || independentOutcome === "unclosed_think");
|
|
563704
|
+
const shouldRecoverFromEmpty = request.disableEmptyContentRecovery !== true && responseFormat !== void 0 && independentOutcome !== null && (independentOutcome === "empty_after_strip" || independentOutcome === "unclosed_think");
|
|
563705
563705
|
const justSuppressed = this._thinkSuppressed && this._thinkFailStreak === _OllamaAgenticBackend._thinkFailThreshold;
|
|
563706
563706
|
const shouldRetryThinkGuard = outcome !== null && effectiveThink === true && (justSuppressed || outcome === "empty_after_strip" || outcome === "unclosed_think");
|
|
563707
563707
|
if (shouldRetryThinkGuard || shouldRecoverFromEmpty) {
|
|
@@ -629151,6 +629151,27 @@ function telegramRouterTimeoutMs(configTimeoutMs, minMs = 1e4, maxMs) {
|
|
|
629151
629151
|
const requested = Number.isFinite(configTimeoutMs) && (configTimeoutMs ?? 0) > 0 ? configTimeoutMs : cap;
|
|
629152
629152
|
return Math.max(floor, Math.min(requested, cap));
|
|
629153
629153
|
}
|
|
629154
|
+
function telegramRouterErrorText(err) {
|
|
629155
|
+
return err instanceof Error ? err.message : String(err);
|
|
629156
|
+
}
|
|
629157
|
+
function compactTelegramRouterDiagnosticText(text, maxLength = 220) {
|
|
629158
|
+
const compact3 = text.replace(/\s+/g, " ").trim();
|
|
629159
|
+
return compact3.length > maxLength ? `${compact3.slice(0, Math.max(0, maxLength - 3))}...` : compact3;
|
|
629160
|
+
}
|
|
629161
|
+
function telegramRouterErrorLooksLikeTimeout(err) {
|
|
629162
|
+
const text = telegramRouterErrorText(err);
|
|
629163
|
+
return /\b(timeout|timed out|ETIMEDOUT)\b|aborted due to timeout|stream timeout/i.test(text);
|
|
629164
|
+
}
|
|
629165
|
+
function telegramRouterErrorLooksLikeBackendLiveness(err) {
|
|
629166
|
+
const text = telegramRouterErrorText(err);
|
|
629167
|
+
return telegramRouterErrorLooksLikeTimeout(err) || /fetch failed|ECONNREFUSED|ECONNRESET|EHOSTUNREACH|ENETUNREACH|ECONNABORTED|socket hang up|terminated|network error/i.test(text);
|
|
629168
|
+
}
|
|
629169
|
+
function telegramRouterDiagnosticAttemptLooksLikeTimeout(attempt) {
|
|
629170
|
+
return attempt.status === "threw" && telegramRouterErrorLooksLikeTimeout(attempt.error ?? "");
|
|
629171
|
+
}
|
|
629172
|
+
function telegramRouterDiagnosticAttemptLooksLikeBackendLiveness(attempt) {
|
|
629173
|
+
return attempt.status === "threw" && telegramRouterErrorLooksLikeBackendLiveness(attempt.error ?? "");
|
|
629174
|
+
}
|
|
629154
629175
|
function telegramThinkSuppressedRequest(request) {
|
|
629155
629176
|
const messages2 = Array.isArray(request.messages) ? request.messages.slice() : [];
|
|
629156
629177
|
let appended = false;
|
|
@@ -635251,11 +635272,25 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
635251
635272
|
async telegramRouterJsonCompletion(backend, request, diagnostics, inferenceKind = "router", sessionKey = "__router__") {
|
|
635252
635273
|
let jsonModeResult;
|
|
635253
635274
|
let jsonModeError;
|
|
635275
|
+
const recordAttempt = (attempt) => {
|
|
635276
|
+
if (!diagnostics) return;
|
|
635277
|
+
diagnostics.attempts ??= [];
|
|
635278
|
+
diagnostics.attempts.push({
|
|
635279
|
+
stage: inferenceKind,
|
|
635280
|
+
...attempt
|
|
635281
|
+
});
|
|
635282
|
+
};
|
|
635254
635283
|
const suppressed = telegramThinkSuppressedRequest(request);
|
|
635284
|
+
const requestTimeoutMs = Number.isFinite(suppressed.timeoutMs) && (suppressed.timeoutMs ?? 0) > 0 ? suppressed.timeoutMs : void 0;
|
|
635285
|
+
const jsonStartMs = Date.now();
|
|
635255
635286
|
try {
|
|
635256
635287
|
jsonModeResult = await this.telegramObservableInference(
|
|
635257
635288
|
backend,
|
|
635258
|
-
{
|
|
635289
|
+
{
|
|
635290
|
+
...suppressed,
|
|
635291
|
+
responseFormat: TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT,
|
|
635292
|
+
disableEmptyContentRecovery: true
|
|
635293
|
+
},
|
|
635259
635294
|
inferenceKind,
|
|
635260
635295
|
sessionKey,
|
|
635261
635296
|
{ stream: false, reason: "router-json" }
|
|
@@ -635265,16 +635300,49 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
635265
635300
|
);
|
|
635266
635301
|
if (visible) {
|
|
635267
635302
|
if (diagnostics) diagnostics.jsonModeStatus = "visible";
|
|
635303
|
+
recordAttempt({
|
|
635304
|
+
mode: "json-mode",
|
|
635305
|
+
status: "visible",
|
|
635306
|
+
elapsedMs: Date.now() - jsonStartMs,
|
|
635307
|
+
timeoutMs: requestTimeoutMs
|
|
635308
|
+
});
|
|
635268
635309
|
return jsonModeResult;
|
|
635269
635310
|
}
|
|
635270
635311
|
if (diagnostics) diagnostics.jsonModeStatus = "empty-after-strip";
|
|
635312
|
+
recordAttempt({
|
|
635313
|
+
mode: "json-mode",
|
|
635314
|
+
status: "empty-after-strip",
|
|
635315
|
+
elapsedMs: Date.now() - jsonStartMs,
|
|
635316
|
+
timeoutMs: requestTimeoutMs
|
|
635317
|
+
});
|
|
635271
635318
|
} catch (err) {
|
|
635272
635319
|
jsonModeError = err;
|
|
635273
635320
|
if (diagnostics) {
|
|
635274
635321
|
diagnostics.jsonModeStatus = "threw";
|
|
635275
|
-
diagnostics.jsonModeError =
|
|
635322
|
+
diagnostics.jsonModeError = telegramRouterErrorText(err);
|
|
635323
|
+
}
|
|
635324
|
+
recordAttempt({
|
|
635325
|
+
mode: "json-mode",
|
|
635326
|
+
status: "threw",
|
|
635327
|
+
error: telegramRouterErrorText(err),
|
|
635328
|
+
elapsedMs: Date.now() - jsonStartMs,
|
|
635329
|
+
timeoutMs: requestTimeoutMs
|
|
635330
|
+
});
|
|
635331
|
+
if (telegramRouterErrorLooksLikeBackendLiveness(err)) {
|
|
635332
|
+
if (diagnostics) {
|
|
635333
|
+
diagnostics.plainStatus = "skipped";
|
|
635334
|
+
diagnostics.plainError = "skipped because json-mode backend liveness failed";
|
|
635335
|
+
}
|
|
635336
|
+
recordAttempt({
|
|
635337
|
+
mode: "plain-retry",
|
|
635338
|
+
status: "skipped",
|
|
635339
|
+
error: "skipped because json-mode backend liveness failed",
|
|
635340
|
+
timeoutMs: requestTimeoutMs
|
|
635341
|
+
});
|
|
635342
|
+
throw err;
|
|
635276
635343
|
}
|
|
635277
635344
|
}
|
|
635345
|
+
const plainStartMs = Date.now();
|
|
635278
635346
|
try {
|
|
635279
635347
|
const plainResult = await this.telegramObservableInference(
|
|
635280
635348
|
backend,
|
|
@@ -635288,13 +635356,26 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
635288
635356
|
(choice) => stripTelegramHiddenThinking(choice.message.content ?? "").trim().length > 0
|
|
635289
635357
|
);
|
|
635290
635358
|
diagnostics.plainStatus = plainVisible ? "visible" : "empty-after-strip";
|
|
635359
|
+
recordAttempt({
|
|
635360
|
+
mode: "plain-retry",
|
|
635361
|
+
status: plainVisible ? "visible" : "empty-after-strip",
|
|
635362
|
+
elapsedMs: Date.now() - plainStartMs,
|
|
635363
|
+
timeoutMs: requestTimeoutMs
|
|
635364
|
+
});
|
|
635291
635365
|
}
|
|
635292
635366
|
return plainResult;
|
|
635293
635367
|
} catch (err) {
|
|
635294
635368
|
if (diagnostics) {
|
|
635295
635369
|
diagnostics.plainStatus = "threw";
|
|
635296
|
-
diagnostics.plainError =
|
|
635370
|
+
diagnostics.plainError = telegramRouterErrorText(err);
|
|
635297
635371
|
}
|
|
635372
|
+
recordAttempt({
|
|
635373
|
+
mode: "plain-retry",
|
|
635374
|
+
status: "threw",
|
|
635375
|
+
error: telegramRouterErrorText(err),
|
|
635376
|
+
elapsedMs: Date.now() - plainStartMs,
|
|
635377
|
+
timeoutMs: requestTimeoutMs
|
|
635378
|
+
});
|
|
635298
635379
|
if (jsonModeError instanceof Error && !(err instanceof Error)) throw jsonModeError;
|
|
635299
635380
|
throw err;
|
|
635300
635381
|
}
|
|
@@ -635667,7 +635748,7 @@ ${repairedText}`,
|
|
|
635667
635748
|
} catch (err) {
|
|
635668
635749
|
if (diagnostics) {
|
|
635669
635750
|
diagnostics.repairStatus = "threw";
|
|
635670
|
-
diagnostics.repairError =
|
|
635751
|
+
diagnostics.repairError = telegramRouterErrorText(err);
|
|
635671
635752
|
}
|
|
635672
635753
|
return null;
|
|
635673
635754
|
}
|
|
@@ -635733,7 +635814,7 @@ ${retryText}`,
|
|
|
635733
635814
|
} catch (err) {
|
|
635734
635815
|
if (diagnostics) {
|
|
635735
635816
|
diagnostics.strictRetryStatus = "threw";
|
|
635736
|
-
diagnostics.strictRetryError =
|
|
635817
|
+
diagnostics.strictRetryError = telegramRouterErrorText(err);
|
|
635737
635818
|
}
|
|
635738
635819
|
return null;
|
|
635739
635820
|
}
|
|
@@ -636221,20 +636302,21 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
|
636221
636302
|
}
|
|
636222
636303
|
const invalidRouterPreview = telegramRouterRawPreview(text);
|
|
636223
636304
|
const failureNarrative = this.summarizeTelegramRouterFailure(diagnostics);
|
|
636305
|
+
const backendLivenessFailure = (diagnostics.attempts ?? []).some(telegramRouterDiagnosticAttemptLooksLikeBackendLiveness) || telegramRouterErrorLooksLikeBackendLiveness(diagnostics.repairError ?? "") || telegramRouterErrorLooksLikeBackendLiveness(diagnostics.strictRetryError ?? "");
|
|
636224
636306
|
const fallback = this.applyTelegramSilentReflectionNotes(this.buildTelegramRouterUnavailableDecision(msg, toolContext, {
|
|
636225
|
-
reason: "router output was not valid decision JSON after repair/retry; no model-derived reply decision",
|
|
636307
|
+
reason: backendLivenessFailure ? "router recovery hit a backend liveness failure; no model-derived reply decision" : "router output was not valid decision JSON after repair/retry; no model-derived reply decision",
|
|
636226
636308
|
silentDisposition: reflectionNotes.silentDisposition,
|
|
636227
636309
|
diagnosticNote: this.composeTelegramRouterDiagnosticNote(
|
|
636228
636310
|
invalidRouterPreview,
|
|
636229
636311
|
failureNarrative,
|
|
636230
|
-
invalidRouterPreview ? "router produced an invalid attention decision payload; repair and strict retry did not recover it" : "router produced an empty attention decision payload; strict retry did not recover it"
|
|
636312
|
+
backendLivenessFailure ? "router backend failed during attention-decision recovery; no usable router decision was available" : invalidRouterPreview ? "router produced an invalid attention decision payload; repair and strict retry did not recover it" : "router produced an empty attention decision payload; strict retry did not recover it"
|
|
636231
636313
|
),
|
|
636232
636314
|
raw: text
|
|
636233
636315
|
}), reflectionNotes);
|
|
636234
636316
|
return withRouterTelemetry(fallback);
|
|
636235
636317
|
} catch (err) {
|
|
636236
636318
|
const failureNarrative = this.summarizeTelegramRouterFailure(diagnostics);
|
|
636237
|
-
const errMsg =
|
|
636319
|
+
const errMsg = telegramRouterErrorText(err);
|
|
636238
636320
|
const fallback = this.applyTelegramSilentReflectionNotes(this.buildTelegramRouterUnavailableDecision(msg, toolContext, {
|
|
636239
636321
|
reason: `router inference failed; no model-derived reply decision (${errMsg.slice(0, 160)})`,
|
|
636240
636322
|
silentDisposition: reflectionNotes.silentDisposition,
|
|
@@ -636247,46 +636329,93 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
|
636247
636329
|
return withRouterTelemetry(fallback);
|
|
636248
636330
|
}
|
|
636249
636331
|
}
|
|
636332
|
+
formatTelegramRouterAttemptTrace(attempt) {
|
|
636333
|
+
const elapsed = Number.isFinite(attempt.elapsedMs) ? ` elapsedMs=${Math.max(0, Math.round(attempt.elapsedMs ?? 0))}` : "";
|
|
636334
|
+
const timeout2 = Number.isFinite(attempt.timeoutMs) ? ` timeoutMs=${Math.max(0, Math.round(attempt.timeoutMs ?? 0))}` : "";
|
|
636335
|
+
const error = attempt.error ? ` (${compactTelegramRouterDiagnosticText(attempt.error, 180)})` : "";
|
|
636336
|
+
return `${attempt.stage}/${attempt.mode}: ${attempt.status}${error}${elapsed}${timeout2}`;
|
|
636337
|
+
}
|
|
636338
|
+
telegramRouterBackendLivenessHint(timeoutSeen) {
|
|
636339
|
+
const backendType = this.agentConfig?.backendType ?? "backend";
|
|
636340
|
+
if (backendType === "ollama") {
|
|
636341
|
+
return timeoutSeen ? "local Ollama did not return router tokens within the liveness window; likely queue backlog, cold model load, GPU/RAM contention, or a wedged runner. JSON repair cannot recover until the backend responds" : "local Ollama request failed before router content was available; check Ollama reachability, model availability, and runner health";
|
|
636342
|
+
}
|
|
636343
|
+
return timeoutSeen ? `${backendType} backend did not return router tokens within the liveness window; check provider latency, rate limits, and request queue depth` : `${backendType} backend request failed before router content was available; check provider reachability and rate limits`;
|
|
636344
|
+
}
|
|
636250
636345
|
/**
|
|
636251
636346
|
* Reduce captured per-step diagnostics into:
|
|
636252
636347
|
* - `summary`: a short outcome-level diagnostic
|
|
636253
636348
|
* - `detail`: a longer ordered trace for operator debugging
|
|
636254
|
-
* - `operatorHint`: an operational hint
|
|
636349
|
+
* - `operatorHint`: an operational hint with backend/model context
|
|
636255
636350
|
*/
|
|
636256
636351
|
summarizeTelegramRouterFailure(diag) {
|
|
636257
636352
|
const parts = [];
|
|
636258
636353
|
const detailParts = [];
|
|
636259
636354
|
let thinkInjectionSuspected = false;
|
|
636260
636355
|
let networkErrorSeen = false;
|
|
636261
|
-
|
|
636262
|
-
|
|
636263
|
-
|
|
636264
|
-
|
|
636265
|
-
|
|
636266
|
-
|
|
636267
|
-
|
|
636268
|
-
|
|
636269
|
-
|
|
636270
|
-
|
|
636271
|
-
|
|
636272
|
-
|
|
636273
|
-
|
|
636274
|
-
|
|
636275
|
-
|
|
636276
|
-
|
|
636277
|
-
|
|
636278
|
-
|
|
636279
|
-
|
|
636280
|
-
|
|
636281
|
-
|
|
636356
|
+
let timeoutSeen = false;
|
|
636357
|
+
const attempts = diag.attempts ?? [];
|
|
636358
|
+
if (attempts.length > 0) {
|
|
636359
|
+
const livenessAttempts = attempts.filter(telegramRouterDiagnosticAttemptLooksLikeBackendLiveness);
|
|
636360
|
+
const timeoutAttempts = attempts.filter(telegramRouterDiagnosticAttemptLooksLikeTimeout);
|
|
636361
|
+
const emptyAttempts = attempts.filter((attempt) => attempt.status === "empty-after-strip");
|
|
636362
|
+
const visibleAttempts = attempts.filter((attempt) => attempt.status === "visible");
|
|
636363
|
+
const skippedAttempts = attempts.filter((attempt) => attempt.status === "skipped");
|
|
636364
|
+
networkErrorSeen = livenessAttempts.length > 0;
|
|
636365
|
+
timeoutSeen = timeoutAttempts.length > 0;
|
|
636366
|
+
thinkInjectionSuspected = emptyAttempts.length > 0;
|
|
636367
|
+
if (livenessAttempts.length > 0) {
|
|
636368
|
+
const affected = livenessAttempts.map((attempt) => `${attempt.stage}/${attempt.mode}`).join(", ");
|
|
636369
|
+
parts.push(timeoutSeen ? `backend timeout/liveness failure during ${affected}` : `backend liveness failure during ${affected}`);
|
|
636370
|
+
}
|
|
636371
|
+
if (emptyAttempts.length > 0) {
|
|
636372
|
+
const affected = emptyAttempts.map((attempt) => `${attempt.stage}/${attempt.mode}`).join(", ");
|
|
636373
|
+
parts.push(`empty visible content after <think> strip during ${affected}`);
|
|
636374
|
+
}
|
|
636375
|
+
if (visibleAttempts.length > 0 && diag.repairStatus !== "recovered" && diag.strictRetryStatus !== "recovered") {
|
|
636376
|
+
parts.push(`visible router text remained unparseable`);
|
|
636377
|
+
}
|
|
636378
|
+
if (skippedAttempts.length > 0) {
|
|
636379
|
+
const affected = skippedAttempts.map((attempt) => `${attempt.stage}/${attempt.mode}`).join(", ");
|
|
636380
|
+
parts.push(`fallback attempt skipped during ${affected}`);
|
|
636381
|
+
}
|
|
636382
|
+
detailParts.push(...attempts.map((attempt) => this.formatTelegramRouterAttemptTrace(attempt)));
|
|
636383
|
+
} else {
|
|
636384
|
+
if (diag.jsonModeStatus === "threw") {
|
|
636385
|
+
parts.push(`json-mode call threw`);
|
|
636386
|
+
detailParts.push(`json-mode: threw (${diag.jsonModeError ?? "no detail"})`);
|
|
636387
|
+
networkErrorSeen = true;
|
|
636388
|
+
timeoutSeen = telegramRouterErrorLooksLikeTimeout(diag.jsonModeError ?? "");
|
|
636389
|
+
} else if (diag.jsonModeStatus === "empty-after-strip") {
|
|
636390
|
+
parts.push(`json-mode returned empty content (likely <think>-only)`);
|
|
636391
|
+
detailParts.push(`json-mode: empty-after-strip`);
|
|
636392
|
+
thinkInjectionSuspected = true;
|
|
636393
|
+
} else if (diag.jsonModeStatus === "visible") {
|
|
636394
|
+
detailParts.push(`json-mode: visible`);
|
|
636395
|
+
}
|
|
636396
|
+
if (diag.plainStatus === "threw") {
|
|
636397
|
+
parts.push(`plain call threw`);
|
|
636398
|
+
detailParts.push(`plain: threw (${diag.plainError ?? "no detail"})`);
|
|
636399
|
+
networkErrorSeen = true;
|
|
636400
|
+
timeoutSeen ||= telegramRouterErrorLooksLikeTimeout(diag.plainError ?? "");
|
|
636401
|
+
} else if (diag.plainStatus === "empty-after-strip") {
|
|
636402
|
+
parts.push(`plain call returned empty content`);
|
|
636403
|
+
detailParts.push(`plain: empty-after-strip`);
|
|
636404
|
+
thinkInjectionSuspected = true;
|
|
636405
|
+
} else if (diag.plainStatus === "visible") {
|
|
636406
|
+
detailParts.push(`plain: visible-but-unparseable`);
|
|
636407
|
+
}
|
|
636282
636408
|
}
|
|
636283
636409
|
if (diag.repairStatus === "skipped") {
|
|
636284
636410
|
detailParts.push(`repair: skipped (${diag.repairError ?? "no recoverable input"})`);
|
|
636411
|
+
} else if (diag.repairStatus === "skipped-truncation-rerun") {
|
|
636412
|
+
detailParts.push(`repair: skipped for truncation rerun`);
|
|
636285
636413
|
} else if (diag.repairStatus === "no-recoverable-output") {
|
|
636286
636414
|
detailParts.push(`repair: returned non-recoverable JSON`);
|
|
636287
636415
|
} else if (diag.repairStatus === "threw") {
|
|
636288
636416
|
detailParts.push(`repair: threw (${diag.repairError ?? "no detail"})`);
|
|
636289
636417
|
networkErrorSeen = true;
|
|
636418
|
+
timeoutSeen ||= telegramRouterErrorLooksLikeTimeout(diag.repairError ?? "");
|
|
636290
636419
|
} else if (diag.repairStatus === "recovered") {
|
|
636291
636420
|
detailParts.push(`repair: recovered`);
|
|
636292
636421
|
}
|
|
@@ -636298,14 +636427,15 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
|
636298
636427
|
} else if (diag.strictRetryStatus === "threw") {
|
|
636299
636428
|
detailParts.push(`strict-retry: threw (${diag.strictRetryError ?? "no detail"})`);
|
|
636300
636429
|
networkErrorSeen = true;
|
|
636430
|
+
timeoutSeen ||= telegramRouterErrorLooksLikeTimeout(diag.strictRetryError ?? "");
|
|
636301
636431
|
} else if (diag.strictRetryStatus === "recovered") {
|
|
636302
636432
|
detailParts.push(`strict-retry: recovered`);
|
|
636303
636433
|
}
|
|
636304
636434
|
let operatorHint;
|
|
636305
636435
|
if (networkErrorSeen) {
|
|
636306
|
-
operatorHint =
|
|
636436
|
+
operatorHint = this.telegramRouterBackendLivenessHint(timeoutSeen);
|
|
636307
636437
|
} else if (thinkInjectionSuspected) {
|
|
636308
|
-
operatorHint = "router model emitted <think>-only or unclosed-think output;
|
|
636438
|
+
operatorHint = "router model emitted <think>-only or unclosed-think output despite think suppression; visible decision content was empty after stripping hidden reasoning";
|
|
636309
636439
|
}
|
|
636310
636440
|
return {
|
|
636311
636441
|
summary: parts.join("; "),
|
|
@@ -636321,7 +636451,7 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
|
636321
636451
|
if (invalidRouterPreview) segments.push(`invalid router output preview: ${invalidRouterPreview}`);
|
|
636322
636452
|
if (failureNarrative.detail) segments.push(`router-failure trace: ${failureNarrative.detail}`);
|
|
636323
636453
|
if (failureNarrative.operatorHint) segments.push(failureNarrative.operatorHint);
|
|
636324
|
-
return segments.join(" | ").slice(0,
|
|
636454
|
+
return segments.join(" | ").slice(0, 1400);
|
|
636325
636455
|
}
|
|
636326
636456
|
buildTelegramWorkspaceContext(modelTier, budget = 14e3) {
|
|
636327
636457
|
if (!this.repoRoot) return "";
|
|
@@ -637014,6 +637144,25 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
637014
637144
|
subAgent.liveMessageId = state.messageId ?? null;
|
|
637015
637145
|
return state.messageId ?? null;
|
|
637016
637146
|
}
|
|
637147
|
+
telegramAdminRunCompleted(subAgent) {
|
|
637148
|
+
return subAgent.runnerCompleted === true || subAgent.completionBoundarySeen;
|
|
637149
|
+
}
|
|
637150
|
+
telegramAdminIncompleteRunText(subAgent, finalText) {
|
|
637151
|
+
const stats = [
|
|
637152
|
+
typeof subAgent.runnerTurns === "number" ? `${subAgent.runnerTurns} turn(s)` : "",
|
|
637153
|
+
typeof subAgent.runnerToolCalls === "number" ? `${subAgent.runnerToolCalls} tool call(s)` : ""
|
|
637154
|
+
].filter(Boolean).join(", ");
|
|
637155
|
+
const summary = cleanTelegramVisibleReply(subAgent.runnerSummary || "");
|
|
637156
|
+
const parts = [
|
|
637157
|
+
`INCOMPLETE: admin run exited before task_complete${stats ? ` after ${stats}` : ""}.`,
|
|
637158
|
+
"This is not a completed task. The run should be resumed or retried; no successful completion boundary was observed.",
|
|
637159
|
+
finalText ? `Last visible draft:
|
|
637160
|
+
${finalText}` : "",
|
|
637161
|
+
summary ? `Runner summary:
|
|
637162
|
+
${summary}` : ""
|
|
637163
|
+
].filter(Boolean);
|
|
637164
|
+
return parts.join("\n\n");
|
|
637165
|
+
}
|
|
637017
637166
|
async sendOrEditFinalTelegramHTML(msg, html, liveMessageId) {
|
|
637018
637167
|
const chunks = splitTelegramMessageText(html, 3900);
|
|
637019
637168
|
if (chunks.length === 0) return null;
|
|
@@ -637350,6 +637499,18 @@ Join: ${newUrl}`);
|
|
|
637350
637499
|
subAgent.typingInterval = null;
|
|
637351
637500
|
}
|
|
637352
637501
|
const finalText = cleanTelegramVisibleReply(result || "");
|
|
637502
|
+
if (isAdminDM && !this.telegramAdminRunCompleted(subAgent)) {
|
|
637503
|
+
const incompleteText = this.telegramAdminIncompleteRunText(subAgent, finalText);
|
|
637504
|
+
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
637505
|
+
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "failed");
|
|
637506
|
+
if (!msg.guestQueryId) {
|
|
637507
|
+
await this.finalizeTelegramAdminLivePanel(subAgent, msg, incompleteText, "failed");
|
|
637508
|
+
} else if (subAgent.liveMessageId) {
|
|
637509
|
+
await this.deleteLiveMessage(msg.chatId, subAgent.liveMessageId).catch(() => {
|
|
637510
|
+
});
|
|
637511
|
+
}
|
|
637512
|
+
return;
|
|
637513
|
+
}
|
|
637353
637514
|
if (!finalText) {
|
|
637354
637515
|
if (msg.chatType !== "private") {
|
|
637355
637516
|
this.maybeLogTelegramGroupSkip(msg, "discretion: skipped reply");
|
|
@@ -637492,6 +637653,18 @@ Join: ${newUrl}`);
|
|
|
637492
637653
|
await subAgent.liveMessagePromise.catch(() => {
|
|
637493
637654
|
});
|
|
637494
637655
|
}
|
|
637656
|
+
if (!this.telegramAdminRunCompleted(subAgent)) {
|
|
637657
|
+
const incompleteText = this.telegramAdminIncompleteRunText(subAgent, finalText);
|
|
637658
|
+
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
637659
|
+
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "failed");
|
|
637660
|
+
if (!msg.guestQueryId) {
|
|
637661
|
+
await this.finalizeTelegramAdminLivePanel(subAgent, msg, incompleteText, "failed");
|
|
637662
|
+
} else if (subAgent.liveMessageId) {
|
|
637663
|
+
await this.deleteLiveMessage(msg.chatId, subAgent.liveMessageId).catch(() => {
|
|
637664
|
+
});
|
|
637665
|
+
}
|
|
637666
|
+
return;
|
|
637667
|
+
}
|
|
637495
637668
|
if (!finalText) {
|
|
637496
637669
|
if (!msg.guestQueryId) {
|
|
637497
637670
|
await this.finalizeTelegramAdminLivePanel(subAgent, msg, "", "completed");
|
|
@@ -637864,12 +638037,16 @@ ${conversationStream}`
|
|
|
637864
638037
|
config.model,
|
|
637865
638038
|
config.apiKey
|
|
637866
638039
|
);
|
|
638040
|
+
const requestTimeoutMs = config.timeoutMs ?? 3e5;
|
|
637867
638041
|
const runner = new AgenticRunner(backend, {
|
|
637868
|
-
|
|
637869
|
-
|
|
638042
|
+
// Admin DMs are operator-directed work sessions. A hard turn cap turns
|
|
638043
|
+
// active tool progress into a false "completed" Telegram panel when the
|
|
638044
|
+
// model has not reached task_complete yet. Public/group runs stay bounded.
|
|
638045
|
+
maxTurns: isAdminDM ? 0 : isAdminGroup ? 12 : 8,
|
|
638046
|
+
maxTokens: isAdminDM ? 8192 : 2048,
|
|
637870
638047
|
temperature: 0.3,
|
|
637871
|
-
requestTimeoutMs
|
|
637872
|
-
taskTimeoutMs: isAdminDM ?
|
|
638048
|
+
requestTimeoutMs,
|
|
638049
|
+
taskTimeoutMs: isAdminDM ? Math.max(requestTimeoutMs * 3, 9e5) : requestTimeoutMs,
|
|
637873
638050
|
compactionThreshold: this.telegramFallbackCompactionThreshold(modelTier),
|
|
637874
638051
|
contextWindowSize,
|
|
637875
638052
|
modelTier,
|
|
@@ -638096,6 +638273,11 @@ Telegram ${isGroup ? "group" : "public"} chat. Respond concisely. Safety filter:
|
|
|
638096
638273
|
|
|
638097
638274
|
${creativeWorkspace}` : ""}`;
|
|
638098
638275
|
const result = await runner.run(userPrompt, systemCtx);
|
|
638276
|
+
subAgent.runnerCompleted = result.completed;
|
|
638277
|
+
subAgent.runnerTurns = result.turns;
|
|
638278
|
+
subAgent.runnerToolCalls = result.toolCalls;
|
|
638279
|
+
subAgent.runnerSummary = result.summary;
|
|
638280
|
+
if (result.completed) subAgent.completionBoundarySeen = true;
|
|
638099
638281
|
return selectTelegramFinalResponse({
|
|
638100
638282
|
visibleReplyText: subAgent.visibleReplyText,
|
|
638101
638283
|
assistantText: subAgent.assistantText,
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.182",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.182",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED