omnius 1.0.649 → 1.0.650
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 +586 -178
- package/dist/launcher.cjs +0 -0
- package/dist/update-worker.js +4 -5
- package/docs/OMNIUS-RELIABILITY-LONG-HORIZON-TODO.md +189 -7
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -622370,7 +622370,7 @@ function validateGraphCollections(value2, ctx3) {
|
|
|
622370
622370
|
});
|
|
622371
622371
|
});
|
|
622372
622372
|
}
|
|
622373
|
-
var OPERATIONAL_WORLD_SCHEMA_VERSION, OperationalWorldSchemaVersionSchema, OperationalWorldIdSchema, OperationalWorldRevisionSchema, ConfidenceSchema, LineRangeLocatorSchema, CharacterRangeLocatorSchema, PageRangeLocatorSchema, SheetRangeLocatorSchema, TableRangeLocatorSchema, JsonPathLocatorSchema, HeadingLocatorSchema, FieldLocatorSchema, UriFragmentLocatorSchema, EvidenceLocatorSchema, SourceAuthoritySchema, SourceFreshnessSchema, SourceReadPolicySchema, SourceBindingSchema, EvidenceRoleSchema, EvidenceRefSchema, ClaimKindSchema, ClaimPolaritySchema, ClaimStatusSchema, WorkGraphNodeAuthoritySchema, ClaimSchema, ConflictKindSchema, ConflictStatusSchema, ConflictResolutionSchema, ConflictSchema, WorkGraphNodeKindSchema, WorkGraphNodeStatusSchema, WorkGraphTargetRefSchema, WorkActionPreconditionSchema, WorkActionMutationSchema, WorkActionApprovalSchema, WorkActionContractSchema, WorkGraphNodeReferenceSchema, WorkGraphNodeSchema, WorkGraphEdgeKindSchema, WorkGraphEdgeSchema, WorkGraphSchema, WorldPatchOperationSchema, WorldPatchSchema, ValidationIssueSeveritySchema, OperationalValidationIssueSchema, OperationalValidationStatusSchema, OperationalValidationResultSchema, ValidationArtifactHashSchema, OperationalValidationReceiptSchema, ReasoningSliceSelectionSchema, ReasoningSliceSchema;
|
|
622373
|
+
var OPERATIONAL_WORLD_SCHEMA_VERSION, OperationalWorldSchemaVersionSchema, OperationalWorldIdSchema, OperationalWorldRevisionSchema, ConfidenceSchema, JsonValueSchema, LineRangeLocatorSchema, CharacterRangeLocatorSchema, PageRangeLocatorSchema, SheetRangeLocatorSchema, TableRangeLocatorSchema, JsonPathLocatorSchema, HeadingLocatorSchema, FieldLocatorSchema, UriFragmentLocatorSchema, EvidenceLocatorSchema, SourceAuthoritySchema, SourceFreshnessSchema, SourceReadPolicySchema, SourceBindingSchema, EvidenceRoleSchema, EvidenceRefSchema, ClaimKindSchema, ClaimPolaritySchema, ClaimStatusSchema, WorkGraphNodeAuthoritySchema, ClaimSchema, ConflictKindSchema, ConflictStatusSchema, ConflictResolutionSchema, ConflictSchema, WorkGraphNodeKindSchema, WorkGraphNodeStatusSchema, WorkGraphTargetRefSchema, WorkActionPreconditionSchema, WorkActionMutationSchema, WorkActionApprovalSchema, WorkActionContractSchema, WorkGraphNodeReferenceSchema, WorkGraphNodeSchema, WorkGraphEdgeKindSchema, WorkGraphEdgeSchema, WorkGraphSchema, WorldPatchOperationSchema, WorldPatchSchema, ValidationIssueSeveritySchema, OperationalValidationIssueSchema, OperationalValidationStatusSchema, OperationalValidationResultSchema, ValidationArtifactHashSchema, OperationalValidationReceiptSchema, ReasoningSliceSelectionSchema, ReasoningSliceSchema;
|
|
622374
622374
|
var init_operational_world = __esm({
|
|
622375
622375
|
"packages/schemas/dist/operational-world.js"() {
|
|
622376
622376
|
"use strict";
|
|
@@ -622379,6 +622379,14 @@ var init_operational_world = __esm({
|
|
|
622379
622379
|
OperationalWorldIdSchema = z16.string().trim().min(1).max(256);
|
|
622380
622380
|
OperationalWorldRevisionSchema = z16.string().trim().min(1).max(256);
|
|
622381
622381
|
ConfidenceSchema = z16.number().finite().min(0).max(1);
|
|
622382
|
+
JsonValueSchema = z16.lazy(() => z16.union([
|
|
622383
|
+
z16.string(),
|
|
622384
|
+
z16.number().finite(),
|
|
622385
|
+
z16.boolean(),
|
|
622386
|
+
z16.null(),
|
|
622387
|
+
z16.array(JsonValueSchema),
|
|
622388
|
+
z16.record(z16.string(), JsonValueSchema)
|
|
622389
|
+
]));
|
|
622382
622390
|
LineRangeLocatorSchema = z16.object({
|
|
622383
622391
|
type: z16.literal("line_range"),
|
|
622384
622392
|
startLine: z16.number().int().positive(),
|
|
@@ -622583,7 +622591,7 @@ var init_operational_world = __esm({
|
|
|
622583
622591
|
/** Structured proposition fields used to group competing claims. */
|
|
622584
622592
|
subjectNodeId: OperationalWorldIdSchema.optional(),
|
|
622585
622593
|
predicate: z16.string().trim().min(1).max(512).optional(),
|
|
622586
|
-
objectValue:
|
|
622594
|
+
objectValue: JsonValueSchema.optional(),
|
|
622587
622595
|
validFrom: z16.string().datetime().optional(),
|
|
622588
622596
|
validTo: z16.string().datetime().optional(),
|
|
622589
622597
|
authority: WorkGraphNodeAuthoritySchema.optional()
|
|
@@ -622753,7 +622761,7 @@ var init_operational_world = __esm({
|
|
|
622753
622761
|
evidenceRefIds: z16.array(OperationalWorldIdSchema).max(256),
|
|
622754
622762
|
reference: WorkGraphNodeReferenceSchema.optional(),
|
|
622755
622763
|
actionContract: WorkActionContractSchema.optional(),
|
|
622756
|
-
attributes: z16.record(z16.string(),
|
|
622764
|
+
attributes: z16.record(z16.string(), JsonValueSchema)
|
|
622757
622765
|
}).strict().superRefine((node, ctx3) => {
|
|
622758
622766
|
const expectedReference = node.kind === "claim" ? "claim" : node.kind === "conflict" ? "conflict" : node.kind === "evidence" ? "evidence" : null;
|
|
622759
622767
|
if (expectedReference && node.reference?.type !== expectedReference) {
|
|
@@ -622811,7 +622819,7 @@ var init_operational_world = __esm({
|
|
|
622811
622819
|
directed: z16.boolean(),
|
|
622812
622820
|
evidenceRefIds: z16.array(OperationalWorldIdSchema).max(256),
|
|
622813
622821
|
confidence: ConfidenceSchema,
|
|
622814
|
-
attributes: z16.record(z16.string(),
|
|
622822
|
+
attributes: z16.record(z16.string(), JsonValueSchema)
|
|
622815
622823
|
}).strict().superRefine((edge, ctx3) => {
|
|
622816
622824
|
if (edge.sourceNodeId === edge.targetNodeId) {
|
|
622817
622825
|
ctx3.addIssue({
|
|
@@ -630516,6 +630524,14 @@ function sameLocalEndpoint(a2, b) {
|
|
|
630516
630524
|
return true;
|
|
630517
630525
|
return isLocalHost(a2.hostname) && isLocalHost(b.hostname);
|
|
630518
630526
|
}
|
|
630527
|
+
function matchesOllamaUnifyDiscovery(parsed, discovery) {
|
|
630528
|
+
for (const managed of [discovery.publicUrl, discovery.backendUrl]) {
|
|
630529
|
+
if (managed && sameLocalEndpoint(parsed, managed))
|
|
630530
|
+
return true;
|
|
630531
|
+
}
|
|
630532
|
+
const requestedPort = Number(effectivePort(parsed));
|
|
630533
|
+
return discovery.privatePortStart !== null && discovery.privatePortEnd !== null && requestedPort >= discovery.privatePortStart && requestedPort <= discovery.privatePortEnd;
|
|
630534
|
+
}
|
|
630519
630535
|
function isOllamaUnifyManagedEndpoint(baseUrl3) {
|
|
630520
630536
|
const parsed = parseBaseUrlForPool(baseUrl3);
|
|
630521
630537
|
if (!parsed || !isLocalHost(parsed.hostname))
|
|
@@ -630523,19 +630539,30 @@ function isOllamaUnifyManagedEndpoint(baseUrl3) {
|
|
|
630523
630539
|
const discoveryPath = process.env["OMNIUS_OLLAMA_UNIFY_DISCOVERY_PATH"]?.trim() || DEFAULT_OLLAMA_UNIFY_DISCOVERY_PATH;
|
|
630524
630540
|
try {
|
|
630525
630541
|
const document2 = JSON.parse(readFileSync79(discoveryPath, "utf8"));
|
|
630526
|
-
if (document2.protocol !== "ollama-unify-gpu-lease/v1")
|
|
630527
|
-
|
|
630528
|
-
|
|
630529
|
-
|
|
630530
|
-
|
|
630531
|
-
|
|
630532
|
-
|
|
630533
|
-
|
|
630534
|
-
|
|
630535
|
-
|
|
630536
|
-
|
|
630537
|
-
|
|
630542
|
+
if (document2.protocol !== "ollama-unify-gpu-lease/v1") {
|
|
630543
|
+
throw new Error("invalid ollama-unify discovery protocol");
|
|
630544
|
+
}
|
|
630545
|
+
const rawPrivateStart = Number(document2.parallel_pool?.private_port_start);
|
|
630546
|
+
const rawPrivateEnd = Number(document2.parallel_pool?.private_port_end);
|
|
630547
|
+
const privatePortStart = Number.isInteger(rawPrivateStart) && rawPrivateStart > 0 ? rawPrivateStart : null;
|
|
630548
|
+
const privatePortEnd = privatePortStart !== null && Number.isInteger(rawPrivateEnd) && rawPrivateEnd >= privatePortStart ? rawPrivateEnd : null;
|
|
630549
|
+
const discovery = {
|
|
630550
|
+
publicUrl: typeof document2.public_ollama_api === "string" ? parseBaseUrlForPool(document2.public_ollama_api) : null,
|
|
630551
|
+
backendUrl: typeof document2.ollama_backend === "string" ? parseBaseUrlForPool(document2.ollama_backend) : null,
|
|
630552
|
+
privatePortStart,
|
|
630553
|
+
privatePortEnd
|
|
630554
|
+
};
|
|
630555
|
+
ollamaUnifyDiscoveryCache.set(discoveryPath, discovery);
|
|
630556
|
+
return matchesOllamaUnifyDiscovery(parsed, discovery);
|
|
630538
630557
|
} catch {
|
|
630558
|
+
const cached2 = ollamaUnifyDiscoveryCache.get(discoveryPath);
|
|
630559
|
+
if (cached2)
|
|
630560
|
+
return matchesOllamaUnifyDiscovery(parsed, cached2);
|
|
630561
|
+
const installedMarker = existsSync99(discoveryPath) || discoveryPath === DEFAULT_OLLAMA_UNIFY_DISCOVERY_PATH && (existsSync99("/usr/local/libexec/ollama-unify-gpu-negotiator") || existsSync99("/run/ollama-unify/gpu-negotiator.sock"));
|
|
630562
|
+
if (installedMarker) {
|
|
630563
|
+
const port2 = Number(effectivePort(parsed));
|
|
630564
|
+
return port2 >= 11434 && port2 <= 11468;
|
|
630565
|
+
}
|
|
630539
630566
|
}
|
|
630540
630567
|
return false;
|
|
630541
630568
|
}
|
|
@@ -630543,8 +630570,7 @@ function shouldUseOllamaPoolForBaseUrl(baseUrl3) {
|
|
|
630543
630570
|
const mode = (process.env["OMNIUS_OLLAMA_POOL"] ?? "").toLowerCase();
|
|
630544
630571
|
if (mode === "0" || mode === "false" || mode === "off")
|
|
630545
630572
|
return false;
|
|
630546
|
-
|
|
630547
|
-
if (!allowBrokerBypass && isOllamaUnifyManagedEndpoint(baseUrl3)) {
|
|
630573
|
+
if (isOllamaUnifyManagedEndpoint(baseUrl3)) {
|
|
630548
630574
|
return false;
|
|
630549
630575
|
}
|
|
630550
630576
|
const parsed = parseBaseUrlForPool(baseUrl3);
|
|
@@ -630579,7 +630605,7 @@ function setOllamaPool(pool3) {
|
|
|
630579
630605
|
_poolByBaseUrl.set(pool3.statusConfig().baseInstanceUrl, pool3);
|
|
630580
630606
|
}
|
|
630581
630607
|
}
|
|
630582
|
-
var _nvidiaSmiAvailable, DEFAULT_MIN_GPU_VRAM_MB, DEFAULT_MIN_COMPUTE_CAPABILITY, _lastNetworkSnapshot, OllamaInstance, realInstanceSpawner, _gpuCursor, OllamaPool, DEFAULT_OLLAMA_UNIFY_DISCOVERY_PATH, _poolSingleton, _poolByBaseUrl;
|
|
630608
|
+
var _nvidiaSmiAvailable, DEFAULT_MIN_GPU_VRAM_MB, DEFAULT_MIN_COMPUTE_CAPABILITY, _lastNetworkSnapshot, OllamaInstance, realInstanceSpawner, _gpuCursor, OllamaPool, DEFAULT_OLLAMA_UNIFY_DISCOVERY_PATH, ollamaUnifyDiscoveryCache, _poolSingleton, _poolByBaseUrl;
|
|
630583
630609
|
var init_ollama_pool = __esm({
|
|
630584
630610
|
"packages/orchestrator/dist/ollama-pool.js"() {
|
|
630585
630611
|
"use strict";
|
|
@@ -631553,6 +631579,7 @@ var init_ollama_pool = __esm({
|
|
|
631553
631579
|
}
|
|
631554
631580
|
};
|
|
631555
631581
|
DEFAULT_OLLAMA_UNIFY_DISCOVERY_PATH = "/usr/local/share/ollama-unify/gpu-negotiator.json";
|
|
631582
|
+
ollamaUnifyDiscoveryCache = /* @__PURE__ */ new Map();
|
|
631556
631583
|
_poolSingleton = null;
|
|
631557
631584
|
_poolByBaseUrl = /* @__PURE__ */ new Map();
|
|
631558
631585
|
}
|
|
@@ -653904,6 +653931,7 @@ runtime_module_sha256=${record.runtimeProvenance.module.sha256 ?? "unknown"}`
|
|
|
653904
653931
|
this._explicitCompactionThreshold = typeof options2?.compactionThreshold === "number";
|
|
653905
653932
|
this.options = {
|
|
653906
653933
|
maxTurns: options2?.maxTurns ?? 60,
|
|
653934
|
+
acceptTextOnlyCompletion: options2?.acceptTextOnlyCompletion ?? false,
|
|
653907
653935
|
maxTokens: options2?.maxTokens ?? 16384,
|
|
653908
653936
|
temperature: options2?.temperature ?? 0,
|
|
653909
653937
|
requestTimeoutMs: options2?.requestTimeoutMs ?? 3e5,
|
|
@@ -671605,6 +671633,18 @@ Only call task_complete when the task is actually complete and the evidence is f
|
|
|
671605
671633
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
671606
671634
|
});
|
|
671607
671635
|
}
|
|
671636
|
+
if (this.options.acceptTextOnlyCompletion && cleanNonStream) {
|
|
671637
|
+
completed = true;
|
|
671638
|
+
summary = cleanNonStream;
|
|
671639
|
+
this._onTypedEvent?.({
|
|
671640
|
+
type: "completion_requested",
|
|
671641
|
+
runId: this.currentArtifactRunId(),
|
|
671642
|
+
summary: cleanNonStream.slice(0, 500),
|
|
671643
|
+
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
671644
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
671645
|
+
});
|
|
671646
|
+
break;
|
|
671647
|
+
}
|
|
671608
671648
|
this.adversaryObserve(messages2, turn);
|
|
671609
671649
|
if (/task.?complete|all tests pass/i.test(content)) {
|
|
671610
671650
|
const completionArgs = { summary: content };
|
|
@@ -687788,6 +687828,7 @@ __export(dist_exports3, {
|
|
|
687788
687828
|
isConcurrencySafe: () => isConcurrencySafe,
|
|
687789
687829
|
isCorrection: () => isCorrection,
|
|
687790
687830
|
isHandoffVague: () => isHandoffVague,
|
|
687831
|
+
isOllamaUnifyManagedEndpoint: () => isOllamaUnifyManagedEndpoint,
|
|
687791
687832
|
isSuccessfulRunFinished: () => isSuccessfulRunFinished,
|
|
687792
687833
|
isTerminalRunEvent: () => isTerminalRunEvent,
|
|
687793
687834
|
isTerminalTaskStatus: () => isTerminalTaskStatus,
|
|
@@ -688640,6 +688681,7 @@ __export(daemon_exports, {
|
|
|
688640
688681
|
getLocalCliVersion: () => getLocalCliVersion,
|
|
688641
688682
|
isDaemonRunning: () => isDaemonRunning,
|
|
688642
688683
|
managedDaemonServiceOwnsPort: () => managedDaemonServiceOwnsPort,
|
|
688684
|
+
observeDaemonIdentityBoundedly: () => observeDaemonIdentityBoundedly,
|
|
688643
688685
|
pidIsInManagedDaemonUnit: () => pidIsInManagedDaemonUnit,
|
|
688644
688686
|
quiesceDaemonForUpdate: () => quiesceDaemonForUpdate,
|
|
688645
688687
|
reclaimOwnedDaemonListener: () => reclaimOwnedDaemonListener,
|
|
@@ -688801,6 +688843,7 @@ async function getDaemonReportedIdentity(port2) {
|
|
|
688801
688843
|
const resp = await fetch(`http://127.0.0.1:${p2}/health`, { signal: AbortSignal.timeout(2e3) });
|
|
688802
688844
|
if (!resp.ok) return null;
|
|
688803
688845
|
const data = await resp.json();
|
|
688846
|
+
if (data.status !== "ok") return null;
|
|
688804
688847
|
const version5 = data.boot_version ?? data.version;
|
|
688805
688848
|
if (!version5) return null;
|
|
688806
688849
|
return {
|
|
@@ -688815,12 +688858,22 @@ async function getDaemonReportedIdentity(port2) {
|
|
|
688815
688858
|
async function getDaemonReportedVersion(port2) {
|
|
688816
688859
|
return (await getDaemonReportedIdentity(port2))?.bootVersion ?? null;
|
|
688817
688860
|
}
|
|
688861
|
+
async function observeDaemonIdentityBoundedly(port2 = getDaemonPort(), attempts = 3, pauseMs = 150) {
|
|
688862
|
+
const boundedAttempts = Math.max(1, Math.min(5, Math.floor(attempts)));
|
|
688863
|
+
for (let attempt = 0; attempt < boundedAttempts; attempt++) {
|
|
688864
|
+
const identity3 = await getDaemonReportedIdentity(port2);
|
|
688865
|
+
if (identity3) return identity3;
|
|
688866
|
+
if (attempt + 1 < boundedAttempts && pauseMs > 0) await delay3(pauseMs);
|
|
688867
|
+
}
|
|
688868
|
+
return null;
|
|
688869
|
+
}
|
|
688818
688870
|
async function waitForDaemonReady(port2, expectedVersion, attempts = 24) {
|
|
688819
688871
|
let observedVersion = null;
|
|
688820
688872
|
for (let attempt = 0; attempt < attempts; attempt++) {
|
|
688821
688873
|
await new Promise((resolve91) => setTimeout(resolve91, 500));
|
|
688822
|
-
|
|
688823
|
-
|
|
688874
|
+
const identity3 = await getDaemonReportedIdentity(port2);
|
|
688875
|
+
if (!identity3) continue;
|
|
688876
|
+
observedVersion = identity3.bootVersion;
|
|
688824
688877
|
if (!expectedVersion || expectedVersion === "0.0.0" || observedVersion === expectedVersion) {
|
|
688825
688878
|
return { ok: true, observedVersion };
|
|
688826
688879
|
}
|
|
@@ -689461,9 +689514,10 @@ async function ensureDaemonVersion(expectedVersion = getLocalCliVersion(), port2
|
|
|
689461
689514
|
recoveryAttempts,
|
|
689462
689515
|
requiresPrivilegedMigration
|
|
689463
689516
|
});
|
|
689464
|
-
|
|
689517
|
+
const runningIdentity = await observeDaemonIdentityBoundedly(port2);
|
|
689518
|
+
if (runningIdentity) {
|
|
689465
689519
|
if (process.env["OMNIUS_NO_VERSION_GUARD"] !== "1") {
|
|
689466
|
-
const running =
|
|
689520
|
+
const running = runningIdentity.bootVersion;
|
|
689467
689521
|
if (expectedVersion !== "0.0.0" && running !== expectedVersion) {
|
|
689468
689522
|
const recovery = await recoverDaemonVersionBoundedly(
|
|
689469
689523
|
expectedVersion,
|
|
@@ -689479,7 +689533,7 @@ async function ensureDaemonVersion(expectedVersion = getLocalCliVersion(), port2
|
|
|
689479
689533
|
);
|
|
689480
689534
|
}
|
|
689481
689535
|
}
|
|
689482
|
-
return finish2(true, "unchanged",
|
|
689536
|
+
return finish2(true, "unchanged", runningIdentity.bootVersion);
|
|
689483
689537
|
}
|
|
689484
689538
|
const reclaimed = await reclaimOwnedDaemonListener(port2);
|
|
689485
689539
|
if (!reclaimed.ok) {
|
|
@@ -689506,8 +689560,9 @@ async function ensureDaemonVersion(expectedVersion = getLocalCliVersion(), port2
|
|
|
689506
689560
|
if (!pid) {
|
|
689507
689561
|
for (let i2 = 0; i2 < 20; i2++) {
|
|
689508
689562
|
await new Promise((r2) => setTimeout(r2, 500));
|
|
689509
|
-
|
|
689510
|
-
|
|
689563
|
+
const identity3 = await getDaemonReportedIdentity(port2);
|
|
689564
|
+
if (identity3) {
|
|
689565
|
+
const observedVersion = identity3.bootVersion;
|
|
689511
689566
|
const versionMatches = expectedVersion === "0.0.0" || observedVersion === expectedVersion;
|
|
689512
689567
|
return finish2(versionMatches, versionMatches ? "started" : "failed", observedVersion);
|
|
689513
689568
|
}
|
|
@@ -706052,6 +706107,31 @@ var init_syntax_highlight = __esm({
|
|
|
706052
706107
|
|
|
706053
706108
|
// packages/cli/src/tui/model-picker.ts
|
|
706054
706109
|
import { totalmem as totalmem6 } from "node:os";
|
|
706110
|
+
function fetchOllamaModelNames(baseUrl3) {
|
|
706111
|
+
const normalized4 = normalizeBaseUrl(baseUrl3);
|
|
706112
|
+
const existing = ollamaModelNameRequests.get(normalized4);
|
|
706113
|
+
if (existing) return existing;
|
|
706114
|
+
const request = (async () => {
|
|
706115
|
+
const response = await fetch(`${normalized4}/api/tags`, {
|
|
706116
|
+
signal: AbortSignal.timeout(1e4)
|
|
706117
|
+
});
|
|
706118
|
+
if (!response.ok) {
|
|
706119
|
+
throw new Error(`Failed to fetch models: HTTP ${response.status}`);
|
|
706120
|
+
}
|
|
706121
|
+
const data = await response.json();
|
|
706122
|
+
return (data.models ?? []).map(
|
|
706123
|
+
(entry) => typeof entry.name === "string" ? entry.name : typeof entry.model === "string" ? entry.model : ""
|
|
706124
|
+
).filter((name10) => name10.length > 0);
|
|
706125
|
+
})();
|
|
706126
|
+
ollamaModelNameRequests.set(normalized4, request);
|
|
706127
|
+
void request.finally(() => {
|
|
706128
|
+
if (ollamaModelNameRequests.get(normalized4) === request) {
|
|
706129
|
+
ollamaModelNameRequests.delete(normalized4);
|
|
706130
|
+
}
|
|
706131
|
+
}).catch(() => {
|
|
706132
|
+
});
|
|
706133
|
+
return request;
|
|
706134
|
+
}
|
|
706055
706135
|
function isImageGenModel(name10, family) {
|
|
706056
706136
|
return IMAGE_GEN_PATTERNS.some((p2) => p2.test(name10) || family && p2.test(family));
|
|
706057
706137
|
}
|
|
@@ -706393,6 +706473,12 @@ async function fetchModels(baseUrl3, apiKey) {
|
|
|
706393
706473
|
function stripLatest(modelName) {
|
|
706394
706474
|
return modelName.replace(/:latest$/i, "");
|
|
706395
706475
|
}
|
|
706476
|
+
function findExactModel(models, query) {
|
|
706477
|
+
const canonicalQuery = stripLatest(query.trim());
|
|
706478
|
+
return models.find(
|
|
706479
|
+
(model) => stripLatest(model.name.trim()) === canonicalQuery
|
|
706480
|
+
);
|
|
706481
|
+
}
|
|
706396
706482
|
function findModel(models, query) {
|
|
706397
706483
|
const exact = models.find((m2) => m2.name === query);
|
|
706398
706484
|
if (exact) return exact;
|
|
@@ -706702,10 +706788,11 @@ function formatRelativeTime(iso4) {
|
|
|
706702
706788
|
const months = Math.floor(days / 30);
|
|
706703
706789
|
return `${months}mo ago`;
|
|
706704
706790
|
}
|
|
706705
|
-
var IMAGE_GEN_PATTERNS, LLAMA_CPP_TELEMETRY_TIMEOUT_MS, CONTEXT_CAPACITY_KEYS;
|
|
706791
|
+
var ollamaModelNameRequests, IMAGE_GEN_PATTERNS, LLAMA_CPP_TELEMETRY_TIMEOUT_MS, CONTEXT_CAPACITY_KEYS;
|
|
706706
706792
|
var init_model_picker = __esm({
|
|
706707
706793
|
"packages/cli/src/tui/model-picker.ts"() {
|
|
706708
706794
|
init_dist6();
|
|
706795
|
+
ollamaModelNameRequests = /* @__PURE__ */ new Map();
|
|
706709
706796
|
IMAGE_GEN_PATTERNS = [
|
|
706710
706797
|
/flux/i,
|
|
706711
706798
|
/z-image/i,
|
|
@@ -728914,6 +729001,7 @@ var setup_exports = {};
|
|
|
728914
729001
|
__export(setup_exports, {
|
|
728915
729002
|
calculateContextWindow: () => calculateContextWindow,
|
|
728916
729003
|
checkExpandedVariant: () => checkExpandedVariant,
|
|
729004
|
+
checkModelAvailability: () => checkModelAvailability,
|
|
728917
729005
|
checkOllamaUpdate: () => checkOllamaUpdate,
|
|
728918
729006
|
checkPythonVenv: () => checkPythonVenv,
|
|
728919
729007
|
checkToolSupport: () => checkToolSupport,
|
|
@@ -729792,7 +729880,34 @@ async function installOllamaWindows() {
|
|
|
729792
729880
|
return false;
|
|
729793
729881
|
}
|
|
729794
729882
|
}
|
|
729795
|
-
async function startApprovedOllamaServe() {
|
|
729883
|
+
async function startApprovedOllamaServe(backendUrl2 = "http://127.0.0.1:11434") {
|
|
729884
|
+
if (isOllamaUnifyManagedEndpoint(backendUrl2)) {
|
|
729885
|
+
if (!hasCmd("systemctl")) {
|
|
729886
|
+
process.stdout.write(
|
|
729887
|
+
` ${c3.red("✖")} The Ollama endpoint is owned by ollama-unify, but systemctl is unavailable.
|
|
729888
|
+
`
|
|
729889
|
+
);
|
|
729890
|
+
return false;
|
|
729891
|
+
}
|
|
729892
|
+
try {
|
|
729893
|
+
process.stdout.write(
|
|
729894
|
+
` ${c3.cyan("●")} Requesting the system Ollama broker to start...
|
|
729895
|
+
`
|
|
729896
|
+
);
|
|
729897
|
+
await runElevatedCommand(
|
|
729898
|
+
"systemctl start ollama.service ollama-unify-negotiator.service",
|
|
729899
|
+
{ timeoutMs: 6e4 }
|
|
729900
|
+
);
|
|
729901
|
+
return true;
|
|
729902
|
+
} catch (error) {
|
|
729903
|
+
const detail = error instanceof Error ? error.message : String(error);
|
|
729904
|
+
process.stdout.write(
|
|
729905
|
+
` ${c3.red("✖")} Could not start the system Ollama broker: ${detail}
|
|
729906
|
+
`
|
|
729907
|
+
);
|
|
729908
|
+
return false;
|
|
729909
|
+
}
|
|
729910
|
+
}
|
|
729796
729911
|
const admission = await resolveApprovedOllamaGpu();
|
|
729797
729912
|
if (!admission.ok) {
|
|
729798
729913
|
process.stdout.write(
|
|
@@ -729844,7 +729959,7 @@ async function ensureOllamaRunning(backendUrl2, rl) {
|
|
|
729844
729959
|
}
|
|
729845
729960
|
process.stdout.write(` ${c3.cyan("●")} Starting ollama serve...
|
|
729846
729961
|
`);
|
|
729847
|
-
if (!await startApprovedOllamaServe()) {
|
|
729962
|
+
if (!await startApprovedOllamaServe(backendUrl2)) {
|
|
729848
729963
|
process.stdout.write("\n");
|
|
729849
729964
|
return false;
|
|
729850
729965
|
}
|
|
@@ -730507,7 +730622,7 @@ ${c3.cyan(OMNIUS_FIRST_RUN_BANNER)}
|
|
|
730507
730622
|
process.stdout.write(`
|
|
730508
730623
|
${c3.cyan("●")} Ollama is installed but not running. Starting automatically...
|
|
730509
730624
|
`);
|
|
730510
|
-
if (await startApprovedOllamaServe()) {
|
|
730625
|
+
if (await startApprovedOllamaServe(config.backendUrl)) {
|
|
730511
730626
|
await new Promise((resolve91) => setTimeout(resolve91, 3e3));
|
|
730512
730627
|
try {
|
|
730513
730628
|
models = await fetchOllamaModels(config.backendUrl);
|
|
@@ -730533,7 +730648,7 @@ ${c3.cyan(OMNIUS_FIRST_RUN_BANNER)}
|
|
|
730533
730648
|
process.stdout.write(`
|
|
730534
730649
|
${c3.cyan("●")} Starting ollama serve...
|
|
730535
730650
|
`);
|
|
730536
|
-
if (await startApprovedOllamaServe()) {
|
|
730651
|
+
if (await startApprovedOllamaServe(config.backendUrl)) {
|
|
730537
730652
|
await new Promise((resolve91) => setTimeout(resolve91, 3e3));
|
|
730538
730653
|
try {
|
|
730539
730654
|
models = await fetchOllamaModels(config.backendUrl);
|
|
@@ -730726,14 +730841,23 @@ ${c3.cyan(OMNIUS_FIRST_RUN_BANNER)}
|
|
|
730726
730841
|
await runOptionalDepsSetup(rl);
|
|
730727
730842
|
return selectedVariant.tag;
|
|
730728
730843
|
}
|
|
730729
|
-
async function
|
|
730844
|
+
async function checkModelAvailability(config) {
|
|
730730
730845
|
try {
|
|
730731
|
-
const models = await
|
|
730732
|
-
|
|
730733
|
-
|
|
730734
|
-
|
|
730846
|
+
const models = config.backendType === "ollama" ? (await fetchOllamaModelNames(config.backendUrl)).map((name10) => ({
|
|
730847
|
+
name: name10
|
|
730848
|
+
})) : await fetchModels(config.backendUrl, config.apiKey);
|
|
730849
|
+
const match = findExactModel(models, config.model);
|
|
730850
|
+
return match ? { status: "available", model: match.name } : { status: "unavailable" };
|
|
730851
|
+
} catch (error) {
|
|
730852
|
+
return {
|
|
730853
|
+
status: "unknown",
|
|
730854
|
+
error: error instanceof Error ? error.message : String(error)
|
|
730855
|
+
};
|
|
730735
730856
|
}
|
|
730736
730857
|
}
|
|
730858
|
+
async function isModelAvailable(config) {
|
|
730859
|
+
return (await checkModelAvailability(config)).status === "available";
|
|
730860
|
+
}
|
|
730737
730861
|
function isFirstRun() {
|
|
730738
730862
|
try {
|
|
730739
730863
|
return !existsSync148(join158(homedir53(), ".omnius", "config.json"));
|
|
@@ -731850,6 +731974,7 @@ var init_setup = __esm({
|
|
|
731850
731974
|
init_render();
|
|
731851
731975
|
init_config();
|
|
731852
731976
|
init_dist6();
|
|
731977
|
+
init_dist8();
|
|
731853
731978
|
init_tui_select();
|
|
731854
731979
|
init_ollama_gpu_policy();
|
|
731855
731980
|
execAsync2 = promisify8(exec5);
|
|
@@ -759799,6 +759924,18 @@ async function handleBroker(arg, _ctx) {
|
|
|
759799
759924
|
async function handleParallel(arg, ctx3) {
|
|
759800
759925
|
const baseUrl3 = ctx3.config.backendUrl || "http://localhost:11434";
|
|
759801
759926
|
const isRemote = ctx3.config.backendType === "nexus";
|
|
759927
|
+
const brokerManaged = isOllamaUnifyManagedEndpoint(baseUrl3);
|
|
759928
|
+
let brokerPublicUrl = "http://127.0.0.1:11434";
|
|
759929
|
+
if (brokerManaged) {
|
|
759930
|
+
try {
|
|
759931
|
+
const discoveryPath = process.env.OMNIUS_OLLAMA_UNIFY_DISCOVERY_PATH?.trim() || "/usr/local/share/ollama-unify/gpu-negotiator.json";
|
|
759932
|
+
const discovery = JSON.parse(readFileSync135(discoveryPath, "utf8"));
|
|
759933
|
+
if (discovery.protocol === "ollama-unify-gpu-lease/v1" && typeof discovery.public_ollama_api === "string") {
|
|
759934
|
+
brokerPublicUrl = discovery.public_ollama_api.replace(/\/+$/, "");
|
|
759935
|
+
}
|
|
759936
|
+
} catch {
|
|
759937
|
+
}
|
|
759938
|
+
}
|
|
759802
759939
|
if (isRemote) {
|
|
759803
759940
|
renderInfo(
|
|
759804
759941
|
"Parallel slots are configured on the remote provider's Ollama, not locally."
|
|
@@ -759809,6 +759946,28 @@ async function handleParallel(arg, ctx3) {
|
|
|
759809
759946
|
return;
|
|
759810
759947
|
}
|
|
759811
759948
|
if (!arg) {
|
|
759949
|
+
if (brokerManaged) {
|
|
759950
|
+
try {
|
|
759951
|
+
const response = await fetch(
|
|
759952
|
+
`${brokerPublicUrl}/.well-known/ollama-unify-gpu-negotiator`,
|
|
759953
|
+
{ signal: AbortSignal.timeout(5e3) }
|
|
759954
|
+
);
|
|
759955
|
+
if (!response.ok) {
|
|
759956
|
+
throw new Error(`broker returned HTTP ${response.status}`);
|
|
759957
|
+
}
|
|
759958
|
+
const discovery = await response.json();
|
|
759959
|
+
const pool3 = discovery.parallel_pool;
|
|
759960
|
+
const ready = pool3?.lanes?.filter((lane) => lane.kind === "managed") ?? [];
|
|
759961
|
+
renderInfo(
|
|
759962
|
+
`Ollama parallelism is broker-managed: ${ready.length} managed lane(s) ready, ${pool3?.queue?.depth ?? 0} queued, maximum ${pool3?.max_managed_servers ?? "unknown"} lane(s) × ${pool3?.instance_parallel ?? 1} request(s).`
|
|
759963
|
+
);
|
|
759964
|
+
} catch (error) {
|
|
759965
|
+
renderWarning(
|
|
759966
|
+
`The Ollama broker owns parallelism but its status is unavailable: ${error instanceof Error ? error.message : String(error)}`
|
|
759967
|
+
);
|
|
759968
|
+
}
|
|
759969
|
+
return;
|
|
759970
|
+
}
|
|
759812
759971
|
const envVal = process.env.OLLAMA_NUM_PARALLEL;
|
|
759813
759972
|
let runningInfo = "";
|
|
759814
759973
|
try {
|
|
@@ -759862,6 +760021,31 @@ async function handleParallel(arg, ctx3) {
|
|
|
759862
760021
|
);
|
|
759863
760022
|
return;
|
|
759864
760023
|
}
|
|
760024
|
+
if (brokerManaged) {
|
|
760025
|
+
try {
|
|
760026
|
+
const response = await fetch(
|
|
760027
|
+
`${brokerPublicUrl}/.well-known/ollama-unify-gpu-negotiator/capacity`,
|
|
760028
|
+
{
|
|
760029
|
+
method: "POST",
|
|
760030
|
+
headers: { "Content-Type": "application/json" },
|
|
760031
|
+
body: JSON.stringify({ model: ctx3.config.model, parallel: n2 }),
|
|
760032
|
+
signal: AbortSignal.timeout(3e5)
|
|
760033
|
+
}
|
|
760034
|
+
);
|
|
760035
|
+
const result = await response.json();
|
|
760036
|
+
if (!response.ok) {
|
|
760037
|
+
throw new Error(result.error || `broker returned HTTP ${response.status}`);
|
|
760038
|
+
}
|
|
760039
|
+
renderInfo(
|
|
760040
|
+
`The Ollama broker admitted ${result.admitted_parallel ?? n2} parallel request(s) for ${ctx3.config.model}.`
|
|
760041
|
+
);
|
|
760042
|
+
} catch (error) {
|
|
760043
|
+
renderError(
|
|
760044
|
+
`The Ollama broker could not admit parallel=${n2}: ${error instanceof Error ? error.message : String(error)}`
|
|
760045
|
+
);
|
|
760046
|
+
}
|
|
760047
|
+
return;
|
|
760048
|
+
}
|
|
759865
760049
|
const gpuAdmission = await resolveApprovedOllamaGpu();
|
|
759866
760050
|
if (!gpuAdmission.ok) {
|
|
759867
760051
|
renderError(`Ollama restart blocked by GPU safety policy: ${gpuAdmission.reason}`);
|
|
@@ -778305,7 +778489,10 @@ function telegramRouterDiagnosticIsDualEmptyVisible(diag) {
|
|
|
778305
778489
|
}
|
|
778306
778490
|
function telegramThinkSuppressedRequest(request) {
|
|
778307
778491
|
const messages2 = Array.isArray(request.messages) ? request.messages.map(
|
|
778308
|
-
(message2) => message2 && typeof message2.content === "string" ? {
|
|
778492
|
+
(message2) => message2 && typeof message2.content === "string" ? {
|
|
778493
|
+
...message2,
|
|
778494
|
+
content: stripNoThinkPromptDirectives(message2.content)
|
|
778495
|
+
} : message2
|
|
778309
778496
|
) : [];
|
|
778310
778497
|
return { ...request, messages: messages2, think: false };
|
|
778311
778498
|
}
|
|
@@ -779143,7 +779330,8 @@ function renderTelegramLiveProgressHTML(progressLines, accumulated) {
|
|
|
779143
779330
|
function telegramAdminLivePanelPageLabel(page2) {
|
|
779144
779331
|
if (page2 === "response") return "Reply";
|
|
779145
779332
|
if (page2 === "tools") return "Tools";
|
|
779146
|
-
if (page2 === "logs") return "
|
|
779333
|
+
if (page2 === "logs") return "Activity";
|
|
779334
|
+
if (page2 === "evidence") return "Evidence";
|
|
779147
779335
|
return "Context";
|
|
779148
779336
|
}
|
|
779149
779337
|
function trimTelegramAdminPanelLines(lines, max = 80) {
|
|
@@ -779200,11 +779388,18 @@ function createTelegramAdminLivePanelState(args) {
|
|
|
779200
779388
|
expiresAt: now2 + 60 * 6e4,
|
|
779201
779389
|
chatId: args.chatId,
|
|
779202
779390
|
activePage: "response",
|
|
779203
|
-
dirtyPages: {
|
|
779391
|
+
dirtyPages: {
|
|
779392
|
+
response: false,
|
|
779393
|
+
tools: false,
|
|
779394
|
+
logs: false,
|
|
779395
|
+
evidence: false,
|
|
779396
|
+
context: false
|
|
779397
|
+
},
|
|
779204
779398
|
status: "running",
|
|
779205
779399
|
requestPreview,
|
|
779206
779400
|
intakeText: telegramAdminLivePanelIntakeText(requestPreview),
|
|
779207
779401
|
responseText: "",
|
|
779402
|
+
evidenceText: "",
|
|
779208
779403
|
toolLines: [],
|
|
779209
779404
|
mutationLines: [],
|
|
779210
779405
|
logLines: [],
|
|
@@ -779282,7 +779477,7 @@ function renderTelegramAdminLivePanelPayload(state5) {
|
|
|
779282
779477
|
if (state5.activePage === "response") {
|
|
779283
779478
|
const response = state5.responseText.trim();
|
|
779284
779479
|
const clipped = response.length > 2600 ? `${response.slice(0, 2597).trimEnd()}...` : response;
|
|
779285
|
-
body = clipped ? convertMarkdownToTelegramHTML(clipped) : "";
|
|
779480
|
+
body = clipped ? convertMarkdownToTelegramHTML(clipped) : "<i>Working…</i>";
|
|
779286
779481
|
} else if (state5.activePage === "tools") {
|
|
779287
779482
|
const lines = state5.toolLines.slice(-12);
|
|
779288
779483
|
body = lines.length > 0 ? `<blockquote>${escapeTelegramHTML(lines.join("\n"))}</blockquote>` : "<i>No tool calls yet.</i>";
|
|
@@ -779292,6 +779487,8 @@ function renderTelegramAdminLivePanelPayload(state5) {
|
|
|
779292
779487
|
...state5.logLines.slice(-10)
|
|
779293
779488
|
];
|
|
779294
779489
|
body = lines.length > 0 ? `<blockquote expandable>${escapeTelegramHTML(lines.join("\n"))}</blockquote>` : "<i>No mutations or logs yet.</i>";
|
|
779490
|
+
} else if (state5.activePage === "evidence") {
|
|
779491
|
+
body = state5.evidenceText.trim() ? `<blockquote expandable>${escapeTelegramHTML(state5.evidenceText.trim())}</blockquote>` : "<i>No completion evidence yet.</i>";
|
|
779295
779492
|
} else {
|
|
779296
779493
|
const pageCount = state5.contextPages.length;
|
|
779297
779494
|
const pageIndex = Math.min(
|
|
@@ -779315,22 +779512,25 @@ function renderTelegramAdminLivePanelPayload(state5) {
|
|
|
779315
779512
|
body = "<i>Full context has not been captured yet.</i>";
|
|
779316
779513
|
}
|
|
779317
779514
|
}
|
|
779515
|
+
const panelText = state5.activePage === "response" ? body : [
|
|
779516
|
+
header,
|
|
779517
|
+
"",
|
|
779518
|
+
body,
|
|
779519
|
+
"",
|
|
779520
|
+
`<i>Page ${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.indexOf(state5.activePage) + 1}/${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.length}: ${telegramAdminLivePanelPageLabel(state5.activePage)}</i>`
|
|
779521
|
+
].join("\n");
|
|
779318
779522
|
const text3 = truncateTelegramUrlSafe(
|
|
779319
|
-
|
|
779320
|
-
header,
|
|
779321
|
-
"",
|
|
779322
|
-
body,
|
|
779323
|
-
"",
|
|
779324
|
-
`<i>Page ${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.indexOf(state5.activePage) + 1}/${TELEGRAM_ADMIN_LIVE_PANEL_PAGES.length}: ${telegramAdminLivePanelPageLabel(state5.activePage)}</i>`
|
|
779325
|
-
].join("\n"),
|
|
779523
|
+
panelText,
|
|
779326
779524
|
3900,
|
|
779327
779525
|
"\n\n<i>... (panel clipped)</i>"
|
|
779328
779526
|
);
|
|
779527
|
+
const pageButtons = TELEGRAM_ADMIN_LIVE_PANEL_PAGES.map((page2) => ({
|
|
779528
|
+
text: `${page2 === state5.activePage ? "●" : "○"} ${telegramAdminLivePanelPageLabel(page2)}${state5.dirtyPages[page2] ? " *" : ""}`,
|
|
779529
|
+
callback_data: `omni:v1:tgadmin:${state5.nonce}:page:${page2}`
|
|
779530
|
+
}));
|
|
779329
779531
|
const keyboard = [
|
|
779330
|
-
|
|
779331
|
-
|
|
779332
|
-
callback_data: `omni:v1:tgadmin:${state5.nonce}:page:${page2}`
|
|
779333
|
-
}))
|
|
779532
|
+
pageButtons.slice(0, 3),
|
|
779533
|
+
pageButtons.slice(3)
|
|
779334
779534
|
];
|
|
779335
779535
|
if (state5.activePage === "context" && state5.contextPages.length > 1) {
|
|
779336
779536
|
const lastPage = Math.max(0, state5.contextPages.length - 1);
|
|
@@ -780231,7 +780431,7 @@ function renderTelegramSubAgentError(username, error) {
|
|
|
780231
780431
|
`${c3.red("✘")} ${c3.bold(`@${username}`)}: ${c3.dim(linkifyTerminalReferences(preview))}`
|
|
780232
780432
|
);
|
|
780233
780433
|
}
|
|
780234
|
-
var TELEGRAM_TOOL_ACTION_GROUPS, TELEGRAM_TOOL_ACTION_GROUP, TELEGRAM_TOOL_MUTATING_GROUPS, DEFAULT_TELEGRAM_TOOL_GROUP_POLICY, TELEGRAM_TOOL_BUTTON_LABELS, TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, TELEGRAM_PUBLIC_SOUL_PROFILE, TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT, TELEGRAM_PUBLIC_MEMORY_SCOPE_CONTRACT, TELEGRAM_PUBLIC_VISION_STACK_CONTRACT, TELEGRAM_EVIDENCE_SUFFICIENCY_CONTRACT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_EXTERNAL_ACQUISITION_CONTRACT, TELEGRAM_LINK_INTEGRITY_CONTRACT, TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT, TELEGRAM_INTERACTION_DECISION_MINIMAL_SCHEMA, TELEGRAM_INTERACTION_DECISION_REPAIR_SCHEMA, TELEGRAM_CHAT_REPLY_RESPONSE_FORMAT, TelegramEmptyInferenceStreamError, TELEGRAM_SPACED_URL_RE, TELEGRAM_HTTP_URL_RE, TELEGRAM_STUCK_SELF_TALK_PREFIXES, TELEGRAM_CHAT_HISTORY_LIMIT, TELEGRAM_CONTEXT_RECENT_DEFAULT, TELEGRAM_CONTEXT_LINE_LIMIT, TELEGRAM_CONTEXT_SAMPLE_LIMIT, TELEGRAM_MEMORY_CARD_LIMIT, TELEGRAM_MEMORY_NOTE_LIMIT, TELEGRAM_ASSOCIATIVE_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_USER_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_ACTION_LIMIT, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT, TELEGRAM_MEMORY_STOPWORDS, TELEGRAM_MEMORY_GENERIC_QUERY_TOKENS, TELEGRAM_SUB_AGENT_BOUNDED_OPTIONS, TELEGRAM_PUBLIC_FAST_OPTIONS, TELEGRAM_ADMIN_EVIDENCE_OPTIONS, TELEGRAM_SUB_AGENT_DEFAULT_LIMIT, TELEGRAM_SUB_AGENT_MAX_LIMIT, TELEGRAM_SUB_AGENT_BURST_CONTEXT_LIMIT, TELEGRAM_ADMIN_LIVE_PANEL_PAGES, TELEGRAM_ADMIN_LIVE_MUTATION_TOOLS, TELEGRAM_PUBLIC_HELP_COMMANDS2, TELEGRAM_REMINDER_SLASH_COMMANDS, TELEGRAM_REFLECTION_SLASH_COMMANDS, TELEGRAM_PUBLIC_BOT_COMMAND_NAMES, TELEGRAM_IMAGE_EXTENSIONS, MEDIA_CACHE_TTL_MS, TELEGRAM_CHANNEL_DMN_SWEEP_MS, TELEGRAM_CHANNEL_DMN_IDLE_AFTER_MS, TELEGRAM_CHANNEL_DMN_MIN_INTERVAL_MS, TELEGRAM_CHANNEL_DMN_MIN_MESSAGES, TELEGRAM_ALLOWED_UPDATES, TELEGRAM_DEFAULT_LONG_POLL_TIMEOUT_SECONDS, TELEGRAM_PUBLIC_TOOL_QUOTAS, TelegramBridge;
|
|
780434
|
+
var TELEGRAM_TOOL_ACTION_GROUPS, TELEGRAM_TOOL_ACTION_GROUP, TELEGRAM_TOOL_MUTATING_GROUPS, DEFAULT_TELEGRAM_TOOL_GROUP_POLICY, TELEGRAM_TOOL_BUTTON_LABELS, TELEGRAM_SAFETY_PROMPT, ADMIN_DM_PROMPT, ADMIN_GROUP_PROMPT, TELEGRAM_PUBLIC_SOUL_PROFILE, TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT, TELEGRAM_PUBLIC_MEMORY_SCOPE_CONTRACT, TELEGRAM_PUBLIC_VISION_STACK_CONTRACT, TELEGRAM_EVIDENCE_SUFFICIENCY_CONTRACT, GROUP_REPLY_DISCRETION_PROMPT, TELEGRAM_CHAT_MODE_PROMPT, ADMIN_CHAT_PROFILE_PROMPT, TELEGRAM_ACTION_RESPONSE_CONTRACT, TELEGRAM_EXTERNAL_ACQUISITION_CONTRACT, TELEGRAM_LINK_INTEGRITY_CONTRACT, TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT, TELEGRAM_INTERACTION_DECISION_MINIMAL_SCHEMA, TELEGRAM_INTERACTION_DECISION_REPAIR_SCHEMA, TELEGRAM_CHAT_REPLY_RESPONSE_FORMAT, TelegramEmptyInferenceStreamError, TELEGRAM_SPACED_URL_RE, TELEGRAM_HTTP_URL_RE, TELEGRAM_STUCK_SELF_TALK_PREFIXES, TELEGRAM_CHAT_HISTORY_LIMIT, TELEGRAM_CONTEXT_RECENT_DEFAULT, TELEGRAM_CONTEXT_LINE_LIMIT, TELEGRAM_CONTEXT_SAMPLE_LIMIT, TELEGRAM_MEMORY_CARD_LIMIT, TELEGRAM_MEMORY_NOTE_LIMIT, TELEGRAM_ASSOCIATIVE_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_USER_FACT_LIMIT, TELEGRAM_ASSOCIATIVE_ACTION_LIMIT, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT, TELEGRAM_MEMORY_STOPWORDS, TELEGRAM_MEMORY_GENERIC_QUERY_TOKENS, TELEGRAM_SUB_AGENT_BOUNDED_OPTIONS, TELEGRAM_PUBLIC_FAST_OPTIONS, TELEGRAM_ADMIN_EVIDENCE_OPTIONS, TELEGRAM_SUB_AGENT_DEFAULT_LIMIT, TELEGRAM_SUB_AGENT_MAX_LIMIT, TELEGRAM_SUB_AGENT_BURST_CONTEXT_LIMIT, TELEGRAM_ADMIN_LIVE_PANEL_PAGES, TELEGRAM_ADMIN_LIVE_MUTATION_TOOLS, TELEGRAM_PUBLIC_HELP_COMMANDS2, TELEGRAM_REMINDER_SLASH_COMMANDS, TELEGRAM_REFLECTION_SLASH_COMMANDS, TELEGRAM_PUBLIC_BOT_COMMAND_NAMES, TELEGRAM_IMAGE_EXTENSIONS, MEDIA_CACHE_TTL_MS, TELEGRAM_CHANNEL_DMN_SWEEP_MS, TELEGRAM_CHANNEL_DMN_IDLE_AFTER_MS, TELEGRAM_CHANNEL_DMN_MIN_INTERVAL_MS, TELEGRAM_CHANNEL_DMN_MIN_MESSAGES, TELEGRAM_ALLOWED_UPDATES, TELEGRAM_DEFAULT_LONG_POLL_TIMEOUT_SECONDS, TelegramStartupError, TELEGRAM_PUBLIC_TOOL_QUOTAS, TelegramBridge;
|
|
780235
780435
|
var init_telegram_bridge = __esm({
|
|
780236
780436
|
"packages/cli/src/tui/telegram-bridge.ts"() {
|
|
780237
780437
|
init_conversation_context();
|
|
@@ -780712,6 +780912,7 @@ Telegram link integrity contract:
|
|
|
780712
780912
|
"response",
|
|
780713
780913
|
"tools",
|
|
780714
780914
|
"logs",
|
|
780915
|
+
"evidence",
|
|
780715
780916
|
"context"
|
|
780716
780917
|
];
|
|
780717
780918
|
TELEGRAM_ADMIN_LIVE_MUTATION_TOOLS = /* @__PURE__ */ new Set([
|
|
@@ -780768,6 +780969,18 @@ Telegram link integrity contract:
|
|
|
780768
780969
|
"message_reaction_count"
|
|
780769
780970
|
];
|
|
780770
780971
|
TELEGRAM_DEFAULT_LONG_POLL_TIMEOUT_SECONDS = 50;
|
|
780972
|
+
TelegramStartupError = class extends Error {
|
|
780973
|
+
constructor(message2, retryable, method, errorCode) {
|
|
780974
|
+
super(message2);
|
|
780975
|
+
this.retryable = retryable;
|
|
780976
|
+
this.method = method;
|
|
780977
|
+
this.errorCode = errorCode;
|
|
780978
|
+
this.name = "TelegramStartupError";
|
|
780979
|
+
}
|
|
780980
|
+
retryable;
|
|
780981
|
+
method;
|
|
780982
|
+
errorCode;
|
|
780983
|
+
};
|
|
780771
780984
|
TELEGRAM_PUBLIC_TOOL_QUOTAS = {
|
|
780772
780985
|
web: { limit: 20, windowMs: 60 * 6e4 },
|
|
780773
780986
|
media: { limit: 30, windowMs: 60 * 6e4 },
|
|
@@ -782095,11 +782308,7 @@ ${message2}`)
|
|
|
782095
782308
|
} else {
|
|
782096
782309
|
this.recordTelegramUserMessage(msg, "steering");
|
|
782097
782310
|
}
|
|
782098
|
-
this.injectTelegramSteeringInput(
|
|
782099
|
-
subAgent,
|
|
782100
|
-
intakeRecord,
|
|
782101
|
-
context2
|
|
782102
|
-
);
|
|
782311
|
+
this.injectTelegramSteeringInput(subAgent, intakeRecord, context2);
|
|
782103
782312
|
void this.transitionTelegramIntake(
|
|
782104
782313
|
intakeRecord,
|
|
782105
782314
|
"accepted",
|
|
@@ -782163,13 +782372,19 @@ ${message2}`)
|
|
|
782163
782372
|
if (/^\/(?:replace|new[_-]?task)\b/.test(lower) || /^(?:new task|replace (?:the )?(?:current )?task|forget (?:that|the current task)|instead[,!:]?)/.test(
|
|
782164
782373
|
lower
|
|
782165
782374
|
)) {
|
|
782166
|
-
return {
|
|
782375
|
+
return {
|
|
782376
|
+
intent: "replace",
|
|
782377
|
+
reason: "explicit replacement/new-task request"
|
|
782378
|
+
};
|
|
782167
782379
|
}
|
|
782168
782380
|
if (/^\/(?:append|add|also)\b/.test(lower) || /^(?:also|add|include|one more thing)\b/.test(lower)) {
|
|
782169
782381
|
return { intent: "append", reason: "explicit additive instruction" };
|
|
782170
782382
|
}
|
|
782171
782383
|
if (/\?$/.test(text3) || /^(?:clarify|correction|to be clear)\b/.test(lower)) {
|
|
782172
|
-
return {
|
|
782384
|
+
return {
|
|
782385
|
+
intent: "clarify",
|
|
782386
|
+
reason: "plain-text clarification; scope preserved"
|
|
782387
|
+
};
|
|
782173
782388
|
}
|
|
782174
782389
|
const classified = classifySteeringIntent(text3, "append");
|
|
782175
782390
|
return {
|
|
@@ -782274,7 +782489,9 @@ ${message2}`)
|
|
|
782274
782489
|
});
|
|
782275
782490
|
return;
|
|
782276
782491
|
}
|
|
782277
|
-
runner.injectUserMessage(
|
|
782492
|
+
runner.injectUserMessage(
|
|
782493
|
+
this.formatTelegramSteeringCompatibilityMessage(pending2)
|
|
782494
|
+
);
|
|
782278
782495
|
}
|
|
782279
782496
|
async preemptTelegramSubAgentForIntake(msg, subAgent, intake) {
|
|
782280
782497
|
const sessionKey = intake.sessionKey;
|
|
@@ -783570,7 +783787,9 @@ ${mediaContext}` : ""
|
|
|
783570
783787
|
const structuredObjectLabels = [
|
|
783571
783788
|
objectLabels.label,
|
|
783572
783789
|
...objectLabels.aliases
|
|
783573
|
-
].filter(
|
|
783790
|
+
].filter(
|
|
783791
|
+
(label) => typeof label === "string" && label.trim().length > 0
|
|
783792
|
+
);
|
|
783574
783793
|
const payload = {
|
|
783575
783794
|
sourceSurface: "telegram",
|
|
783576
783795
|
sessionId: this.sessionKeyForMessage(msg),
|
|
@@ -788974,21 +789193,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
788974
789193
|
async start() {
|
|
788975
789194
|
if (this.polling) throw new Error("Telegram bridge already active.");
|
|
788976
789195
|
try {
|
|
788977
|
-
|
|
788978
|
-
for (let attempt = 0; attempt < 3; attempt++) {
|
|
788979
|
-
try {
|
|
788980
|
-
me = await this.apiCall("getMe");
|
|
788981
|
-
break;
|
|
788982
|
-
} catch (err) {
|
|
788983
|
-
if (attempt === 2) throw err;
|
|
788984
|
-
await new Promise((r2) => setTimeout(r2, 2e3 * (attempt + 1)));
|
|
788985
|
-
}
|
|
788986
|
-
}
|
|
788987
|
-
if (!me?.ok) {
|
|
788988
|
-
throw new Error(
|
|
788989
|
-
`Invalid Telegram bot token: ${me?.description || "unknown error"}`
|
|
788990
|
-
);
|
|
788991
|
-
}
|
|
789196
|
+
const me = await this.telegramStartupApiCall("getMe");
|
|
788992
789197
|
if (me.result?.id) {
|
|
788993
789198
|
const botUserId = Number(me.result.id);
|
|
788994
789199
|
const globalLockDir = process.env["OMNIUS_TELEGRAM_LOCK_DIR"] ? resolve82(process.env["OMNIUS_TELEGRAM_LOCK_DIR"]) : resolve82(homedir61(), ".omnius", "telegram-runner-state");
|
|
@@ -789068,25 +789273,72 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789068
789273
|
}
|
|
789069
789274
|
}
|
|
789070
789275
|
async prepareTelegramLongPolling() {
|
|
789071
|
-
|
|
789276
|
+
await this.telegramStartupApiCall("deleteWebhook", {
|
|
789072
789277
|
drop_pending_updates: false
|
|
789073
789278
|
});
|
|
789074
|
-
|
|
789075
|
-
throw new Error(
|
|
789076
|
-
`Telegram long-polling setup failed while clearing webhook: ${this.telegramApiErrorDescription(webhook)}`
|
|
789077
|
-
);
|
|
789078
|
-
}
|
|
789079
|
-
const probe = await this.apiCall("getUpdates", {
|
|
789279
|
+
await this.telegramStartupApiCall("getUpdates", {
|
|
789080
789280
|
offset: this.lastUpdateId + 1,
|
|
789081
789281
|
timeout: 0,
|
|
789082
789282
|
limit: 1,
|
|
789083
789283
|
allowed_updates: TELEGRAM_ALLOWED_UPDATES
|
|
789084
789284
|
});
|
|
789085
|
-
|
|
789086
|
-
|
|
789087
|
-
|
|
789285
|
+
}
|
|
789286
|
+
telegramStartupResultError(method, result) {
|
|
789287
|
+
const code8 = Number(result["error_code"]);
|
|
789288
|
+
const errorCode = Number.isFinite(code8) ? code8 : void 0;
|
|
789289
|
+
const description = String(
|
|
789290
|
+
result["description"] || result["error"] || "unknown Bot API error"
|
|
789291
|
+
);
|
|
789292
|
+
const webhookPropagationConflict = errorCode === 409 && method === "getUpdates" && description.toLowerCase().includes("webhook");
|
|
789293
|
+
const retryable = errorCode === 429 || errorCode !== void 0 && errorCode >= 500 && errorCode <= 599 || webhookPropagationConflict;
|
|
789294
|
+
return new TelegramStartupError(
|
|
789295
|
+
`Telegram ${method} startup failed: ${this.telegramApiErrorDescription(result)}`,
|
|
789296
|
+
retryable,
|
|
789297
|
+
method,
|
|
789298
|
+
errorCode
|
|
789299
|
+
);
|
|
789300
|
+
}
|
|
789301
|
+
telegramStartupRetryDelayMs(attempt, result) {
|
|
789302
|
+
const override = Number.parseInt(
|
|
789303
|
+
process.env["OMNIUS_TELEGRAM_STARTUP_RETRY_MS"] ?? "",
|
|
789304
|
+
10
|
|
789305
|
+
);
|
|
789306
|
+
if (Number.isFinite(override) && override >= 0 && override <= 3e4) {
|
|
789307
|
+
return override;
|
|
789308
|
+
}
|
|
789309
|
+
const retryAfter = Number(result?.["parameters"]?.["retry_after"]);
|
|
789310
|
+
if (Number.isFinite(retryAfter) && retryAfter > 0) {
|
|
789311
|
+
return Math.min(3e3, Math.floor(retryAfter * 1e3));
|
|
789312
|
+
}
|
|
789313
|
+
return [500, 1e3, 2e3][Math.min(attempt, 2)];
|
|
789314
|
+
}
|
|
789315
|
+
async telegramStartupApiCall(method, body, attempts = 3) {
|
|
789316
|
+
let lastError;
|
|
789317
|
+
for (let attempt = 0; attempt < Math.max(1, attempts); attempt++) {
|
|
789318
|
+
let result;
|
|
789319
|
+
try {
|
|
789320
|
+
result = await this.apiCall(method, body);
|
|
789321
|
+
if (result && result["ok"] !== false) return result;
|
|
789322
|
+
if (!result) throw new Error("empty Bot API response");
|
|
789323
|
+
lastError = this.telegramStartupResultError(method, result);
|
|
789324
|
+
} catch (error) {
|
|
789325
|
+
const stopped = this.abortController?.signal.aborted === true;
|
|
789326
|
+
lastError = error instanceof TelegramStartupError ? error : new TelegramStartupError(
|
|
789327
|
+
`Telegram ${method} startup request failed: ${error instanceof Error ? error.message : String(error)}`,
|
|
789328
|
+
!stopped,
|
|
789329
|
+
method
|
|
789330
|
+
);
|
|
789331
|
+
}
|
|
789332
|
+
if (!lastError.retryable || attempt + 1 >= attempts) throw lastError;
|
|
789333
|
+
await new Promise(
|
|
789334
|
+
(resolve91) => setTimeout(resolve91, this.telegramStartupRetryDelayMs(attempt, result))
|
|
789088
789335
|
);
|
|
789089
789336
|
}
|
|
789337
|
+
throw lastError ?? new TelegramStartupError(
|
|
789338
|
+
`Telegram ${method} startup failed`,
|
|
789339
|
+
true,
|
|
789340
|
+
method
|
|
789341
|
+
);
|
|
789090
789342
|
}
|
|
789091
789343
|
telegramApiErrorDescription(result) {
|
|
789092
789344
|
if (!result) return "unknown Bot API error";
|
|
@@ -789138,7 +789390,9 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789138
789390
|
}
|
|
789139
789391
|
this.telegramQueuedSessionWork.clear();
|
|
789140
789392
|
for (const completion of this.telegramQueuedSessionCompletions.values()) {
|
|
789141
|
-
completion.reject(
|
|
789393
|
+
completion.reject(
|
|
789394
|
+
new Error("Telegram bridge stopped before queued work completed")
|
|
789395
|
+
);
|
|
789142
789396
|
}
|
|
789143
789397
|
this.telegramQueuedSessionCompletions.clear();
|
|
789144
789398
|
this.telegramActiveWorkSessions.clear();
|
|
@@ -789256,7 +789510,8 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789256
789510
|
if (!existsSync176(lockFile)) return;
|
|
789257
789511
|
try {
|
|
789258
789512
|
const prior = JSON.parse(readFileSync148(lockFile, "utf8"));
|
|
789259
|
-
if (prior.pid !== process.pid || prior.ownerToken !== ownerToken)
|
|
789513
|
+
if (prior.pid !== process.pid || prior.ownerToken !== ownerToken)
|
|
789514
|
+
return;
|
|
789260
789515
|
} catch {
|
|
789261
789516
|
return;
|
|
789262
789517
|
}
|
|
@@ -789404,13 +789659,22 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789404
789659
|
if (replyParameters) body["reply_parameters"] = replyParameters;
|
|
789405
789660
|
if (replyMarkup) body["reply_markup"] = replyMarkup;
|
|
789406
789661
|
const result = await this.apiCall("sendMessage", body);
|
|
789662
|
+
if (result.ok === false) {
|
|
789663
|
+
throw new Error(
|
|
789664
|
+
String(result.description || "Telegram sendMessage failed")
|
|
789665
|
+
);
|
|
789666
|
+
}
|
|
789667
|
+
const messageId = result.result?.message_id;
|
|
789668
|
+
if (!Number.isInteger(messageId)) {
|
|
789669
|
+
throw new Error("Telegram sendMessage returned no valid message_id");
|
|
789670
|
+
}
|
|
789407
789671
|
this.state.messagesSent++;
|
|
789408
789672
|
this.updateTelegramTextDeliveryCapability(chatId, {
|
|
789409
789673
|
status: "allowed",
|
|
789410
789674
|
canSendText: true,
|
|
789411
789675
|
source: "sendLiveMessage"
|
|
789412
789676
|
});
|
|
789413
|
-
return
|
|
789677
|
+
return messageId;
|
|
789414
789678
|
} catch {
|
|
789415
789679
|
try {
|
|
789416
789680
|
const body = {
|
|
@@ -789421,13 +789685,22 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789421
789685
|
if (replyParameters) body["reply_parameters"] = replyParameters;
|
|
789422
789686
|
if (replyMarkup) body["reply_markup"] = replyMarkup;
|
|
789423
789687
|
const result = await this.apiCall("sendMessage", body);
|
|
789688
|
+
if (result.ok === false) {
|
|
789689
|
+
throw new Error(
|
|
789690
|
+
String(result.description || "Telegram sendMessage failed")
|
|
789691
|
+
);
|
|
789692
|
+
}
|
|
789693
|
+
const messageId = result.result?.message_id;
|
|
789694
|
+
if (!Number.isInteger(messageId)) {
|
|
789695
|
+
throw new Error("Telegram sendMessage returned no valid message_id");
|
|
789696
|
+
}
|
|
789424
789697
|
this.state.messagesSent++;
|
|
789425
789698
|
this.updateTelegramTextDeliveryCapability(chatId, {
|
|
789426
789699
|
status: "allowed",
|
|
789427
789700
|
canSendText: true,
|
|
789428
789701
|
source: "sendLiveMessage.plain_fallback"
|
|
789429
789702
|
});
|
|
789430
|
-
return
|
|
789703
|
+
return messageId;
|
|
789431
789704
|
} catch (err) {
|
|
789432
789705
|
const errStr = err instanceof Error ? err.message : String(err);
|
|
789433
789706
|
if (process.env["OMNIUS_TELEGRAM_DEBUG_SEND_FAILURES"] === "1" && this.shouldLogTelegramSendFailure(errStr)) {
|
|
@@ -789446,7 +789719,7 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789446
789719
|
reason: errStr,
|
|
789447
789720
|
ts: Date.now()
|
|
789448
789721
|
});
|
|
789449
|
-
|
|
789722
|
+
throw new Error(errStr);
|
|
789450
789723
|
}
|
|
789451
789724
|
}
|
|
789452
789725
|
}
|
|
@@ -789593,13 +789866,12 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789593
789866
|
async renderTelegramAdminLivePanel(state5, replyToMessageId) {
|
|
789594
789867
|
const payload = renderTelegramAdminLivePanelPayload(state5);
|
|
789595
789868
|
if (state5.messageId !== void 0) {
|
|
789596
|
-
|
|
789869
|
+
return this.editLiveMessage(
|
|
789597
789870
|
state5.chatId,
|
|
789598
789871
|
state5.messageId,
|
|
789599
789872
|
payload.text,
|
|
789600
789873
|
payload.reply_markup
|
|
789601
789874
|
);
|
|
789602
|
-
return;
|
|
789603
789875
|
}
|
|
789604
789876
|
const messageId = await this.sendLiveMessage(
|
|
789605
789877
|
state5.chatId,
|
|
@@ -789607,7 +789879,8 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789607
789879
|
replyToMessageId,
|
|
789608
789880
|
payload.reply_markup
|
|
789609
789881
|
);
|
|
789610
|
-
|
|
789882
|
+
state5.messageId = messageId;
|
|
789883
|
+
return true;
|
|
789611
789884
|
}
|
|
789612
789885
|
updateTelegramAdminLivePanelFromEvent(subAgent, msg, event) {
|
|
789613
789886
|
const state5 = this.ensureTelegramAdminLivePanel(subAgent, msg);
|
|
@@ -789631,19 +789904,29 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
789631
789904
|
});
|
|
789632
789905
|
}
|
|
789633
789906
|
}
|
|
789634
|
-
async finalizeTelegramAdminLivePanel(subAgent, msg,
|
|
789907
|
+
async finalizeTelegramAdminLivePanel(subAgent, msg, replyText, status = "completed", evidenceText = "") {
|
|
789635
789908
|
const state5 = this.ensureTelegramAdminLivePanel(subAgent, msg);
|
|
789636
789909
|
state5.status = status;
|
|
789637
|
-
state5.responseText =
|
|
789910
|
+
state5.responseText = replyText || (status === "failed" ? "I couldn't complete that request." : "Done.");
|
|
789911
|
+
if (evidenceText.trim()) {
|
|
789912
|
+
state5.evidenceText = evidenceText.trim();
|
|
789913
|
+
state5.dirtyPages.evidence = true;
|
|
789914
|
+
}
|
|
789915
|
+
state5.activePage = "response";
|
|
789916
|
+
state5.dirtyPages.response = false;
|
|
789638
789917
|
state5.updatedAt = Date.now();
|
|
789639
|
-
if (state5.activePage !== "response") state5.dirtyPages.response = true;
|
|
789640
789918
|
this.refreshTelegramAdminLivePanelContextPages(state5, subAgent, msg);
|
|
789641
789919
|
if (subAgent.liveMessagePromise)
|
|
789642
789920
|
await subAgent.liveMessagePromise.catch(() => {
|
|
789643
789921
|
});
|
|
789644
|
-
await this.renderTelegramAdminLivePanel(state5);
|
|
789922
|
+
const delivered = await this.renderTelegramAdminLivePanel(state5);
|
|
789923
|
+
if (!delivered || state5.messageId === void 0) {
|
|
789924
|
+
throw new Error(
|
|
789925
|
+
"Telegram admin panel finalization produced no delivery receipt"
|
|
789926
|
+
);
|
|
789927
|
+
}
|
|
789645
789928
|
subAgent.liveMessageId = state5.messageId ?? null;
|
|
789646
|
-
return state5.messageId
|
|
789929
|
+
return state5.messageId;
|
|
789647
789930
|
}
|
|
789648
789931
|
telegramAdminRunCompleted(subAgent) {
|
|
789649
789932
|
if (subAgent.runnerStatus === "incomplete_verification") return false;
|
|
@@ -790504,12 +790787,12 @@ Join: ${newUrl}`
|
|
|
790504
790787
|
}
|
|
790505
790788
|
const subAgentProfile = decision2.route === "chat" ? "chat" : "action";
|
|
790506
790789
|
if (decision2.route === "chat" && msg.chatType === "private") {
|
|
790507
|
-
const
|
|
790790
|
+
const visibleReplyDelivered = await this.handleTelegramChatCompletion(
|
|
790508
790791
|
msg,
|
|
790509
790792
|
toolContext,
|
|
790510
790793
|
[decisionContext, rapidContext].filter(Boolean).join("\n\n")
|
|
790511
790794
|
);
|
|
790512
|
-
if (shouldDeferNotes &&
|
|
790795
|
+
if (shouldDeferNotes && visibleReplyDelivered) {
|
|
790513
790796
|
this.deliverTelegramPostReplyNotes(
|
|
790514
790797
|
sessionKey,
|
|
790515
790798
|
msg,
|
|
@@ -790523,8 +790806,8 @@ Join: ${newUrl}`
|
|
|
790523
790806
|
work.intakeRecords.map(
|
|
790524
790807
|
(intake) => this.transitionTelegramIntake(
|
|
790525
790808
|
intake,
|
|
790526
|
-
"consumed",
|
|
790527
|
-
"Telegram quick-chat
|
|
790809
|
+
visibleReplyDelivered ? "consumed" : "failed",
|
|
790810
|
+
visibleReplyDelivered ? "Telegram quick-chat reply was delivered" : "Telegram quick-chat reply did not produce a delivery receipt"
|
|
790528
790811
|
)
|
|
790529
790812
|
)
|
|
790530
790813
|
);
|
|
@@ -790649,14 +790932,28 @@ Join: ${newUrl}`
|
|
|
790649
790932
|
subAgent,
|
|
790650
790933
|
finalText
|
|
790651
790934
|
);
|
|
790935
|
+
const deliveredFinalText2 = finalText || "I couldn't complete that request.";
|
|
790652
790936
|
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
790653
790937
|
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "failed");
|
|
790654
790938
|
if (!msg.guestQueryId) {
|
|
790655
|
-
await this.finalizeTelegramAdminLivePanel(
|
|
790939
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
790656
790940
|
subAgent,
|
|
790657
790941
|
msg,
|
|
790658
|
-
|
|
790659
|
-
"failed"
|
|
790942
|
+
deliveredFinalText2,
|
|
790943
|
+
"failed",
|
|
790944
|
+
incompleteText
|
|
790945
|
+
);
|
|
790946
|
+
this.recordTelegramAssistantMessage(
|
|
790947
|
+
msg,
|
|
790948
|
+
deliveredFinalText2,
|
|
790949
|
+
subAgentProfile,
|
|
790950
|
+
{ messageId }
|
|
790951
|
+
);
|
|
790952
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
790953
|
+
msg,
|
|
790954
|
+
subAgent,
|
|
790955
|
+
deliveredFinalText2,
|
|
790956
|
+
true
|
|
790660
790957
|
);
|
|
790661
790958
|
} else if (subAgent.liveMessageId) {
|
|
790662
790959
|
await this.deleteLiveMessage(
|
|
@@ -790669,21 +790966,35 @@ Join: ${newUrl}`
|
|
|
790669
790966
|
}
|
|
790670
790967
|
if (!finalText) {
|
|
790671
790968
|
if (isAdminDM && this.telegramAdminRunCompleted(subAgent)) {
|
|
790672
|
-
const
|
|
790969
|
+
const evidenceText = this.telegramAdminCompletionRunText(
|
|
790673
790970
|
subAgent,
|
|
790674
790971
|
""
|
|
790675
790972
|
);
|
|
790973
|
+
const deliveredFinalText2 = "Done.";
|
|
790676
790974
|
this.subAgentViewCallbacks?.onWrite(
|
|
790677
790975
|
subAgent.viewId,
|
|
790678
|
-
`completed: ${
|
|
790976
|
+
`completed: ${evidenceText}`
|
|
790679
790977
|
);
|
|
790680
790978
|
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "completed");
|
|
790681
790979
|
if (!msg.guestQueryId) {
|
|
790682
|
-
await this.finalizeTelegramAdminLivePanel(
|
|
790980
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
790683
790981
|
subAgent,
|
|
790684
790982
|
msg,
|
|
790685
790983
|
deliveredFinalText2,
|
|
790686
|
-
"completed"
|
|
790984
|
+
"completed",
|
|
790985
|
+
evidenceText
|
|
790986
|
+
);
|
|
790987
|
+
this.recordTelegramAssistantMessage(
|
|
790988
|
+
msg,
|
|
790989
|
+
deliveredFinalText2,
|
|
790990
|
+
subAgentProfile,
|
|
790991
|
+
{ messageId }
|
|
790992
|
+
);
|
|
790993
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
790994
|
+
msg,
|
|
790995
|
+
subAgent,
|
|
790996
|
+
deliveredFinalText2,
|
|
790997
|
+
true
|
|
790687
790998
|
);
|
|
790688
790999
|
} else if (subAgent.liveMessageId) {
|
|
790689
791000
|
await this.deleteLiveMessage(
|
|
@@ -790729,7 +791040,8 @@ Join: ${newUrl}`
|
|
|
790729
791040
|
await subAgent.liveMessagePromise.catch(() => {
|
|
790730
791041
|
});
|
|
790731
791042
|
}
|
|
790732
|
-
const deliveredFinalText =
|
|
791043
|
+
const deliveredFinalText = finalText;
|
|
791044
|
+
const adminEvidenceText = isAdminDM ? this.telegramAdminCompletionRunText(subAgent, finalText) : "";
|
|
790733
791045
|
const finalHtml = convertMarkdownToTelegramHTML(deliveredFinalText);
|
|
790734
791046
|
const contextExplorerState = !isAdminDM && msg.chatType !== "private" && !msg.guestQueryId ? this.buildTelegramContextExplorerState(
|
|
790735
791047
|
msg,
|
|
@@ -790742,7 +791054,8 @@ Join: ${newUrl}`
|
|
|
790742
791054
|
subAgent,
|
|
790743
791055
|
msg,
|
|
790744
791056
|
deliveredFinalText,
|
|
790745
|
-
"completed"
|
|
791057
|
+
"completed",
|
|
791058
|
+
adminEvidenceText
|
|
790746
791059
|
) : await this.sendOrEditFinalTelegramHTML(
|
|
790747
791060
|
msg,
|
|
790748
791061
|
finalHtml,
|
|
@@ -790813,13 +791126,32 @@ Join: ${newUrl}`
|
|
|
790813
791126
|
});
|
|
790814
791127
|
}
|
|
790815
791128
|
if (isAdminDM && !msg.guestQueryId) {
|
|
790816
|
-
|
|
791129
|
+
const partialReply = cleanTelegramVisibleReply(
|
|
791130
|
+
subAgent.visibleReplyText || subAgent.streamText || subAgent.assistantText || subAgent.accumulated || ""
|
|
791131
|
+
);
|
|
791132
|
+
const deliveredFinalText = partialReply || "I couldn't complete that request.";
|
|
791133
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
790817
791134
|
subAgent,
|
|
790818
791135
|
msg,
|
|
790819
|
-
|
|
790820
|
-
"failed"
|
|
790821
|
-
|
|
790822
|
-
|
|
791136
|
+
deliveredFinalText,
|
|
791137
|
+
"failed",
|
|
791138
|
+
`Error:
|
|
791139
|
+
${errMsg}`
|
|
791140
|
+
).catch(() => null);
|
|
791141
|
+
if (messageId !== null) {
|
|
791142
|
+
this.recordTelegramAssistantMessage(
|
|
791143
|
+
msg,
|
|
791144
|
+
deliveredFinalText,
|
|
791145
|
+
subAgentProfile,
|
|
791146
|
+
{ messageId }
|
|
791147
|
+
);
|
|
791148
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
791149
|
+
msg,
|
|
791150
|
+
subAgent,
|
|
791151
|
+
deliveredFinalText,
|
|
791152
|
+
true
|
|
791153
|
+
);
|
|
791154
|
+
}
|
|
790823
791155
|
} else if (subAgent.liveMessageId && !msg.guestQueryId) {
|
|
790824
791156
|
await this.deleteLiveMessage(msg.chatId, subAgent.liveMessageId).catch(
|
|
790825
791157
|
() => {
|
|
@@ -790930,7 +791262,7 @@ Join: ${newUrl}`
|
|
|
790930
791262
|
if (subAgent.preempted) return "";
|
|
790931
791263
|
throw err;
|
|
790932
791264
|
});
|
|
790933
|
-
if (subAgent.preempted) return;
|
|
791265
|
+
if (subAgent.preempted) return false;
|
|
790934
791266
|
if (subAgent.typingInterval) {
|
|
790935
791267
|
clearInterval(subAgent.typingInterval);
|
|
790936
791268
|
subAgent.typingInterval = null;
|
|
@@ -790945,15 +791277,27 @@ Join: ${newUrl}`
|
|
|
790945
791277
|
subAgent,
|
|
790946
791278
|
finalText
|
|
790947
791279
|
);
|
|
791280
|
+
const deliveredFinalText2 = finalText || "I couldn't complete that request.";
|
|
790948
791281
|
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, incompleteText);
|
|
790949
791282
|
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "failed");
|
|
790950
791283
|
if (!msg.guestQueryId) {
|
|
790951
|
-
await this.finalizeTelegramAdminLivePanel(
|
|
791284
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
790952
791285
|
subAgent,
|
|
790953
791286
|
msg,
|
|
790954
|
-
|
|
790955
|
-
"failed"
|
|
791287
|
+
deliveredFinalText2,
|
|
791288
|
+
"failed",
|
|
791289
|
+
incompleteText
|
|
790956
791290
|
);
|
|
791291
|
+
this.recordTelegramAssistantMessage(msg, deliveredFinalText2, "chat", {
|
|
791292
|
+
messageId
|
|
791293
|
+
});
|
|
791294
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
791295
|
+
msg,
|
|
791296
|
+
subAgent,
|
|
791297
|
+
deliveredFinalText2,
|
|
791298
|
+
true
|
|
791299
|
+
);
|
|
791300
|
+
return true;
|
|
790957
791301
|
} else if (subAgent.liveMessageId) {
|
|
790958
791302
|
await this.deleteLiveMessage(
|
|
790959
791303
|
msg.chatId,
|
|
@@ -790961,20 +791305,31 @@ Join: ${newUrl}`
|
|
|
790961
791305
|
).catch(() => {
|
|
790962
791306
|
});
|
|
790963
791307
|
}
|
|
790964
|
-
return;
|
|
791308
|
+
return false;
|
|
790965
791309
|
}
|
|
790966
791310
|
if (!finalText) {
|
|
790967
|
-
const deliveredFinalText2 =
|
|
790968
|
-
|
|
790969
|
-
|
|
790970
|
-
);
|
|
791311
|
+
const deliveredFinalText2 = "Done.";
|
|
791312
|
+
const evidenceText2 = this.telegramAdminCompletionRunText(subAgent, "");
|
|
791313
|
+
this.subAgentViewCallbacks?.onWrite(subAgent.viewId, evidenceText2);
|
|
791314
|
+
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "completed");
|
|
790971
791315
|
if (!msg.guestQueryId) {
|
|
790972
|
-
await this.finalizeTelegramAdminLivePanel(
|
|
791316
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
790973
791317
|
subAgent,
|
|
790974
791318
|
msg,
|
|
790975
791319
|
deliveredFinalText2,
|
|
790976
|
-
"completed"
|
|
791320
|
+
"completed",
|
|
791321
|
+
evidenceText2
|
|
791322
|
+
);
|
|
791323
|
+
this.recordTelegramAssistantMessage(msg, deliveredFinalText2, "chat", {
|
|
791324
|
+
messageId
|
|
791325
|
+
});
|
|
791326
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
791327
|
+
msg,
|
|
791328
|
+
subAgent,
|
|
791329
|
+
deliveredFinalText2,
|
|
791330
|
+
true
|
|
790977
791331
|
);
|
|
791332
|
+
return true;
|
|
790978
791333
|
} else if (subAgent.liveMessageId) {
|
|
790979
791334
|
await this.deleteLiveMessage(
|
|
790980
791335
|
msg.chatId,
|
|
@@ -790982,23 +791337,20 @@ Join: ${newUrl}`
|
|
|
790982
791337
|
).catch(() => {
|
|
790983
791338
|
});
|
|
790984
791339
|
}
|
|
790985
|
-
|
|
790986
|
-
subAgent.viewId,
|
|
790987
|
-
`completed: ${deliveredFinalText2}`
|
|
790988
|
-
);
|
|
790989
|
-
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "completed");
|
|
790990
|
-
return;
|
|
791340
|
+
return false;
|
|
790991
791341
|
}
|
|
790992
|
-
const deliveredFinalText =
|
|
791342
|
+
const deliveredFinalText = finalText;
|
|
791343
|
+
const evidenceText = this.telegramAdminCompletionRunText(
|
|
790993
791344
|
subAgent,
|
|
790994
|
-
|
|
791345
|
+
deliveredFinalText
|
|
790995
791346
|
);
|
|
790996
791347
|
const finalHtml = convertMarkdownToTelegramHTML(deliveredFinalText);
|
|
790997
791348
|
const sentMessageId = !msg.guestQueryId ? await this.finalizeTelegramAdminLivePanel(
|
|
790998
791349
|
subAgent,
|
|
790999
791350
|
msg,
|
|
791000
791351
|
deliveredFinalText,
|
|
791001
|
-
"completed"
|
|
791352
|
+
"completed",
|
|
791353
|
+
evidenceText
|
|
791002
791354
|
) : await this.sendOrEditFinalTelegramHTML(
|
|
791003
791355
|
msg,
|
|
791004
791356
|
finalHtml,
|
|
@@ -791026,6 +791378,7 @@ Join: ${newUrl}`
|
|
|
791026
791378
|
`completed: ${deliveredFinalText}`
|
|
791027
791379
|
);
|
|
791028
791380
|
this.subAgentViewCallbacks?.onStatus(subAgent.viewId, "completed");
|
|
791381
|
+
return true;
|
|
791029
791382
|
} catch (err) {
|
|
791030
791383
|
if (subAgent.typingInterval) {
|
|
791031
791384
|
clearInterval(subAgent.typingInterval);
|
|
@@ -791040,19 +791393,37 @@ Join: ${newUrl}`
|
|
|
791040
791393
|
});
|
|
791041
791394
|
}
|
|
791042
791395
|
if (!msg.guestQueryId) {
|
|
791043
|
-
|
|
791396
|
+
const partialReply = cleanTelegramVisibleReply(
|
|
791397
|
+
subAgent.visibleReplyText || subAgent.streamText || subAgent.assistantText || subAgent.accumulated || ""
|
|
791398
|
+
);
|
|
791399
|
+
const deliveredFinalText = partialReply || "I couldn't complete that request.";
|
|
791400
|
+
const messageId = await this.finalizeTelegramAdminLivePanel(
|
|
791044
791401
|
subAgent,
|
|
791045
791402
|
msg,
|
|
791046
|
-
|
|
791047
|
-
"failed"
|
|
791048
|
-
|
|
791049
|
-
|
|
791403
|
+
deliveredFinalText,
|
|
791404
|
+
"failed",
|
|
791405
|
+
`Error:
|
|
791406
|
+
${errMsg}`
|
|
791407
|
+
).catch(() => null);
|
|
791408
|
+
if (messageId !== null) {
|
|
791409
|
+
this.recordTelegramAssistantMessage(msg, deliveredFinalText, "chat", {
|
|
791410
|
+
messageId
|
|
791411
|
+
});
|
|
791412
|
+
await this.sendGeneratedArtifactsFromSubAgent(
|
|
791413
|
+
msg,
|
|
791414
|
+
subAgent,
|
|
791415
|
+
deliveredFinalText,
|
|
791416
|
+
true
|
|
791417
|
+
);
|
|
791418
|
+
return true;
|
|
791419
|
+
}
|
|
791050
791420
|
} else if (subAgent.liveMessageId) {
|
|
791051
791421
|
await this.deleteLiveMessage(msg.chatId, subAgent.liveMessageId).catch(
|
|
791052
791422
|
() => {
|
|
791053
791423
|
}
|
|
791054
791424
|
);
|
|
791055
791425
|
}
|
|
791426
|
+
return false;
|
|
791056
791427
|
} finally {
|
|
791057
791428
|
await this.requeuePendingTelegramIntakeOnFinalization(subAgent);
|
|
791058
791429
|
this.clearTelegramSubAgentContextBuffer(sessionKey);
|
|
@@ -791064,12 +791435,11 @@ Join: ${newUrl}`
|
|
|
791064
791435
|
/** Fast Telegram chat path: direct streamed completion, no tool loop. */
|
|
791065
791436
|
async handleTelegramChatCompletion(msg, toolContext, additionalContext = "") {
|
|
791066
791437
|
if (toolContext === "telegram-admin-dm") {
|
|
791067
|
-
|
|
791438
|
+
return this.handleTelegramAdminChatAgent(
|
|
791068
791439
|
msg,
|
|
791069
791440
|
toolContext,
|
|
791070
791441
|
additionalContext
|
|
791071
791442
|
);
|
|
791072
|
-
return true;
|
|
791073
791443
|
}
|
|
791074
791444
|
const viewId = `${this.viewIdForMessage(msg)}-chat`;
|
|
791075
791445
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
@@ -791207,6 +791577,9 @@ Join: ${newUrl}`
|
|
|
791207
791577
|
finalHtml,
|
|
791208
791578
|
liveMessageId
|
|
791209
791579
|
);
|
|
791580
|
+
if (sentMessageId === null && !msg.guestQueryId) {
|
|
791581
|
+
throw new Error("Telegram final reply produced no delivery receipt");
|
|
791582
|
+
}
|
|
791210
791583
|
if (sentMessageId !== null || msg.guestQueryId) {
|
|
791211
791584
|
this.recordTelegramAssistantMessage(msg, cleaned, "chat", {
|
|
791212
791585
|
messageId: sentMessageId,
|
|
@@ -791463,6 +791836,11 @@ ${conversationStream}`
|
|
|
791463
791836
|
modelTier: modelTier2,
|
|
791464
791837
|
disableTodoCompletionGuard: true,
|
|
791465
791838
|
disableTodoPlanningNudges: true,
|
|
791839
|
+
// The attention router already classified this private-admin turn as
|
|
791840
|
+
// chat. Accept its first visible assistant answer as the terminal result
|
|
791841
|
+
// instead of spending two more generations demanding task_complete.
|
|
791842
|
+
// Action routes keep the normal explicit completion/evidence boundary.
|
|
791843
|
+
acceptTextOnlyCompletion: isAdminDM && profile === "chat",
|
|
791466
791844
|
streamEnabled: true,
|
|
791467
791845
|
dynamicContext: sessionContext.context,
|
|
791468
791846
|
captureContextFrame: true,
|
|
@@ -791807,6 +792185,7 @@ ${creativeWorkspace}` : ""}`;
|
|
|
791807
792185
|
},
|
|
791808
792186
|
() => runner.run(userPrompt, systemCtx, msg.text)
|
|
791809
792187
|
);
|
|
792188
|
+
this.retainTelegramVisibleReplyFromCompletedStream(subAgent);
|
|
791810
792189
|
subAgent.runnerCompleted = result.completed;
|
|
791811
792190
|
subAgent.runnerStatus = result.status;
|
|
791812
792191
|
subAgent.runnerTurns = result.turns;
|
|
@@ -795145,16 +795524,20 @@ Advanced text extraction signal: chars=${advancedSignal.chars}, lines=${advanced
|
|
|
795145
795524
|
plan,
|
|
795146
795525
|
executor
|
|
795147
795526
|
);
|
|
795148
|
-
const matchingEntry = bridge.recentTelegramMediaEntries(chatId, 60).find(
|
|
795527
|
+
const matchingEntry = bridge.recentTelegramMediaEntries(chatId, 60).find(
|
|
795528
|
+
(entry) => resolve82(entry.localPath) === resolve82(resolution.path)
|
|
795529
|
+
);
|
|
795149
795530
|
try {
|
|
795150
795531
|
const { queryVisualFamiliarity: queryVisualFamiliarity2 } = await Promise.resolve().then(() => (init_vision_ingress(), vision_ingress_exports));
|
|
795151
795532
|
const familiarity = await queryVisualFamiliarity2(resolution.path, {
|
|
795152
795533
|
timeoutMs: 15e3
|
|
795153
795534
|
});
|
|
795154
795535
|
if (familiarity.contextBlock) {
|
|
795155
|
-
stageLines.push(
|
|
795536
|
+
stageLines.push(
|
|
795537
|
+
`
|
|
795156
795538
|
## visual_familiarity
|
|
795157
|
-
${familiarity.contextBlock}`
|
|
795539
|
+
${familiarity.contextBlock}`
|
|
795540
|
+
);
|
|
795158
795541
|
llmParts.push(`## visual_familiarity
|
|
795159
795542
|
${familiarity.contextBlock}`);
|
|
795160
795543
|
}
|
|
@@ -795191,11 +795574,15 @@ ${familiarity.contextBlock}`);
|
|
|
795191
795574
|
extractedContent: llmParts.join("\n\n")
|
|
795192
795575
|
});
|
|
795193
795576
|
if (association.contextBlock) {
|
|
795194
|
-
stageLines.push(
|
|
795577
|
+
stageLines.push(
|
|
795578
|
+
`
|
|
795195
795579
|
## visual_identity_memory
|
|
795196
|
-
${association.contextBlock}`
|
|
795197
|
-
|
|
795198
|
-
|
|
795580
|
+
${association.contextBlock}`
|
|
795581
|
+
);
|
|
795582
|
+
llmParts.push(
|
|
795583
|
+
`## visual_identity_memory
|
|
795584
|
+
${association.contextBlock}`
|
|
795585
|
+
);
|
|
795199
795586
|
}
|
|
795200
795587
|
} catch {
|
|
795201
795588
|
}
|
|
@@ -795217,11 +795604,15 @@ ${association.contextBlock}`);
|
|
|
795217
795604
|
}
|
|
795218
795605
|
});
|
|
795219
795606
|
if (objectMemory.contextBlock) {
|
|
795220
|
-
stageLines.push(
|
|
795607
|
+
stageLines.push(
|
|
795608
|
+
`
|
|
795221
795609
|
## visual_object_memory
|
|
795222
|
-
${objectMemory.contextBlock}`
|
|
795223
|
-
|
|
795224
|
-
|
|
795610
|
+
${objectMemory.contextBlock}`
|
|
795611
|
+
);
|
|
795612
|
+
llmParts.push(
|
|
795613
|
+
`## visual_object_memory
|
|
795614
|
+
${objectMemory.contextBlock}`
|
|
795615
|
+
);
|
|
795225
795616
|
}
|
|
795226
795617
|
} catch {
|
|
795227
795618
|
}
|
|
@@ -805502,6 +805893,7 @@ ${result.summary}`
|
|
|
805502
805893
|
};
|
|
805503
805894
|
}
|
|
805504
805895
|
let telegramBridge = null;
|
|
805896
|
+
let telegramAutoStartTimer = null;
|
|
805505
805897
|
let activeTelegramChatId = null;
|
|
805506
805898
|
let dmnRetriggerTimer = null;
|
|
805507
805899
|
let reminderDispatchTimer = null;
|
|
@@ -805915,8 +806307,11 @@ This is an independent background session started from /background.`
|
|
|
805915
806307
|
].sort();
|
|
805916
806308
|
let cachedModelNames = [];
|
|
805917
806309
|
function refreshModelCache() {
|
|
805918
|
-
fetchModels(currentConfig.backendUrl, currentConfig.apiKey).then(
|
|
805919
|
-
|
|
806310
|
+
const request = currentConfig.backendType === "ollama" ? fetchOllamaModelNames(currentConfig.backendUrl) : fetchModels(currentConfig.backendUrl, currentConfig.apiKey).then(
|
|
806311
|
+
(models) => models.map((model) => model.name)
|
|
806312
|
+
);
|
|
806313
|
+
request.then((names) => {
|
|
806314
|
+
cachedModelNames = names;
|
|
805920
806315
|
}).catch(() => {
|
|
805921
806316
|
});
|
|
805922
806317
|
}
|
|
@@ -806386,16 +806781,13 @@ This is an independent background session started from /background.`
|
|
|
806386
806781
|
}
|
|
806387
806782
|
const startupChecksPromise = (async () => {
|
|
806388
806783
|
if (!isResumed && !isFirstRun()) {
|
|
806389
|
-
|
|
806390
|
-
|
|
806391
|
-
|
|
806392
|
-
|
|
806393
|
-
|
|
806394
|
-
|
|
806395
|
-
|
|
806396
|
-
});
|
|
806397
|
-
}
|
|
806398
|
-
} catch {
|
|
806784
|
+
const availability = await checkModelAvailability(currentConfig);
|
|
806785
|
+
if (availability.status === "unavailable" && currentConfig.backendType === "ollama") {
|
|
806786
|
+
writeContent(() => {
|
|
806787
|
+
renderWarning(
|
|
806788
|
+
`Model "${currentConfig.model}" not available. Use /model to pick one.`
|
|
806789
|
+
);
|
|
806790
|
+
});
|
|
806399
806791
|
}
|
|
806400
806792
|
}
|
|
806401
806793
|
if (currentConfig.backendType === "ollama") {
|
|
@@ -807813,6 +808205,10 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
807813
808205
|
showPrompt();
|
|
807814
808206
|
},
|
|
807815
808207
|
telegramStop() {
|
|
808208
|
+
if (telegramAutoStartTimer) {
|
|
808209
|
+
clearTimeout(telegramAutoStartTimer);
|
|
808210
|
+
telegramAutoStartTimer = null;
|
|
808211
|
+
}
|
|
807816
808212
|
if (telegramBridge?.isActive) {
|
|
807817
808213
|
const stats = telegramBridge.stats;
|
|
807818
808214
|
telegramBridge.stop();
|
|
@@ -809526,23 +809922,38 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
809526
809922
|
}
|
|
809527
809923
|
}
|
|
809528
809924
|
const autoTelegramSettings = telegramSettingsForScope("project");
|
|
809529
|
-
|
|
809530
|
-
|
|
809925
|
+
const telegramAutoStartRetryDelaysMs = [2e3, 5e3, 15e3, 3e4];
|
|
809926
|
+
const scheduleTelegramAutoStart = (delayMs, retryIndex = 0) => {
|
|
809927
|
+
telegramAutoStartTimer = setTimeout(async () => {
|
|
809928
|
+
telegramAutoStartTimer = null;
|
|
809929
|
+
const settings = telegramSettingsForScope("project");
|
|
809930
|
+
if (interactiveExiting || isResumed || process.env["OMNIUS_TELEGRAM_DISABLED"] === "1" || settings.enabled === false || !settings.key || telegramBridge !== null) {
|
|
809931
|
+
return;
|
|
809932
|
+
}
|
|
809531
809933
|
try {
|
|
809532
809934
|
await commandCtx.telegramStart(
|
|
809533
|
-
|
|
809534
|
-
|
|
809935
|
+
settings.key,
|
|
809936
|
+
settings.admin,
|
|
809535
809937
|
"project"
|
|
809536
809938
|
);
|
|
809537
809939
|
} catch (err) {
|
|
809940
|
+
const retryable = err instanceof TelegramStartupError && err.retryable;
|
|
809941
|
+
const retryDelay = telegramAutoStartRetryDelaysMs[retryIndex];
|
|
809538
809942
|
writeContent(
|
|
809539
809943
|
() => renderWarning(
|
|
809540
|
-
`Telegram auto-start failed: ${err instanceof Error ? err.message : String(err)}`
|
|
809944
|
+
retryable && retryDelay !== void 0 ? `Telegram auto-start delayed: ${err.message}; retrying in ${Math.ceil(retryDelay / 1e3)}s` : `Telegram auto-start failed: ${err instanceof Error ? err.message : String(err)}`
|
|
809541
809945
|
)
|
|
809542
809946
|
);
|
|
809543
809947
|
showPrompt();
|
|
809948
|
+
if (retryable && retryDelay !== void 0) {
|
|
809949
|
+
scheduleTelegramAutoStart(retryDelay, retryIndex + 1);
|
|
809950
|
+
}
|
|
809544
809951
|
}
|
|
809545
|
-
},
|
|
809952
|
+
}, delayMs);
|
|
809953
|
+
telegramAutoStartTimer.unref?.();
|
|
809954
|
+
};
|
|
809955
|
+
if (!isResumed && autoTelegramSettings.key && autoTelegramSettings.enabled !== false && process.env["OMNIUS_TELEGRAM_DISABLED"] !== "1") {
|
|
809956
|
+
scheduleTelegramAutoStart(200);
|
|
809546
809957
|
}
|
|
809547
809958
|
let pasteBuffer = [];
|
|
809548
809959
|
let pasteTimer = null;
|
|
@@ -810693,11 +811104,8 @@ ${c3.dim("(Use /quit to exit)")}
|
|
|
810693
811104
|
async function shouldRunFirstRunSetup(config, firstRun = isFirstRun()) {
|
|
810694
811105
|
if (config.backendType !== "ollama") return false;
|
|
810695
811106
|
if (!firstRun) return false;
|
|
810696
|
-
|
|
810697
|
-
|
|
810698
|
-
} catch {
|
|
810699
|
-
return false;
|
|
810700
|
-
}
|
|
811107
|
+
const availability = await checkModelAvailability(config);
|
|
811108
|
+
return availability.status === "unavailable";
|
|
810701
811109
|
}
|
|
810702
811110
|
async function runWithTUI(task, config, repoPath2, callbacks) {
|
|
810703
811111
|
const repoRoot = resolve84(repoPath2 ?? cwd());
|