omnius 1.0.172 → 1.0.174
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 +70 -13
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -562106,6 +562106,7 @@ ${description}`
|
|
|
562106
562106
|
if (effectiveThink === true && (effectiveMaxTokens ?? 0) < 4096) {
|
|
562107
562107
|
effectiveMaxTokens = 4096;
|
|
562108
562108
|
}
|
|
562109
|
+
const responseFormat = request.responseFormat ?? request.response_format;
|
|
562109
562110
|
const body = {
|
|
562110
562111
|
model: this.model,
|
|
562111
562112
|
messages: cleanedMessages,
|
|
@@ -562116,6 +562117,16 @@ ${description}`
|
|
|
562116
562117
|
stream_options: { include_usage: true },
|
|
562117
562118
|
think: effectiveThink
|
|
562118
562119
|
};
|
|
562120
|
+
if (responseFormat !== void 0) {
|
|
562121
|
+
body["response_format"] = responseFormat;
|
|
562122
|
+
}
|
|
562123
|
+
const reqNumCtx = request.numCtx;
|
|
562124
|
+
if (Number.isFinite(reqNumCtx) && (reqNumCtx ?? 0) > 0) {
|
|
562125
|
+
const opts = body["options"] ?? {};
|
|
562126
|
+
opts["num_ctx"] = reqNumCtx;
|
|
562127
|
+
body["options"] = opts;
|
|
562128
|
+
body["num_ctx"] = reqNumCtx;
|
|
562129
|
+
}
|
|
562119
562130
|
let poolSlot = shouldUseOllamaPoolForBaseUrl(this.baseUrl) ? await getOllamaPool({ baseInstanceUrl: this.baseUrl }).acquire({
|
|
562120
562131
|
model: this.model
|
|
562121
562132
|
}) : null;
|
|
@@ -627516,7 +627527,12 @@ function truncateTelegramUrlSafe(text, maxLength, suffix = "...") {
|
|
|
627516
627527
|
if (maxLength <= suffix.length) return normalized.slice(0, maxLength);
|
|
627517
627528
|
let cut = maxLength - suffix.length;
|
|
627518
627529
|
const span = telegramUrlSpanAt(normalized, cut);
|
|
627519
|
-
if (span)
|
|
627530
|
+
if (span) {
|
|
627531
|
+
cut = span.start;
|
|
627532
|
+
const tagStart = normalized.lastIndexOf("<", cut);
|
|
627533
|
+
const tagEnd = normalized.lastIndexOf(">", cut);
|
|
627534
|
+
if (tagStart > tagEnd) cut = tagStart;
|
|
627535
|
+
}
|
|
627520
627536
|
return `${normalized.slice(0, Math.max(0, cut)).trimEnd()}${suffix}`;
|
|
627521
627537
|
}
|
|
627522
627538
|
function splitTelegramMessageText(text, maxLength = 3900) {
|
|
@@ -633165,7 +633181,8 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633165
633181
|
backend,
|
|
633166
633182
|
{ ...suppressed, responseFormat: TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT },
|
|
633167
633183
|
inferenceKind,
|
|
633168
|
-
sessionKey
|
|
633184
|
+
sessionKey,
|
|
633185
|
+
{ stream: false, reason: "router-json" }
|
|
633169
633186
|
);
|
|
633170
633187
|
const visible = jsonModeResult.choices.some(
|
|
633171
633188
|
(choice) => stripTelegramHiddenThinking(choice.message.content ?? "").trim().length > 0
|
|
@@ -633187,7 +633204,8 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633187
633204
|
backend,
|
|
633188
633205
|
suppressed,
|
|
633189
633206
|
inferenceKind,
|
|
633190
|
-
sessionKey
|
|
633207
|
+
sessionKey,
|
|
633208
|
+
{ stream: false, reason: "router-plain-retry" }
|
|
633191
633209
|
);
|
|
633192
633210
|
if (diagnostics) {
|
|
633193
633211
|
const plainVisible = plainResult.choices.some(
|
|
@@ -633226,7 +633244,7 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633226
633244
|
* content tokens emitted, the registry shows it, and the
|
|
633227
633245
|
* hard-deadline retire path becomes diagnosable instead of opaque
|
|
633228
633246
|
*/
|
|
633229
|
-
async telegramObservableInference(backend, request, kind, sessionKey) {
|
|
633247
|
+
async telegramObservableInference(backend, request, kind, sessionKey, options2 = {}) {
|
|
633230
633248
|
const model = this.agentConfig?.model ?? "?";
|
|
633231
633249
|
const promptTokens = estimatePromptTokensFromRequest(request);
|
|
633232
633250
|
const broker = getModelBroker();
|
|
@@ -633254,7 +633272,17 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633254
633272
|
let completionTokens = 0;
|
|
633255
633273
|
try {
|
|
633256
633274
|
let result;
|
|
633257
|
-
|
|
633275
|
+
const streamAllowed = options2.stream !== false;
|
|
633276
|
+
if (!streamAllowed) {
|
|
633277
|
+
result = await backend.chatCompletion(requestWithCtx);
|
|
633278
|
+
this.updateTelegramInferenceFinal(id, result);
|
|
633279
|
+
if (!streamAllowed && process.env["OMNIUS_BROKER_TRACE"] === "1") {
|
|
633280
|
+
this.tuiWrite(() => renderTelegramSubAgentEvent(
|
|
633281
|
+
sessionKey,
|
|
633282
|
+
`inference ${id}: non-stream direct (${options2.reason ?? "requested"}) ${this.telegramInferenceRequestDiagnostic(requestWithCtx)}`
|
|
633283
|
+
));
|
|
633284
|
+
}
|
|
633285
|
+
} else if (typeof streamFn !== "function") {
|
|
633258
633286
|
result = await backend.chatCompletion(requestWithCtx);
|
|
633259
633287
|
this.updateTelegramInferenceFinal(id, result);
|
|
633260
633288
|
} else {
|
|
@@ -633284,6 +633312,28 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633284
633312
|
this.deregisterTelegramInference(id);
|
|
633285
633313
|
}
|
|
633286
633314
|
}
|
|
633315
|
+
telegramBackendDiagnostic() {
|
|
633316
|
+
const config = this.agentConfig;
|
|
633317
|
+
if (!config) return "backend=unconfigured model=?";
|
|
633318
|
+
return `backend=${config.backendType} url=${config.backendUrl} model=${config.model}`;
|
|
633319
|
+
}
|
|
633320
|
+
telegramInferenceRequestDiagnostic(request) {
|
|
633321
|
+
const responseFormat = request.responseFormat ?? request.response_format;
|
|
633322
|
+
const responseFormatType = responseFormat && typeof responseFormat["type"] === "string" ? responseFormat["type"] : responseFormat ? "present" : "none";
|
|
633323
|
+
const numCtx = request.numCtx;
|
|
633324
|
+
const think = request.think;
|
|
633325
|
+
const tools = Array.isArray(request.tools) ? request.tools.length : 0;
|
|
633326
|
+
return `${this.telegramBackendDiagnostic()} response_format=${responseFormatType} num_ctx=${Number.isFinite(numCtx) ? numCtx : "unset"} think=${think === void 0 ? "default" : String(think)} tools=${tools} timeoutMs=${Number.isFinite(request.timeoutMs) ? request.timeoutMs : "unset"}`;
|
|
633327
|
+
}
|
|
633328
|
+
telegramStreamInactivityDiagnostic(request, inferenceId, inactivityMs, contentChars, thinkingChars) {
|
|
633329
|
+
const entry = this.telegramActiveInferences.get(inferenceId);
|
|
633330
|
+
const now = performance.now();
|
|
633331
|
+
const elapsed = entry ? `${((now - entry.startTs) / 1e3).toFixed(1)}s` : "unknown";
|
|
633332
|
+
const idle = entry ? `${((now - entry.lastTokenAt) / 1e3).toFixed(1)}s` : "unknown";
|
|
633333
|
+
const ttfb = entry?.firstChunkAt !== void 0 ? `${((entry.firstChunkAt - entry.startTs) / 1e3).toFixed(1)}s` : "never";
|
|
633334
|
+
const phase = entry?.firstChunkAt === void 0 ? "before-first-chunk" : "mid-stream";
|
|
633335
|
+
return `stream-inactivity: no chunks for ${(inactivityMs / 1e3).toFixed(0)}s (phase=${phase}; elapsed=${elapsed}; idle=${idle}; ttfb=${ttfb}; content=${contentChars}c thinking=${thinkingChars}c; ${this.telegramInferenceRequestDiagnostic(request)}; stream_endpoint=no-sse-chunk)`;
|
|
633336
|
+
}
|
|
633287
633337
|
/**
|
|
633288
633338
|
* Drive a chatCompletionStream to exhaustion, accumulating tokens into a
|
|
633289
633339
|
* chatCompletion-shaped result. Live-emits content + thinking tokens
|
|
@@ -633320,7 +633370,13 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
633320
633370
|
const inactivityPromise = new Promise((_, reject) => {
|
|
633321
633371
|
timeoutHandle = setTimeout(
|
|
633322
633372
|
() => reject(new Error(
|
|
633323
|
-
|
|
633373
|
+
this.telegramStreamInactivityDiagnostic(
|
|
633374
|
+
request,
|
|
633375
|
+
inferenceId,
|
|
633376
|
+
inactivityMs,
|
|
633377
|
+
contentBuf.length,
|
|
633378
|
+
thinkingBuf.length
|
|
633379
|
+
)
|
|
633324
633380
|
)),
|
|
633325
633381
|
inactivityMs
|
|
633326
633382
|
);
|
|
@@ -634175,6 +634231,7 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`
|
|
|
634175
634231
|
composeTelegramRouterDiagnosticNote(invalidRouterPreview, failureNarrative, headline) {
|
|
634176
634232
|
const segments = [];
|
|
634177
634233
|
segments.push(headline);
|
|
634234
|
+
segments.push(this.telegramBackendDiagnostic());
|
|
634178
634235
|
if (failureNarrative.summary) segments.push(failureNarrative.summary);
|
|
634179
634236
|
if (invalidRouterPreview) segments.push(`invalid router output preview: ${invalidRouterPreview}`);
|
|
634180
634237
|
if (failureNarrative.detail) segments.push(`router-failure trace: ${failureNarrative.detail}`);
|
|
@@ -634781,7 +634838,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
634781
634838
|
*/
|
|
634782
634839
|
async editLiveMessage(chatId, messageId, html) {
|
|
634783
634840
|
const normalizedHtml = normalizeTelegramOutboundLinks(html);
|
|
634784
|
-
const truncated = normalizedHtml.length > 4e3 ? normalizedHtml
|
|
634841
|
+
const truncated = normalizedHtml.length > 4e3 ? truncateTelegramUrlSafe(normalizedHtml, 4e3, "\n\n<i>... (streaming)</i>") : normalizedHtml;
|
|
634785
634842
|
try {
|
|
634786
634843
|
const result = await this.apiCall("editMessageText", {
|
|
634787
634844
|
chat_id: chatId,
|
|
@@ -634795,7 +634852,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`);
|
|
|
634795
634852
|
} catch {
|
|
634796
634853
|
try {
|
|
634797
634854
|
const plain = normalizedHtml.replace(/<[^>]+>/g, "");
|
|
634798
|
-
const truncPlain = plain.length > 4e3 ? plain
|
|
634855
|
+
const truncPlain = plain.length > 4e3 ? truncateTelegramUrlSafe(plain, 4e3, "\n\n... (streaming)") : plain;
|
|
634799
634856
|
const result = await this.apiCall("editMessageText", {
|
|
634800
634857
|
chat_id: chatId,
|
|
634801
634858
|
message_id: messageId,
|
|
@@ -637237,7 +637294,7 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
637237
637294
|
reply_to_message_id: entry.replyToMessageId,
|
|
637238
637295
|
chat_type: entry.chatType,
|
|
637239
637296
|
chat_title: entry.chatTitle,
|
|
637240
|
-
text: redactTelegramLocalPaths(stripTelegramHiddenThinking(entry.text || ""))
|
|
637297
|
+
text: truncateTelegramUrlSafe(redactTelegramLocalPaths(stripTelegramHiddenThinking(entry.text || "")), 4e3)
|
|
637241
637298
|
};
|
|
637242
637299
|
if (entry.mediaSummary) {
|
|
637243
637300
|
safe["media_summary"] = redactTelegramLocalPaths(entry.mediaSummary);
|
|
@@ -637248,13 +637305,13 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
637248
637305
|
source: entry.replyContext.source,
|
|
637249
637306
|
message_id: entry.replyContext.messageId,
|
|
637250
637307
|
sender: entry.replyContext.sender ? telegramReplySenderLabel(entry.replyContext.sender) : void 0,
|
|
637251
|
-
text: entry.replyContext.text ? redactTelegramLocalPaths(stripTelegramHiddenThinking(entry.replyContext.text))
|
|
637252
|
-
caption: entry.replyContext.caption ? redactTelegramLocalPaths(entry.replyContext.caption)
|
|
637308
|
+
text: entry.replyContext.text ? truncateTelegramUrlSafe(redactTelegramLocalPaths(stripTelegramHiddenThinking(entry.replyContext.text)), 2e3) : void 0,
|
|
637309
|
+
caption: entry.replyContext.caption ? truncateTelegramUrlSafe(redactTelegramLocalPaths(entry.replyContext.caption), 1200) : void 0,
|
|
637253
637310
|
media_summary: entry.replyContext.mediaSummary ? redactTelegramLocalPaths(entry.replyContext.mediaSummary) : void 0
|
|
637254
637311
|
};
|
|
637255
637312
|
}
|
|
637256
637313
|
if (includePrivate && entry.generatedMediaPromptInfo?.originalPrompt) {
|
|
637257
|
-
safe["generated_image_prompt"] = redactTelegramLocalPaths(entry.generatedMediaPromptInfo.originalPrompt)
|
|
637314
|
+
safe["generated_image_prompt"] = truncateTelegramUrlSafe(redactTelegramLocalPaths(entry.generatedMediaPromptInfo.originalPrompt), 2e3);
|
|
637258
637315
|
}
|
|
637259
637316
|
return safe;
|
|
637260
637317
|
}
|
|
@@ -638886,7 +638943,7 @@ Content-Type: ${mimeForPath(pathOrFileId, field === "photo" ? "image" : "video")
|
|
|
638886
638943
|
*/
|
|
638887
638944
|
async answerGuestQuery(guestQueryId, text, options2 = {}) {
|
|
638888
638945
|
const normalizedText = normalizeTelegramOutboundLinks(text);
|
|
638889
|
-
const truncated = normalizedText.length > 4e3 ? normalizedText
|
|
638946
|
+
const truncated = normalizedText.length > 4e3 ? truncateTelegramUrlSafe(normalizedText, 4e3, "\n\n... (truncated)") : normalizedText;
|
|
638890
638947
|
const inputMessageContent = {
|
|
638891
638948
|
message_text: truncated
|
|
638892
638949
|
};
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.174",
|
|
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.174",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED