omnius 1.0.72 → 1.0.73
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 +929 -120
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87766,7 +87766,7 @@ var require_axios = __commonJS({
|
|
|
87766
87766
|
}
|
|
87767
87767
|
var isString = typeOfTest("string");
|
|
87768
87768
|
var isFunction$1 = typeOfTest("function");
|
|
87769
|
-
var
|
|
87769
|
+
var isNumber2 = typeOfTest("number");
|
|
87770
87770
|
var isObject = (thing) => thing !== null && typeof thing === "object";
|
|
87771
87771
|
var isBoolean = (thing) => thing === true || thing === false;
|
|
87772
87772
|
var isPlainObject = (val) => {
|
|
@@ -87966,7 +87966,7 @@ var require_axios = __commonJS({
|
|
|
87966
87966
|
if (!thing) return null;
|
|
87967
87967
|
if (isArray(thing)) return thing;
|
|
87968
87968
|
let i2 = thing.length;
|
|
87969
|
-
if (!
|
|
87969
|
+
if (!isNumber2(i2)) return null;
|
|
87970
87970
|
const arr = new Array(i2);
|
|
87971
87971
|
while (i2-- > 0) {
|
|
87972
87972
|
arr[i2] = thing[i2];
|
|
@@ -88107,7 +88107,7 @@ var require_axios = __commonJS({
|
|
|
88107
88107
|
isFormData,
|
|
88108
88108
|
isArrayBufferView,
|
|
88109
88109
|
isString,
|
|
88110
|
-
isNumber,
|
|
88110
|
+
isNumber: isNumber2,
|
|
88111
88111
|
isBoolean,
|
|
88112
88112
|
isObject,
|
|
88113
88113
|
isPlainObject,
|
|
@@ -92298,7 +92298,7 @@ var require_auto = __commonJS({
|
|
|
92298
92298
|
// ../node_modules/acme-client/src/client.js
|
|
92299
92299
|
var require_client = __commonJS({
|
|
92300
92300
|
"../node_modules/acme-client/src/client.js"(exports, module) {
|
|
92301
|
-
var { createHash:
|
|
92301
|
+
var { createHash: createHash29 } = __require("crypto");
|
|
92302
92302
|
var { getPemBodyAsB64u } = require_crypto();
|
|
92303
92303
|
var { log: log22 } = require_logger();
|
|
92304
92304
|
var HttpClient = require_http();
|
|
@@ -92609,14 +92609,14 @@ var require_client = __commonJS({
|
|
|
92609
92609
|
*/
|
|
92610
92610
|
async getChallengeKeyAuthorization(challenge) {
|
|
92611
92611
|
const jwk = this.http.getJwk();
|
|
92612
|
-
const keysum =
|
|
92612
|
+
const keysum = createHash29("sha256").update(JSON.stringify(jwk));
|
|
92613
92613
|
const thumbprint = keysum.digest("base64url");
|
|
92614
92614
|
const result = `${challenge.token}.${thumbprint}`;
|
|
92615
92615
|
if (challenge.type === "http-01") {
|
|
92616
92616
|
return result;
|
|
92617
92617
|
}
|
|
92618
92618
|
if (challenge.type === "dns-01") {
|
|
92619
|
-
return
|
|
92619
|
+
return createHash29("sha256").update(result).digest("base64url");
|
|
92620
92620
|
}
|
|
92621
92621
|
if (challenge.type === "tls-alpn-01") {
|
|
92622
92622
|
return result;
|
|
@@ -235296,7 +235296,7 @@ var require_websocket2 = __commonJS({
|
|
|
235296
235296
|
var http6 = __require("http");
|
|
235297
235297
|
var net5 = __require("net");
|
|
235298
235298
|
var tls2 = __require("tls");
|
|
235299
|
-
var { randomBytes: randomBytes27, createHash:
|
|
235299
|
+
var { randomBytes: randomBytes27, createHash: createHash29 } = __require("crypto");
|
|
235300
235300
|
var { Duplex: Duplex3, Readable } = __require("stream");
|
|
235301
235301
|
var { URL: URL3 } = __require("url");
|
|
235302
235302
|
var PerMessageDeflate3 = require_permessage_deflate2();
|
|
@@ -235956,7 +235956,7 @@ var require_websocket2 = __commonJS({
|
|
|
235956
235956
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
235957
235957
|
return;
|
|
235958
235958
|
}
|
|
235959
|
-
const digest3 =
|
|
235959
|
+
const digest3 = createHash29("sha1").update(key + GUID).digest("base64");
|
|
235960
235960
|
if (res.headers["sec-websocket-accept"] !== digest3) {
|
|
235961
235961
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
235962
235962
|
return;
|
|
@@ -236323,7 +236323,7 @@ var require_websocket_server = __commonJS({
|
|
|
236323
236323
|
var EventEmitter14 = __require("events");
|
|
236324
236324
|
var http6 = __require("http");
|
|
236325
236325
|
var { Duplex: Duplex3 } = __require("stream");
|
|
236326
|
-
var { createHash:
|
|
236326
|
+
var { createHash: createHash29 } = __require("crypto");
|
|
236327
236327
|
var extension3 = require_extension2();
|
|
236328
236328
|
var PerMessageDeflate3 = require_permessage_deflate2();
|
|
236329
236329
|
var subprotocol3 = require_subprotocol();
|
|
@@ -236624,7 +236624,7 @@ var require_websocket_server = __commonJS({
|
|
|
236624
236624
|
);
|
|
236625
236625
|
}
|
|
236626
236626
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
236627
|
-
const digest3 =
|
|
236627
|
+
const digest3 = createHash29("sha1").update(key + GUID).digest("base64");
|
|
236628
236628
|
const headers = [
|
|
236629
236629
|
"HTTP/1.1 101 Switching Protocols",
|
|
236630
236630
|
"Upgrade: websocket",
|
|
@@ -243390,15 +243390,15 @@ var require_is_number = __commonJS({
|
|
|
243390
243390
|
var require_to_regex_range = __commonJS({
|
|
243391
243391
|
"../node_modules/to-regex-range/index.js"(exports, module) {
|
|
243392
243392
|
"use strict";
|
|
243393
|
-
var
|
|
243393
|
+
var isNumber2 = require_is_number();
|
|
243394
243394
|
var toRegexRange = (min, max, options2) => {
|
|
243395
|
-
if (
|
|
243395
|
+
if (isNumber2(min) === false) {
|
|
243396
243396
|
throw new TypeError("toRegexRange: expected the first argument to be a number");
|
|
243397
243397
|
}
|
|
243398
243398
|
if (max === void 0 || min === max) {
|
|
243399
243399
|
return String(min);
|
|
243400
243400
|
}
|
|
243401
|
-
if (
|
|
243401
|
+
if (isNumber2(max) === false) {
|
|
243402
243402
|
throw new TypeError("toRegexRange: expected the second argument to be a number.");
|
|
243403
243403
|
}
|
|
243404
243404
|
let opts = { relaxZeros: true, ...options2 };
|
|
@@ -243610,7 +243610,7 @@ var require_fill_range = __commonJS({
|
|
|
243610
243610
|
var isValidValue = (value2) => {
|
|
243611
243611
|
return typeof value2 === "number" || typeof value2 === "string" && value2 !== "";
|
|
243612
243612
|
};
|
|
243613
|
-
var
|
|
243613
|
+
var isNumber2 = (num) => Number.isInteger(+num);
|
|
243614
243614
|
var zeros = (input) => {
|
|
243615
243615
|
let value2 = `${input}`;
|
|
243616
243616
|
let index = -1;
|
|
@@ -243738,7 +243738,7 @@ var require_fill_range = __commonJS({
|
|
|
243738
243738
|
return range;
|
|
243739
243739
|
};
|
|
243740
243740
|
var fillLetters = (start2, end, step = 1, options2 = {}) => {
|
|
243741
|
-
if (!
|
|
243741
|
+
if (!isNumber2(start2) && start2.length > 1 || !isNumber2(end) && end.length > 1) {
|
|
243742
243742
|
return invalidRange(start2, end, options2);
|
|
243743
243743
|
}
|
|
243744
243744
|
let format3 = options2.transform || ((val) => String.fromCharCode(val));
|
|
@@ -243778,11 +243778,11 @@ var require_fill_range = __commonJS({
|
|
|
243778
243778
|
let opts = { ...options2 };
|
|
243779
243779
|
if (opts.capture === true) opts.wrap = true;
|
|
243780
243780
|
step = step || opts.step || 1;
|
|
243781
|
-
if (!
|
|
243781
|
+
if (!isNumber2(step)) {
|
|
243782
243782
|
if (step != null && !isObject(step)) return invalidStep(step, opts);
|
|
243783
243783
|
return fill(start2, end, 1, step);
|
|
243784
243784
|
}
|
|
243785
|
-
if (
|
|
243785
|
+
if (isNumber2(start2) && isNumber2(end)) {
|
|
243786
243786
|
return fillNumbers(start2, end, step, opts);
|
|
243787
243787
|
}
|
|
243788
243788
|
return fillLetters(start2, end, Math.max(Math.abs(step), 1), opts);
|
|
@@ -249431,13 +249431,13 @@ Justification: ${justification || "(none provided)"}`,
|
|
|
249431
249431
|
}
|
|
249432
249432
|
const snapshot = JSON.stringify(this.selfState, null, 2);
|
|
249433
249433
|
try {
|
|
249434
|
-
const { createHash:
|
|
249434
|
+
const { createHash: createHash29 } = await import("node:crypto");
|
|
249435
249435
|
const snapshotDir = join30(this.cwd, ".omnius", "identity", "snapshots");
|
|
249436
249436
|
await mkdir7(snapshotDir, { recursive: true });
|
|
249437
249437
|
const version4 = this.selfState.version;
|
|
249438
249438
|
const snapshotPath = join30(snapshotDir, `v${version4}.json`);
|
|
249439
249439
|
await writeFile12(snapshotPath, snapshot, "utf8");
|
|
249440
|
-
const hash =
|
|
249440
|
+
const hash = createHash29("sha256").update(snapshot).digest("hex");
|
|
249441
249441
|
await writeFile12(join30(this.cwd, ".omnius", "identity", "latest-hash.txt"), hash, "utf8");
|
|
249442
249442
|
let ipfsCid = "";
|
|
249443
249443
|
try {
|
|
@@ -249570,8 +249570,8 @@ New: ${newNarrative.slice(0, 200)}...`,
|
|
|
249570
249570
|
}
|
|
249571
249571
|
// ── Helpers ──────────────────────────────────────────────────────────────
|
|
249572
249572
|
createDefaultState() {
|
|
249573
|
-
const { createHash:
|
|
249574
|
-
const machineId =
|
|
249573
|
+
const { createHash: createHash29 } = __require("node:crypto");
|
|
249574
|
+
const machineId = createHash29("sha256").update(this.cwd).digest("hex").slice(0, 12);
|
|
249575
249575
|
return {
|
|
249576
249576
|
self_id: `omnius-${machineId}`,
|
|
249577
249577
|
version: 1,
|
|
@@ -249653,9 +249653,9 @@ New: ${newNarrative.slice(0, 200)}...`,
|
|
|
249653
249653
|
let cid;
|
|
249654
249654
|
if (this.selfState.version > prevVersion) {
|
|
249655
249655
|
try {
|
|
249656
|
-
const { createHash:
|
|
249656
|
+
const { createHash: createHash29 } = await import("node:crypto");
|
|
249657
249657
|
const stateJson = JSON.stringify(this.selfState);
|
|
249658
|
-
const hash =
|
|
249658
|
+
const hash = createHash29("sha256").update(stateJson).digest("hex").slice(0, 32);
|
|
249659
249659
|
const cidsPath = join30(this.cwd, ".omnius", "identity", "cids.json");
|
|
249660
249660
|
const cidsData = { latest: "", hash, version: this.selfState.version };
|
|
249661
249661
|
try {
|
|
@@ -270064,7 +270064,7 @@ var require_typescript = __commonJS({
|
|
|
270064
270064
|
commandLineOptionOfCustomType: () => commandLineOptionOfCustomType,
|
|
270065
270065
|
commentPragmas: () => commentPragmas,
|
|
270066
270066
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
270067
|
-
compact: () =>
|
|
270067
|
+
compact: () => compact3,
|
|
270068
270068
|
compareBooleans: () => compareBooleans,
|
|
270069
270069
|
compareComparableValues: () => compareComparableValues,
|
|
270070
270070
|
compareDataObjects: () => compareDataObjects,
|
|
@@ -271372,7 +271372,7 @@ var require_typescript = __commonJS({
|
|
|
271372
271372
|
isNonStaticMethodOrAccessorWithPrivateName: () => isNonStaticMethodOrAccessorWithPrivateName,
|
|
271373
271373
|
isNotEmittedStatement: () => isNotEmittedStatement,
|
|
271374
271374
|
isNullishCoalesce: () => isNullishCoalesce,
|
|
271375
|
-
isNumber: () =>
|
|
271375
|
+
isNumber: () => isNumber2,
|
|
271376
271376
|
isNumericLiteral: () => isNumericLiteral,
|
|
271377
271377
|
isNumericLiteralName: () => isNumericLiteralName,
|
|
271378
271378
|
isObjectBindingElementWithoutPropertyName: () => isObjectBindingElementWithoutPropertyName,
|
|
@@ -272579,7 +272579,7 @@ var require_typescript = __commonJS({
|
|
|
272579
272579
|
}
|
|
272580
272580
|
return true;
|
|
272581
272581
|
}
|
|
272582
|
-
function
|
|
272582
|
+
function compact3(array) {
|
|
272583
272583
|
let result;
|
|
272584
272584
|
if (array !== void 0) {
|
|
272585
272585
|
for (let i2 = 0; i2 < array.length; i2++) {
|
|
@@ -273114,7 +273114,7 @@ var require_typescript = __commonJS({
|
|
|
273114
273114
|
function isString(text) {
|
|
273115
273115
|
return typeof text === "string";
|
|
273116
273116
|
}
|
|
273117
|
-
function
|
|
273117
|
+
function isNumber2(x) {
|
|
273118
273118
|
return typeof x === "number";
|
|
273119
273119
|
}
|
|
273120
273120
|
function tryCast(value2, test) {
|
|
@@ -378650,7 +378650,7 @@ ${lanes.join("\n")}
|
|
|
378650
378650
|
node.operatorToken,
|
|
378651
378651
|
visitNode(node.right, visitor, isExpression)
|
|
378652
378652
|
);
|
|
378653
|
-
const expr = some(pendingExpressions) ? factory2.inlineExpressions(
|
|
378653
|
+
const expr = some(pendingExpressions) ? factory2.inlineExpressions(compact3([...pendingExpressions, node])) : node;
|
|
378654
378654
|
pendingExpressions = savedPendingExpressions;
|
|
378655
378655
|
return expr;
|
|
378656
378656
|
}
|
|
@@ -398919,7 +398919,7 @@ ${lanes.join("\n")}
|
|
|
398919
398919
|
let parameterProperties;
|
|
398920
398920
|
if (ctor) {
|
|
398921
398921
|
const oldDiag2 = getSymbolAccessibilityDiagnostic;
|
|
398922
|
-
parameterProperties =
|
|
398922
|
+
parameterProperties = compact3(flatMap(ctor.parameters, (param) => {
|
|
398923
398923
|
if (!hasSyntacticModifier(
|
|
398924
398924
|
param,
|
|
398925
398925
|
31
|
|
@@ -410266,8 +410266,8 @@ ${lanes.join("\n")}
|
|
|
410266
410266
|
return result;
|
|
410267
410267
|
}
|
|
410268
410268
|
function getPendingEmitKind(optionsOrEmitKind, oldOptionsOrEmitKind) {
|
|
410269
|
-
const oldEmitKind = oldOptionsOrEmitKind && (
|
|
410270
|
-
const emitKind =
|
|
410269
|
+
const oldEmitKind = oldOptionsOrEmitKind && (isNumber2(oldOptionsOrEmitKind) ? oldOptionsOrEmitKind : getBuilderFileEmit(oldOptionsOrEmitKind));
|
|
410270
|
+
const emitKind = isNumber2(optionsOrEmitKind) ? optionsOrEmitKind : getBuilderFileEmit(optionsOrEmitKind);
|
|
410271
410271
|
if (oldEmitKind === emitKind) return 0;
|
|
410272
410272
|
if (!oldEmitKind || !emitKind) return emitKind;
|
|
410273
410273
|
const diff = oldEmitKind ^ emitKind;
|
|
@@ -410998,7 +410998,7 @@ ${lanes.join("\n")}
|
|
|
410998
410998
|
if (isLastStartEnd && last22[1] === fileId - 1) return last22[1] = fileId;
|
|
410999
410999
|
if (isLastStartEnd || root.length === 1 || last22 !== fileId - 1) return root.push(fileId);
|
|
411000
411000
|
const lastButOne = root[root.length - 2];
|
|
411001
|
-
if (!
|
|
411001
|
+
if (!isNumber2(lastButOne) || lastButOne !== last22 - 1) return root.push(fileId);
|
|
411002
411002
|
root[root.length - 2] = [lastButOne, fileId];
|
|
411003
411003
|
return root.length = root.length - 1;
|
|
411004
411004
|
}
|
|
@@ -411598,7 +411598,7 @@ ${lanes.join("\n")}
|
|
|
411598
411598
|
return isString(fileInfo) ? { version: fileInfo, signature: fileInfo, affectsGlobalScope: void 0, impliedFormat: void 0 } : isString(fileInfo.signature) ? fileInfo : { version: fileInfo.version, signature: fileInfo.signature === false ? void 0 : fileInfo.version, affectsGlobalScope: fileInfo.affectsGlobalScope, impliedFormat: fileInfo.impliedFormat };
|
|
411599
411599
|
}
|
|
411600
411600
|
function toBuilderFileEmit(value2, fullEmitForOptions) {
|
|
411601
|
-
return
|
|
411601
|
+
return isNumber2(value2) ? fullEmitForOptions : value2[1] || 24;
|
|
411602
411602
|
}
|
|
411603
411603
|
function toProgramEmitPending(value2, options2) {
|
|
411604
411604
|
return !value2 ? getBuilderFileEmit(options2 || {}) : value2;
|
|
@@ -411641,7 +411641,7 @@ ${lanes.join("\n")}
|
|
|
411641
411641
|
if (emitSignatures && stateFileInfo.signature) emitSignatures.set(path12, stateFileInfo.signature);
|
|
411642
411642
|
});
|
|
411643
411643
|
(_d = buildInfo.emitSignatures) == null ? void 0 : _d.forEach((value2) => {
|
|
411644
|
-
if (
|
|
411644
|
+
if (isNumber2(value2)) emitSignatures.delete(toFilePath(value2));
|
|
411645
411645
|
else {
|
|
411646
411646
|
const key = toFilePath(value2[0]);
|
|
411647
411647
|
emitSignatures.set(
|
|
@@ -411662,7 +411662,7 @@ ${lanes.join("\n")}
|
|
|
411662
411662
|
emitDiagnosticsPerFile: toPerFileEmitDiagnostics(buildInfo.emitDiagnosticsPerFile),
|
|
411663
411663
|
hasReusableDiagnostic: true,
|
|
411664
411664
|
changedFilesSet,
|
|
411665
|
-
affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value2) => toFilePath(
|
|
411665
|
+
affectedFilesPendingEmit: buildInfo.affectedFilesPendingEmit && arrayToMap(buildInfo.affectedFilesPendingEmit, (value2) => toFilePath(isNumber2(value2) ? value2 : value2[0]), (value2) => toBuilderFileEmit(value2, fullEmitForOptions)),
|
|
411666
411666
|
latestChangedDtsFile,
|
|
411667
411667
|
emitSignatures: (emitSignatures == null ? void 0 : emitSignatures.size) ? emitSignatures : void 0,
|
|
411668
411668
|
hasErrors: buildInfo.errors,
|
|
@@ -411718,7 +411718,7 @@ ${lanes.join("\n")}
|
|
|
411718
411718
|
)
|
|
411719
411719
|
);
|
|
411720
411720
|
diagnostics == null ? void 0 : diagnostics.forEach((value2) => {
|
|
411721
|
-
if (
|
|
411721
|
+
if (isNumber2(value2)) semanticDiagnostics.delete(toFilePath(value2));
|
|
411722
411722
|
else semanticDiagnostics.set(toFilePath(value2[0]), value2[1]);
|
|
411723
411723
|
});
|
|
411724
411724
|
return semanticDiagnostics;
|
|
@@ -435962,7 +435962,7 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
435962
435962
|
return decl;
|
|
435963
435963
|
}
|
|
435964
435964
|
function getIsMatchingAsyncError(span, errorCode) {
|
|
435965
|
-
return ({ start: start2, length: length22, relatedInformation, code: code8 }) =>
|
|
435965
|
+
return ({ start: start2, length: length22, relatedInformation, code: code8 }) => isNumber2(start2) && isNumber2(length22) && textSpansEqual({ start: start2, length: length22 }, span) && code8 === errorCode && !!relatedInformation && some(relatedInformation, (related) => related.code === Diagnostics.Did_you_mean_to_mark_this_function_as_async.code);
|
|
435966
435966
|
}
|
|
435967
435967
|
var fixId3 = "addMissingAwait";
|
|
435968
435968
|
var propertyAccessCode = Diagnostics.Property_0_does_not_exist_on_type_1.code;
|
|
@@ -436000,7 +436000,7 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
436000
436000
|
}
|
|
436001
436001
|
const checker = context2.program.getTypeChecker();
|
|
436002
436002
|
const trackChanges = (cb) => ts_textChanges_exports.ChangeTracker.with(context2, cb);
|
|
436003
|
-
return
|
|
436003
|
+
return compact3([
|
|
436004
436004
|
getDeclarationSiteFix(context2, expression, errorCode, checker, trackChanges),
|
|
436005
436005
|
getUseSiteFix(context2, expression, errorCode, checker, trackChanges)
|
|
436006
436006
|
]);
|
|
@@ -436047,7 +436047,7 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
436047
436047
|
function isMissingAwaitError(sourceFile, errorCode, span, cancellationToken, program) {
|
|
436048
436048
|
const checker = program.getTypeChecker();
|
|
436049
436049
|
const diagnostics = checker.getDiagnostics(sourceFile, cancellationToken);
|
|
436050
|
-
return some(diagnostics, ({ start: start2, length: length22, relatedInformation, code: code8 }) =>
|
|
436050
|
+
return some(diagnostics, ({ start: start2, length: length22, relatedInformation, code: code8 }) => isNumber2(start2) && isNumber2(length22) && textSpansEqual({ start: start2, length: length22 }, span) && code8 === errorCode && !!relatedInformation && some(relatedInformation, (related) => related.code === Diagnostics.Did_you_forget_to_use_await.code));
|
|
436051
436051
|
}
|
|
436052
436052
|
function findAwaitableInitializers(expression, sourceFile, cancellationToken, program, checker) {
|
|
436053
436053
|
const identifiers = getIdentifiersFromErrorSpanExpression(expression, checker);
|
|
@@ -459591,7 +459591,7 @@ ${content}
|
|
|
459591
459591
|
const lastToken = last2(children2);
|
|
459592
459592
|
const separateLastToken = separateTrailingSemicolon && lastToken.kind === 27;
|
|
459593
459593
|
const rightChildren = children2.slice(splitTokenIndex + 1, separateLastToken ? children2.length - 1 : void 0);
|
|
459594
|
-
const result =
|
|
459594
|
+
const result = compact3([
|
|
459595
459595
|
leftChildren.length ? createSyntaxList2(leftChildren) : void 0,
|
|
459596
459596
|
splitToken,
|
|
459597
459597
|
rightChildren.length ? createSyntaxList2(rightChildren) : void 0
|
|
@@ -466315,7 +466315,7 @@ ${options2.prefix}` : "\n" : options2.prefix
|
|
|
466315
466315
|
commandLineOptionOfCustomType: () => commandLineOptionOfCustomType,
|
|
466316
466316
|
commentPragmas: () => commentPragmas,
|
|
466317
466317
|
commonOptionsWithBuild: () => commonOptionsWithBuild,
|
|
466318
|
-
compact: () =>
|
|
466318
|
+
compact: () => compact3,
|
|
466319
466319
|
compareBooleans: () => compareBooleans,
|
|
466320
466320
|
compareComparableValues: () => compareComparableValues,
|
|
466321
466321
|
compareDataObjects: () => compareDataObjects,
|
|
@@ -467623,7 +467623,7 @@ ${options2.prefix}` : "\n" : options2.prefix
|
|
|
467623
467623
|
isNonStaticMethodOrAccessorWithPrivateName: () => isNonStaticMethodOrAccessorWithPrivateName,
|
|
467624
467624
|
isNotEmittedStatement: () => isNotEmittedStatement,
|
|
467625
467625
|
isNullishCoalesce: () => isNullishCoalesce,
|
|
467626
|
-
isNumber: () =>
|
|
467626
|
+
isNumber: () => isNumber2,
|
|
467627
467627
|
isNumericLiteral: () => isNumericLiteral,
|
|
467628
467628
|
isNumericLiteralName: () => isNumericLiteralName,
|
|
467629
467629
|
isObjectBindingElementWithoutPropertyName: () => isObjectBindingElementWithoutPropertyName,
|
|
@@ -544024,8 +544024,8 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
544024
544024
|
if (process.env["OMNIUS_DISABLE_ADAPTIVE_RETRIEVAL"] !== "1") {
|
|
544025
544025
|
const goalForSig = (this._taskState.goal || "").slice(0, 200);
|
|
544026
544026
|
const recentTools = this._toolSequence.slice(-5).join("|");
|
|
544027
|
-
const { createHash:
|
|
544028
|
-
const sig =
|
|
544027
|
+
const { createHash: createHash29 } = await import("node:crypto");
|
|
544028
|
+
const sig = createHash29("sha256").update(`${goalForSig}::${recentTools}`).digest("hex").slice(0, 16);
|
|
544029
544029
|
if (this._lastPprSig === sig && this._lastPprMemoryLines.length > 0) {
|
|
544030
544030
|
compacted.push({
|
|
544031
544031
|
role: "system",
|
|
@@ -559204,7 +559204,7 @@ var require_websocket3 = __commonJS({
|
|
|
559204
559204
|
var http6 = __require("http");
|
|
559205
559205
|
var net5 = __require("net");
|
|
559206
559206
|
var tls2 = __require("tls");
|
|
559207
|
-
var { randomBytes: randomBytes27, createHash:
|
|
559207
|
+
var { randomBytes: randomBytes27, createHash: createHash29 } = __require("crypto");
|
|
559208
559208
|
var { Duplex: Duplex3, Readable } = __require("stream");
|
|
559209
559209
|
var { URL: URL3 } = __require("url");
|
|
559210
559210
|
var PerMessageDeflate3 = require_permessage_deflate3();
|
|
@@ -559864,7 +559864,7 @@ var require_websocket3 = __commonJS({
|
|
|
559864
559864
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
559865
559865
|
return;
|
|
559866
559866
|
}
|
|
559867
|
-
const digest3 =
|
|
559867
|
+
const digest3 = createHash29("sha1").update(key + GUID).digest("base64");
|
|
559868
559868
|
if (res.headers["sec-websocket-accept"] !== digest3) {
|
|
559869
559869
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
559870
559870
|
return;
|
|
@@ -560231,7 +560231,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
560231
560231
|
var EventEmitter14 = __require("events");
|
|
560232
560232
|
var http6 = __require("http");
|
|
560233
560233
|
var { Duplex: Duplex3 } = __require("stream");
|
|
560234
|
-
var { createHash:
|
|
560234
|
+
var { createHash: createHash29 } = __require("crypto");
|
|
560235
560235
|
var extension3 = require_extension3();
|
|
560236
560236
|
var PerMessageDeflate3 = require_permessage_deflate3();
|
|
560237
560237
|
var subprotocol3 = require_subprotocol2();
|
|
@@ -560532,7 +560532,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
560532
560532
|
);
|
|
560533
560533
|
}
|
|
560534
560534
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
560535
|
-
const digest3 =
|
|
560535
|
+
const digest3 = createHash29("sha1").update(key + GUID).digest("base64");
|
|
560536
560536
|
const headers = [
|
|
560537
560537
|
"HTTP/1.1 101 Switching Protocols",
|
|
560538
560538
|
"Upgrade: websocket",
|
|
@@ -563932,9 +563932,9 @@ function keywords(text) {
|
|
|
563932
563932
|
return out;
|
|
563933
563933
|
}
|
|
563934
563934
|
function compactLine(text, limit = 220) {
|
|
563935
|
-
const
|
|
563936
|
-
if (
|
|
563937
|
-
return `${
|
|
563935
|
+
const compact3 = text.replace(/\s+/g, " ").trim();
|
|
563936
|
+
if (compact3.length <= limit) return compact3;
|
|
563937
|
+
return `${compact3.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
|
|
563938
563938
|
}
|
|
563939
563939
|
function newDocument(scope) {
|
|
563940
563940
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -567606,9 +567606,9 @@ function formatCaps(caps) {
|
|
|
567606
567606
|
if (caps.thinking) tags.push("think");
|
|
567607
567607
|
return tags.join("+");
|
|
567608
567608
|
}
|
|
567609
|
-
function formatRelativeTime(
|
|
567609
|
+
function formatRelativeTime(iso2) {
|
|
567610
567610
|
const now = Date.now();
|
|
567611
|
-
const then = new Date(
|
|
567611
|
+
const then = new Date(iso2).getTime();
|
|
567612
567612
|
const diffMs = now - then;
|
|
567613
567613
|
const minutes = Math.floor(diffMs / 6e4);
|
|
567614
567614
|
if (minutes < 1) return "just now";
|
|
@@ -573449,10 +573449,10 @@ ${CONTENT_BG_SEQ}`);
|
|
|
573449
573449
|
if (this._telegramStatus.active) {
|
|
573450
573450
|
const suffix = this._telegramStatus.activeSubAgents > 0 ? ` ${this._telegramStatus.activeSubAgents}` : "";
|
|
573451
573451
|
const label = `✈ tg${suffix}`;
|
|
573452
|
-
const
|
|
573452
|
+
const compact3 = `✈${suffix}`;
|
|
573453
573453
|
sections.push({
|
|
573454
573454
|
expanded: `\x1B[38;5;45m${label}\x1B[0m`,
|
|
573455
|
-
compact: `\x1B[38;5;45m${
|
|
573455
|
+
compact: `\x1B[38;5;45m${compact3}\x1B[0m`,
|
|
573456
573456
|
expandedW: 2 + 3 + suffix.length,
|
|
573457
573457
|
compactW: 2 + suffix.length,
|
|
573458
573458
|
empty: false
|
|
@@ -608152,26 +608152,38 @@ function buildOpenQuestions(input) {
|
|
|
608152
608152
|
}
|
|
608153
608153
|
function buildReplyOpportunities(input, openQuestions) {
|
|
608154
608154
|
const opportunities = [];
|
|
608155
|
+
const lifecycleUpdatedAt = new Date(input.generatedAtMs).toISOString();
|
|
608155
608156
|
for (const question of openQuestions.slice(-3)) {
|
|
608157
|
+
const trigger = question;
|
|
608156
608158
|
opportunities.push({
|
|
608157
|
-
|
|
608159
|
+
id: daydreamOpportunityId(input, trigger),
|
|
608160
|
+
trigger,
|
|
608158
608161
|
rationale: "The group left a question or uncertainty that may benefit from a concise clarification.",
|
|
608159
608162
|
suggestedTone: "brief, contextual, ask one concrete follow-up if needed",
|
|
608160
|
-
confidence: 0.62
|
|
608163
|
+
confidence: 0.62,
|
|
608164
|
+
lifecycle: "proposed",
|
|
608165
|
+
lifecycleUpdatedAt
|
|
608161
608166
|
});
|
|
608162
608167
|
}
|
|
608163
608168
|
const recent = recentUserMessages(input);
|
|
608164
608169
|
const last2 = recent[recent.length - 1];
|
|
608165
608170
|
if (last2 && /\b(omnius|bot|agent)\b/i.test(last2.text) && opportunities.length < 4) {
|
|
608171
|
+
const trigger = `${last2.speaker || last2.username || "user"} mentioned the agent: ${compactLine2(last2.text, 160)}`;
|
|
608166
608172
|
opportunities.push({
|
|
608167
|
-
|
|
608173
|
+
id: daydreamOpportunityId(input, trigger),
|
|
608174
|
+
trigger,
|
|
608168
608175
|
rationale: "A later live-router pass should consider whether this is a direct social opening or just third-person chatter.",
|
|
608169
608176
|
suggestedTone: "low-intrusion, do not assume the turn belongs to the agent",
|
|
608170
|
-
confidence: 0.48
|
|
608177
|
+
confidence: 0.48,
|
|
608178
|
+
lifecycle: "proposed",
|
|
608179
|
+
lifecycleUpdatedAt
|
|
608171
608180
|
});
|
|
608172
608181
|
}
|
|
608173
608182
|
return opportunities;
|
|
608174
608183
|
}
|
|
608184
|
+
function daydreamOpportunityId(input, trigger) {
|
|
608185
|
+
return createHash21("sha1").update(`${input.sessionKey}:${input.generatedAtMs}:${trigger}`).digest("hex").slice(0, 16);
|
|
608186
|
+
}
|
|
608175
608187
|
function clamp018(value2) {
|
|
608176
608188
|
if (!Number.isFinite(value2)) return 0;
|
|
608177
608189
|
return Math.max(0, Math.min(1, value2));
|
|
@@ -608607,6 +608619,8 @@ Selected seed: ${artifact.selectedSeed.nodeText} (${artifact.selectedSeed.nodeTy
|
|
|
608607
608619
|
"",
|
|
608608
608620
|
"## Reply Opportunities",
|
|
608609
608621
|
artifact.replyOpportunities.length ? artifact.replyOpportunities.map((item) => `- ${item.trigger}
|
|
608622
|
+
- id: ${item.id}
|
|
608623
|
+
- lifecycle: ${item.lifecycle}${item.lifecycleUpdatedAt ? ` at ${item.lifecycleUpdatedAt}` : ""}
|
|
608610
608624
|
- rationale: ${item.rationale}
|
|
608611
608625
|
- tone: ${item.suggestedTone}
|
|
608612
608626
|
- confidence: ${item.confidence.toFixed(2)}`).join("\n") : "- None",
|
|
@@ -608690,7 +608704,7 @@ ${artifact.contextEngineeringNotes.slice(0, 5).map((line) => `- ${line}`).join("
|
|
|
608690
608704
|
artifact.openQuestions.length ? `Open questions:
|
|
608691
608705
|
${artifact.openQuestions.slice(0, 4).map((line) => `- ${line}`).join("\n")}` : "",
|
|
608692
608706
|
artifact.replyOpportunities.length ? `Possible reply opportunities:
|
|
608693
|
-
${artifact.replyOpportunities.slice(0, 3).map((item) => `- ${item.trigger} (confidence ${item.confidence.toFixed(2)}; ${item.suggestedTone})`).join("\n")}` : ""
|
|
608707
|
+
${artifact.replyOpportunities.slice(0, 3).map((item) => `- ${item.id} [${item.lifecycle}] ${item.trigger} (confidence ${item.confidence.toFixed(2)}; ${item.suggestedTone})`).join("\n")}` : ""
|
|
608694
608708
|
].filter(Boolean);
|
|
608695
608709
|
return lines.join("\n");
|
|
608696
608710
|
}
|
|
@@ -609415,6 +609429,600 @@ var init_telegram_reflection_extraction = __esm({
|
|
|
609415
609429
|
}
|
|
609416
609430
|
});
|
|
609417
609431
|
|
|
609432
|
+
// packages/cli/src/tui/telegram-social-state-types.ts
|
|
609433
|
+
import { createHash as createHash23 } from "node:crypto";
|
|
609434
|
+
function telegramSocialActorKey(actor) {
|
|
609435
|
+
if (!actor) return "unknown";
|
|
609436
|
+
if (typeof actor.userId === "number") return `user:${actor.userId}`;
|
|
609437
|
+
const username = cleanUsername(actor.username);
|
|
609438
|
+
if (username) return `username:${username.toLowerCase()}`;
|
|
609439
|
+
const first2 = compact2(actor.firstName, 80).toLowerCase();
|
|
609440
|
+
return first2 ? `name:${first2}` : "unknown";
|
|
609441
|
+
}
|
|
609442
|
+
function telegramSocialActorKind(actor) {
|
|
609443
|
+
if (actor.isSelf || actor.isBot) return "bot";
|
|
609444
|
+
if (actor.userId || actor.username || actor.firstName) return "human";
|
|
609445
|
+
return "unknown";
|
|
609446
|
+
}
|
|
609447
|
+
function telegramSocialThreadKey(input) {
|
|
609448
|
+
return input.messageThreadId !== void 0 ? `chat:${String(input.chatId)}:thread:${input.messageThreadId}` : `chat:${String(input.chatId)}`;
|
|
609449
|
+
}
|
|
609450
|
+
function appendUnique(items, value2, max) {
|
|
609451
|
+
if (value2 === void 0 || value2 === null) return items.slice(-max);
|
|
609452
|
+
const next = items.filter((item) => item !== value2);
|
|
609453
|
+
next.push(value2);
|
|
609454
|
+
return next.slice(-max);
|
|
609455
|
+
}
|
|
609456
|
+
function hashTelegramSocialId(parts) {
|
|
609457
|
+
return createHash23("sha1").update(parts.map((part) => String(part ?? "")).join(":")).digest("hex").slice(0, 16);
|
|
609458
|
+
}
|
|
609459
|
+
function cleanUsername(value2) {
|
|
609460
|
+
if (typeof value2 !== "string") return void 0;
|
|
609461
|
+
const clean5 = value2.trim().replace(/^@/, "");
|
|
609462
|
+
return clean5 ? clean5.slice(0, 80) : void 0;
|
|
609463
|
+
}
|
|
609464
|
+
function compactOptional(value2, max) {
|
|
609465
|
+
const clean5 = compact2(value2, max);
|
|
609466
|
+
return clean5 || void 0;
|
|
609467
|
+
}
|
|
609468
|
+
function compact2(value2, max) {
|
|
609469
|
+
if (value2 === void 0 || value2 === null) return "";
|
|
609470
|
+
const clean5 = String(value2).replace(/\s+/g, " ").trim();
|
|
609471
|
+
return clean5.length > max ? `${clean5.slice(0, Math.max(0, max - 3)).trimEnd()}...` : clean5;
|
|
609472
|
+
}
|
|
609473
|
+
function jsonLine(value2, max) {
|
|
609474
|
+
return JSON.stringify(compact2(value2, max));
|
|
609475
|
+
}
|
|
609476
|
+
function numberOr(value2, fallback) {
|
|
609477
|
+
return typeof value2 === "number" && Number.isFinite(value2) ? value2 : fallback;
|
|
609478
|
+
}
|
|
609479
|
+
function isNumber(value2) {
|
|
609480
|
+
return typeof value2 === "number" && Number.isFinite(value2);
|
|
609481
|
+
}
|
|
609482
|
+
function clamp019(value2) {
|
|
609483
|
+
return Math.max(0, Math.min(1, Number.isFinite(value2) ? value2 : 0));
|
|
609484
|
+
}
|
|
609485
|
+
function iso(ts) {
|
|
609486
|
+
try {
|
|
609487
|
+
return new Date(ts).toISOString();
|
|
609488
|
+
} catch {
|
|
609489
|
+
return "";
|
|
609490
|
+
}
|
|
609491
|
+
}
|
|
609492
|
+
var TELEGRAM_SOCIAL_LIMITS;
|
|
609493
|
+
var init_telegram_social_state_types = __esm({
|
|
609494
|
+
"packages/cli/src/tui/telegram-social-state-types.ts"() {
|
|
609495
|
+
"use strict";
|
|
609496
|
+
TELEGRAM_SOCIAL_LIMITS = {
|
|
609497
|
+
relationships: 240,
|
|
609498
|
+
salience: 180,
|
|
609499
|
+
outcomes: 160,
|
|
609500
|
+
daydreamOpportunities: 120,
|
|
609501
|
+
daydreamStaleMs: 6 * 60 * 6e4
|
|
609502
|
+
};
|
|
609503
|
+
}
|
|
609504
|
+
});
|
|
609505
|
+
|
|
609506
|
+
// packages/cli/src/tui/telegram-social-state-context.ts
|
|
609507
|
+
function formatTelegramSocialStateContext(state, input) {
|
|
609508
|
+
const limit = Math.max(3, Math.min(12, Math.floor(input.limit ?? 8)));
|
|
609509
|
+
const senderKey3 = telegramSocialActorKey(input);
|
|
609510
|
+
const selfKey = input.self ? telegramSocialActorKey(input.self) : void 0;
|
|
609511
|
+
const replyKey = input.replySender ? telegramSocialActorKey(input.replySender) : void 0;
|
|
609512
|
+
const thread = state.threads[telegramSocialThreadKey(input)];
|
|
609513
|
+
const participant = state.participants[senderKey3];
|
|
609514
|
+
const relevantKeys = new Set([senderKey3, selfKey, replyKey].filter(Boolean));
|
|
609515
|
+
const edges = state.relationships.filter((edge) => relevantKeys.has(edge.fromKey) || relevantKeys.has(edge.toKey)).sort((a2, b) => b.lastSeenAt - a2.lastSeenAt).slice(0, limit);
|
|
609516
|
+
const outcomes = state.outcomes.filter((outcome) => outcome.senderKey === senderKey3 || outcome.chatId === String(input.chatId)).sort((a2, b) => b.ts - a2.ts).slice(0, limit);
|
|
609517
|
+
const salience = state.salience.filter((item) => item.senderKey === senderKey3 || item.chatId === String(input.chatId)).sort((a2, b) => b.ts - a2.ts).slice(0, limit);
|
|
609518
|
+
const daydreams = Object.values(state.daydreamOpportunities).filter((item) => item.lifecycle !== "retired").sort((a2, b) => b.updatedAt - a2.updatedAt).slice(0, Math.min(5, limit));
|
|
609519
|
+
const preferences = preferenceLines(state.preferences[senderKey3]);
|
|
609520
|
+
return [
|
|
609521
|
+
"### Telegram Structured Social State",
|
|
609522
|
+
`Current actor node: ${senderKey3} [${participant?.actorKind || telegramSocialActorKind(input)}] messages=${participant?.messageCount ?? 0}${participant?.lastText ? ` last=${jsonLine(participant.lastText, 140)}` : ""}`,
|
|
609523
|
+
thread ? `Active channel/thread: ${thread.key}; messages=${thread.messageCount}; participants=${thread.participantKeys.slice(-8).join(", ") || "none"}; last_outcomes=${thread.lastOutcomeIds.slice(-5).join(", ") || "none"}` : "",
|
|
609524
|
+
preferences.length ? `Relevant preference vector for ${senderKey3}:
|
|
609525
|
+
${preferences.join("\n")}` : `Relevant preference vector for ${senderKey3}: no durable preferences yet`,
|
|
609526
|
+
salience.length ? `Recent salience observations:
|
|
609527
|
+
${salience.map((item) => `- ${iso(item.ts)} ${item.senderKey}: ${item.signals.join(", ") || "none"}; text=${jsonLine(item.textPreview, 120)}`).join("\n")}` : "",
|
|
609528
|
+
edges.length ? `Relevant relationship edges:
|
|
609529
|
+
${edges.map(formatEdge).join("\n")}` : "Relevant relationship edges: none yet",
|
|
609530
|
+
outcomes.length ? `Prior response outcomes:
|
|
609531
|
+
${outcomes.map(formatOutcome).join("\n")}` : "Prior response outcomes: none yet",
|
|
609532
|
+
daydreams.length ? `Active daydream opportunity lifecycle:
|
|
609533
|
+
${daydreams.map((item) => `- ${item.id} [${item.lifecycle}] confidence=${item.confidence.toFixed(2)} trigger=${jsonLine(item.trigger, 140)}`).join("\n")}` : ""
|
|
609534
|
+
].filter(Boolean).join("\n");
|
|
609535
|
+
}
|
|
609536
|
+
function preferenceLines(vector) {
|
|
609537
|
+
if (!vector) return [];
|
|
609538
|
+
return Object.entries(vector).map(([key, evidence]) => {
|
|
609539
|
+
const item = evidence;
|
|
609540
|
+
return `- ${key}: value=${item.value.toFixed(2)} confidence=${item.confidence.toFixed(2)} evidence=${item.evidenceMessageIds.join(",") || "none"}${item.note ? ` note=${jsonLine(item.note, 120)}` : ""}`;
|
|
609541
|
+
});
|
|
609542
|
+
}
|
|
609543
|
+
function formatEdge(edge) {
|
|
609544
|
+
const evidence = edge.evidenceMessageIds.length ? ` evidence=${edge.evidenceMessageIds.join(",")}` : "";
|
|
609545
|
+
const note = edge.note ? ` note=${jsonLine(edge.note, 140)}` : "";
|
|
609546
|
+
return `- ${edge.fromKey} --${edge.kind}--> ${edge.toKey} confidence=${edge.confidence.toFixed(2)} weight=${edge.weight.toFixed(2)}${evidence}${note}`;
|
|
609547
|
+
}
|
|
609548
|
+
function formatOutcome(outcome) {
|
|
609549
|
+
const action = outcome.shouldReply ? `replied via ${outcome.route}` : "silent";
|
|
609550
|
+
const note = outcome.mentalNote || outcome.memoryNote || outcome.relationshipNote || outcome.silentDisposition || outcome.reason;
|
|
609551
|
+
return `- ${iso(outcome.ts)} message=${outcome.messageId ?? "?"} ${action} confidence=${outcome.confidence.toFixed(2)} reason=${jsonLine(note, 160)}`;
|
|
609552
|
+
}
|
|
609553
|
+
var init_telegram_social_state_context = __esm({
|
|
609554
|
+
"packages/cli/src/tui/telegram-social-state-context.ts"() {
|
|
609555
|
+
"use strict";
|
|
609556
|
+
init_telegram_social_state_types();
|
|
609557
|
+
}
|
|
609558
|
+
});
|
|
609559
|
+
|
|
609560
|
+
// packages/cli/src/tui/telegram-social-state-normalize.ts
|
|
609561
|
+
function createTelegramSocialState(now = Date.now()) {
|
|
609562
|
+
return {
|
|
609563
|
+
version: 1,
|
|
609564
|
+
createdAt: now,
|
|
609565
|
+
updatedAt: now,
|
|
609566
|
+
participants: {},
|
|
609567
|
+
relationships: [],
|
|
609568
|
+
preferences: {},
|
|
609569
|
+
threads: {},
|
|
609570
|
+
salience: [],
|
|
609571
|
+
outcomes: [],
|
|
609572
|
+
daydreamOpportunities: {}
|
|
609573
|
+
};
|
|
609574
|
+
}
|
|
609575
|
+
function normalizeTelegramSocialState(raw) {
|
|
609576
|
+
const now = Date.now();
|
|
609577
|
+
if (!raw || typeof raw !== "object") return createTelegramSocialState(now);
|
|
609578
|
+
const value2 = raw;
|
|
609579
|
+
const state = createTelegramSocialState(now);
|
|
609580
|
+
state.createdAt = numberOr(value2.createdAt, state.createdAt);
|
|
609581
|
+
state.updatedAt = numberOr(value2.updatedAt, state.updatedAt);
|
|
609582
|
+
state.participants = normalizeRecord(value2.participants, normalizeParticipant);
|
|
609583
|
+
state.relationships = Array.isArray(value2.relationships) ? value2.relationships.map(normalizeRelationship).filter(Boolean).slice(-TELEGRAM_SOCIAL_LIMITS.relationships) : [];
|
|
609584
|
+
state.preferences = normalizePreferences(value2.preferences);
|
|
609585
|
+
state.threads = normalizeRecord(value2.threads, normalizeThread);
|
|
609586
|
+
state.salience = Array.isArray(value2.salience) ? value2.salience.map(normalizeSalience).filter(Boolean).slice(-TELEGRAM_SOCIAL_LIMITS.salience) : [];
|
|
609587
|
+
state.outcomes = Array.isArray(value2.outcomes) ? value2.outcomes.map(normalizeOutcome).filter(Boolean).slice(-TELEGRAM_SOCIAL_LIMITS.outcomes) : [];
|
|
609588
|
+
state.daydreamOpportunities = normalizeRecord(value2.daydreamOpportunities, normalizeDaydreamOpportunity);
|
|
609589
|
+
return state;
|
|
609590
|
+
}
|
|
609591
|
+
function normalizeRecord(raw, fn) {
|
|
609592
|
+
const output = {};
|
|
609593
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return output;
|
|
609594
|
+
for (const [key, value2] of Object.entries(raw)) {
|
|
609595
|
+
const normalized = fn(value2);
|
|
609596
|
+
if (normalized) output[key] = normalized;
|
|
609597
|
+
}
|
|
609598
|
+
return output;
|
|
609599
|
+
}
|
|
609600
|
+
function normalizeParticipant(raw) {
|
|
609601
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609602
|
+
const value2 = raw;
|
|
609603
|
+
const key = String(value2.key || "").trim();
|
|
609604
|
+
if (!key) return null;
|
|
609605
|
+
return {
|
|
609606
|
+
key,
|
|
609607
|
+
userId: typeof value2.userId === "number" ? value2.userId : void 0,
|
|
609608
|
+
username: cleanUsername(value2.username),
|
|
609609
|
+
displayName: compactOptional(value2.displayName, 120),
|
|
609610
|
+
actorKind: value2.actorKind === "bot" || value2.actorKind === "human" ? value2.actorKind : "unknown",
|
|
609611
|
+
aliases: Array.isArray(value2.aliases) ? value2.aliases.map(String).slice(0, 20) : [],
|
|
609612
|
+
firstSeenAt: numberOr(value2.firstSeenAt, Date.now()),
|
|
609613
|
+
lastSeenAt: numberOr(value2.lastSeenAt, Date.now()),
|
|
609614
|
+
messageCount: numberOr(value2.messageCount, 0),
|
|
609615
|
+
lastMessageIds: Array.isArray(value2.lastMessageIds) ? value2.lastMessageIds.filter(isNumber).slice(-30) : [],
|
|
609616
|
+
lastText: compactOptional(value2.lastText, 500)
|
|
609617
|
+
};
|
|
609618
|
+
}
|
|
609619
|
+
function normalizeRelationship(raw) {
|
|
609620
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609621
|
+
const value2 = raw;
|
|
609622
|
+
if (!value2.kind || !value2.fromKey || !value2.toKey) return null;
|
|
609623
|
+
return {
|
|
609624
|
+
id: String(value2.id || hashTelegramSocialId(["edge", value2.kind, value2.fromKey, value2.toKey])),
|
|
609625
|
+
kind: value2.kind,
|
|
609626
|
+
fromKey: String(value2.fromKey),
|
|
609627
|
+
toKey: String(value2.toKey),
|
|
609628
|
+
confidence: clamp019(numberOr(value2.confidence, 0)),
|
|
609629
|
+
weight: clamp019(numberOr(value2.weight, 0)),
|
|
609630
|
+
firstSeenAt: numberOr(value2.firstSeenAt, Date.now()),
|
|
609631
|
+
lastSeenAt: numberOr(value2.lastSeenAt, Date.now()),
|
|
609632
|
+
evidenceMessageIds: Array.isArray(value2.evidenceMessageIds) ? value2.evidenceMessageIds.filter(isNumber).slice(-40) : [],
|
|
609633
|
+
note: compactOptional(value2.note, 260),
|
|
609634
|
+
source: value2.source === "router" || value2.source === "daydream" ? value2.source : "message"
|
|
609635
|
+
};
|
|
609636
|
+
}
|
|
609637
|
+
function normalizePreferences(raw) {
|
|
609638
|
+
const out = {};
|
|
609639
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return out;
|
|
609640
|
+
for (const [actorKey, vector] of Object.entries(raw)) {
|
|
609641
|
+
if (!vector || typeof vector !== "object") continue;
|
|
609642
|
+
out[actorKey] = {};
|
|
609643
|
+
for (const key of ["verbosity", "depth", "silence", "directness", "botToBotTolerance"]) {
|
|
609644
|
+
const evidence = vector[key];
|
|
609645
|
+
if (!evidence || typeof evidence !== "object") continue;
|
|
609646
|
+
out[actorKey][key] = {
|
|
609647
|
+
value: Math.max(-1, Math.min(1, numberOr(evidence.value, 0))),
|
|
609648
|
+
confidence: clamp019(numberOr(evidence.confidence, 0)),
|
|
609649
|
+
updatedAt: numberOr(evidence.updatedAt, Date.now()),
|
|
609650
|
+
evidenceMessageIds: Array.isArray(evidence.evidenceMessageIds) ? evidence.evidenceMessageIds.filter(isNumber).slice(-12) : [],
|
|
609651
|
+
note: compactOptional(evidence.note, 220)
|
|
609652
|
+
};
|
|
609653
|
+
}
|
|
609654
|
+
}
|
|
609655
|
+
return out;
|
|
609656
|
+
}
|
|
609657
|
+
function normalizeThread(raw) {
|
|
609658
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609659
|
+
const value2 = raw;
|
|
609660
|
+
const key = String(value2.key || "").trim();
|
|
609661
|
+
if (!key) return null;
|
|
609662
|
+
return {
|
|
609663
|
+
key,
|
|
609664
|
+
chatId: String(value2.chatId || ""),
|
|
609665
|
+
chatType: compactOptional(value2.chatType, 40),
|
|
609666
|
+
chatTitle: compactOptional(value2.chatTitle, 120),
|
|
609667
|
+
messageThreadId: typeof value2.messageThreadId === "number" ? value2.messageThreadId : void 0,
|
|
609668
|
+
firstSeenAt: numberOr(value2.firstSeenAt, Date.now()),
|
|
609669
|
+
lastSeenAt: numberOr(value2.lastSeenAt, Date.now()),
|
|
609670
|
+
messageCount: numberOr(value2.messageCount, 0),
|
|
609671
|
+
participantKeys: Array.isArray(value2.participantKeys) ? value2.participantKeys.map(String).slice(-40) : [],
|
|
609672
|
+
lastMessageIds: Array.isArray(value2.lastMessageIds) ? value2.lastMessageIds.filter(isNumber).slice(-40) : [],
|
|
609673
|
+
lastOutcomeIds: Array.isArray(value2.lastOutcomeIds) ? value2.lastOutcomeIds.map(String).slice(-30) : []
|
|
609674
|
+
};
|
|
609675
|
+
}
|
|
609676
|
+
function normalizeSalience(raw) {
|
|
609677
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609678
|
+
const value2 = raw;
|
|
609679
|
+
if (!value2.senderKey) return null;
|
|
609680
|
+
return {
|
|
609681
|
+
id: String(value2.id || hashTelegramSocialId(["salience", value2.senderKey, value2.messageId ?? Date.now()])),
|
|
609682
|
+
ts: numberOr(value2.ts, Date.now()),
|
|
609683
|
+
chatId: String(value2.chatId || ""),
|
|
609684
|
+
messageId: typeof value2.messageId === "number" ? value2.messageId : void 0,
|
|
609685
|
+
messageThreadId: typeof value2.messageThreadId === "number" ? value2.messageThreadId : void 0,
|
|
609686
|
+
senderKey: String(value2.senderKey),
|
|
609687
|
+
actorKind: value2.actorKind === "bot" || value2.actorKind === "human" ? value2.actorKind : "unknown",
|
|
609688
|
+
signals: Array.isArray(value2.signals) ? value2.signals.map(String).slice(0, 16) : [],
|
|
609689
|
+
textPreview: compact2(value2.textPreview || "", 240)
|
|
609690
|
+
};
|
|
609691
|
+
}
|
|
609692
|
+
function normalizeOutcome(raw) {
|
|
609693
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609694
|
+
const value2 = raw;
|
|
609695
|
+
if (!value2.senderKey) return null;
|
|
609696
|
+
return {
|
|
609697
|
+
id: String(value2.id || hashTelegramSocialId(["outcome", value2.senderKey, value2.messageId ?? Date.now()])),
|
|
609698
|
+
ts: numberOr(value2.ts, Date.now()),
|
|
609699
|
+
chatId: String(value2.chatId || ""),
|
|
609700
|
+
messageId: typeof value2.messageId === "number" ? value2.messageId : void 0,
|
|
609701
|
+
messageThreadId: typeof value2.messageThreadId === "number" ? value2.messageThreadId : void 0,
|
|
609702
|
+
senderKey: String(value2.senderKey),
|
|
609703
|
+
replyToMessageId: typeof value2.replyToMessageId === "number" ? value2.replyToMessageId : void 0,
|
|
609704
|
+
route: value2.route === "action" ? "action" : "chat",
|
|
609705
|
+
shouldReply: value2.shouldReply === true,
|
|
609706
|
+
confidence: clamp019(numberOr(value2.confidence, 0)),
|
|
609707
|
+
reason: compact2(value2.reason || "", 280),
|
|
609708
|
+
source: compact2(value2.source || "unknown", 80),
|
|
609709
|
+
silentDisposition: compactOptional(value2.silentDisposition, 280),
|
|
609710
|
+
mentalNote: compactOptional(value2.mentalNote, 360),
|
|
609711
|
+
memoryNote: compactOptional(value2.memoryNote, 360),
|
|
609712
|
+
relationshipNote: compactOptional(value2.relationshipNote, 360),
|
|
609713
|
+
salienceSignals: Array.isArray(value2.salienceSignals) ? value2.salienceSignals.map(String).slice(0, 16) : [],
|
|
609714
|
+
daydreamOpportunityIds: Array.isArray(value2.daydreamOpportunityIds) ? value2.daydreamOpportunityIds.map(String).slice(0, 16) : []
|
|
609715
|
+
};
|
|
609716
|
+
}
|
|
609717
|
+
function normalizeDaydreamOpportunity(raw) {
|
|
609718
|
+
if (!raw || typeof raw !== "object") return null;
|
|
609719
|
+
const value2 = raw;
|
|
609720
|
+
const id = String(value2.id || "").trim();
|
|
609721
|
+
if (!id) return null;
|
|
609722
|
+
const lifecycle = ["proposed", "considered", "acted", "suppressed", "retired"].includes(String(value2.lifecycle)) ? value2.lifecycle : "proposed";
|
|
609723
|
+
return {
|
|
609724
|
+
id,
|
|
609725
|
+
artifactId: String(value2.artifactId || "unknown"),
|
|
609726
|
+
generatedAt: String(value2.generatedAt || (/* @__PURE__ */ new Date()).toISOString()),
|
|
609727
|
+
trigger: compact2(value2.trigger || "", 240),
|
|
609728
|
+
confidence: clamp019(numberOr(value2.confidence, 0)),
|
|
609729
|
+
lifecycle,
|
|
609730
|
+
firstSeenAt: numberOr(value2.firstSeenAt, Date.now()),
|
|
609731
|
+
updatedAt: numberOr(value2.updatedAt, Date.now()),
|
|
609732
|
+
consideredMessageIds: Array.isArray(value2.consideredMessageIds) ? value2.consideredMessageIds.filter(isNumber).slice(-20) : [],
|
|
609733
|
+
actedMessageIds: Array.isArray(value2.actedMessageIds) ? value2.actedMessageIds.filter(isNumber).slice(-20) : [],
|
|
609734
|
+
suppressedMessageIds: Array.isArray(value2.suppressedMessageIds) ? value2.suppressedMessageIds.filter(isNumber).slice(-20) : [],
|
|
609735
|
+
retiredAt: typeof value2.retiredAt === "number" ? value2.retiredAt : void 0
|
|
609736
|
+
};
|
|
609737
|
+
}
|
|
609738
|
+
var init_telegram_social_state_normalize = __esm({
|
|
609739
|
+
"packages/cli/src/tui/telegram-social-state-normalize.ts"() {
|
|
609740
|
+
"use strict";
|
|
609741
|
+
init_telegram_social_state_types();
|
|
609742
|
+
}
|
|
609743
|
+
});
|
|
609744
|
+
|
|
609745
|
+
// packages/cli/src/tui/telegram-social-state.ts
|
|
609746
|
+
function observeTelegramSocialMessage(state, input) {
|
|
609747
|
+
const now = input.ts ?? Date.now();
|
|
609748
|
+
state.updatedAt = now;
|
|
609749
|
+
const senderKey3 = upsertParticipant(state, input, now, true);
|
|
609750
|
+
const thread = upsertThread(state, input, senderKey3, now, true);
|
|
609751
|
+
const text = compact2(input.text || "", 500);
|
|
609752
|
+
const participant = state.participants[senderKey3];
|
|
609753
|
+
if (participant) {
|
|
609754
|
+
participant.lastText = text || participant.lastText;
|
|
609755
|
+
participant.lastMessageIds = appendUnique(participant.lastMessageIds, input.messageId, 30);
|
|
609756
|
+
}
|
|
609757
|
+
addSalience(state, input, senderKey3, now, text);
|
|
609758
|
+
if (input.replySender || input.replyToMessageId !== void 0) {
|
|
609759
|
+
const targetKey = input.replySender ? upsertParticipant(state, input.replySender, now, false) : `message:${input.replyToMessageId}`;
|
|
609760
|
+
upsertRelationship(state, "replied_to", senderKey3, targetKey, input.messageId, 0.86, "message", replyNote(input), now);
|
|
609761
|
+
}
|
|
609762
|
+
const selfKey = input.self ? upsertParticipant(state, { ...input.self, isBot: true }, now, false) : void 0;
|
|
609763
|
+
addMessageDerivedEdges(state, input, senderKey3, selfKey, text, now);
|
|
609764
|
+
updatePreferencesFromText(state, senderKey3, text, input.messageId, now, telegramSocialActorKind(input));
|
|
609765
|
+
thread.lastMessageIds = appendUnique(thread.lastMessageIds, input.messageId, 30);
|
|
609766
|
+
trimSocialState(state, now);
|
|
609767
|
+
}
|
|
609768
|
+
function commitTelegramSocialDecision(state, input) {
|
|
609769
|
+
const now = input.ts ?? Date.now();
|
|
609770
|
+
state.updatedAt = now;
|
|
609771
|
+
const senderKey3 = upsertParticipant(state, input.sender, now, false);
|
|
609772
|
+
const selfKey = input.self ? upsertParticipant(state, { ...input.self, isBot: true }, now, false) : void 0;
|
|
609773
|
+
const opportunities = registerDaydreamOpportunities(state, input.daydreamOpportunities ?? [], now);
|
|
609774
|
+
const opportunityIds = markDecisionOpportunities(opportunities, input.shouldReply, input.messageId, now);
|
|
609775
|
+
const outcome = {
|
|
609776
|
+
id: hashTelegramSocialId(["outcome", input.sessionKey, input.chatId, input.messageId ?? now, now, input.reason]),
|
|
609777
|
+
ts: now,
|
|
609778
|
+
chatId: String(input.chatId),
|
|
609779
|
+
messageId: input.messageId,
|
|
609780
|
+
messageThreadId: input.messageThreadId,
|
|
609781
|
+
senderKey: senderKey3,
|
|
609782
|
+
replyToMessageId: input.replyToMessageId,
|
|
609783
|
+
route: input.route,
|
|
609784
|
+
shouldReply: input.shouldReply,
|
|
609785
|
+
confidence: clamp019(input.confidence),
|
|
609786
|
+
reason: compact2(input.reason, 280),
|
|
609787
|
+
source: compact2(input.source, 80),
|
|
609788
|
+
silentDisposition: compactOptional(input.silentDisposition, 280),
|
|
609789
|
+
mentalNote: compactOptional(input.mentalNote, 360),
|
|
609790
|
+
memoryNote: compactOptional(input.memoryNote, 360),
|
|
609791
|
+
relationshipNote: compactOptional(input.relationshipNote, 360),
|
|
609792
|
+
salienceSignals: [...new Set((input.salienceSignals ?? []).map(String))].slice(0, 16),
|
|
609793
|
+
daydreamOpportunityIds: opportunityIds
|
|
609794
|
+
};
|
|
609795
|
+
state.outcomes.push(outcome);
|
|
609796
|
+
state.outcomes = state.outcomes.slice(-TELEGRAM_SOCIAL_LIMITS.outcomes);
|
|
609797
|
+
const thread = upsertThread(state, input, senderKey3, now, false);
|
|
609798
|
+
thread.lastOutcomeIds = appendUnique(thread.lastOutcomeIds, outcome.id, 30);
|
|
609799
|
+
commitDecisionEdges(state, input, senderKey3, selfKey, now);
|
|
609800
|
+
trimSocialState(state, now);
|
|
609801
|
+
return outcome;
|
|
609802
|
+
}
|
|
609803
|
+
function registerDaydreamOpportunities(state, opportunities, now = Date.now()) {
|
|
609804
|
+
const registered = [];
|
|
609805
|
+
for (const opportunity of opportunities) {
|
|
609806
|
+
const id = opportunity.id || hashTelegramSocialId(["daydream", opportunity.artifactId || "", opportunity.generatedAt || "", opportunity.trigger]);
|
|
609807
|
+
const existing = state.daydreamOpportunities[id];
|
|
609808
|
+
const item = existing ?? {
|
|
609809
|
+
id,
|
|
609810
|
+
artifactId: opportunity.artifactId || "unknown",
|
|
609811
|
+
generatedAt: opportunity.generatedAt || new Date(now).toISOString(),
|
|
609812
|
+
trigger: compact2(opportunity.trigger, 240),
|
|
609813
|
+
confidence: clamp019(opportunity.confidence),
|
|
609814
|
+
lifecycle: "proposed",
|
|
609815
|
+
firstSeenAt: now,
|
|
609816
|
+
updatedAt: now,
|
|
609817
|
+
consideredMessageIds: [],
|
|
609818
|
+
actedMessageIds: [],
|
|
609819
|
+
suppressedMessageIds: []
|
|
609820
|
+
};
|
|
609821
|
+
if (existing) {
|
|
609822
|
+
item.trigger = compact2(opportunity.trigger, 240) || item.trigger;
|
|
609823
|
+
item.confidence = clamp019(opportunity.confidence);
|
|
609824
|
+
item.updatedAt = now;
|
|
609825
|
+
}
|
|
609826
|
+
state.daydreamOpportunities[id] = item;
|
|
609827
|
+
registered.push(item);
|
|
609828
|
+
}
|
|
609829
|
+
retireStaleDaydreamOpportunities(state, now);
|
|
609830
|
+
return registered;
|
|
609831
|
+
}
|
|
609832
|
+
function markTelegramDaydreamOpportunitiesConsidered(state, opportunities, messageId, now = Date.now()) {
|
|
609833
|
+
const registered = registerDaydreamOpportunities(state, opportunities, now);
|
|
609834
|
+
for (const opportunity of registered) {
|
|
609835
|
+
if (opportunity.lifecycle === "proposed") opportunity.lifecycle = "considered";
|
|
609836
|
+
opportunity.updatedAt = now;
|
|
609837
|
+
opportunity.consideredMessageIds = appendUnique(opportunity.consideredMessageIds, messageId, 20);
|
|
609838
|
+
}
|
|
609839
|
+
return registered;
|
|
609840
|
+
}
|
|
609841
|
+
function commitDecisionEdges(state, input, senderKey3, selfKey, now) {
|
|
609842
|
+
if (!selfKey) return;
|
|
609843
|
+
if (input.shouldReply) {
|
|
609844
|
+
upsertRelationship(state, "addressed", selfKey, senderKey3, input.messageId, input.confidence, "router", input.reason, now);
|
|
609845
|
+
} else {
|
|
609846
|
+
upsertRelationship(state, "ignored", selfKey, senderKey3, input.messageId, input.confidence, "router", input.silentDisposition || input.reason, now);
|
|
609847
|
+
}
|
|
609848
|
+
if (input.relationshipNote) {
|
|
609849
|
+
upsertRelationship(state, "addressed", senderKey3, selfKey, input.messageId, Math.max(0.35, input.confidence), "router", input.relationshipNote, now);
|
|
609850
|
+
}
|
|
609851
|
+
}
|
|
609852
|
+
function markDecisionOpportunities(opportunities, shouldReply, messageId, now) {
|
|
609853
|
+
for (const opportunity of opportunities) {
|
|
609854
|
+
opportunity.lifecycle = shouldReply ? "acted" : "suppressed";
|
|
609855
|
+
opportunity.updatedAt = now;
|
|
609856
|
+
opportunity.consideredMessageIds = appendUnique(opportunity.consideredMessageIds, messageId, 20);
|
|
609857
|
+
if (shouldReply) {
|
|
609858
|
+
opportunity.actedMessageIds = appendUnique(opportunity.actedMessageIds, messageId, 20);
|
|
609859
|
+
} else {
|
|
609860
|
+
opportunity.suppressedMessageIds = appendUnique(opportunity.suppressedMessageIds, messageId, 20);
|
|
609861
|
+
}
|
|
609862
|
+
}
|
|
609863
|
+
return opportunities.map((item) => item.id);
|
|
609864
|
+
}
|
|
609865
|
+
function addMessageDerivedEdges(state, input, senderKey3, selfKey, text, now) {
|
|
609866
|
+
if (!selfKey) return;
|
|
609867
|
+
const signals = input.salienceSignals ?? [];
|
|
609868
|
+
const direct = signals.some((signal) => !signal.startsWith("private_dm_delivery"));
|
|
609869
|
+
if (direct) upsertRelationship(state, "addressed", senderKey3, selfKey, input.messageId, 0.78, "message", signals.join(", "), now);
|
|
609870
|
+
if (telegramSocialActorKind(input) === "bot" && direct) {
|
|
609871
|
+
upsertRelationship(state, "bot_to_bot_reference", senderKey3, selfKey, input.messageId, 0.7, "message", signals.join(", "), now);
|
|
609872
|
+
}
|
|
609873
|
+
if (/\b(deep dive|go deeper|more detail|be thorough|proper analysis|full breakdown|analyze this)\b/i.test(text)) {
|
|
609874
|
+
upsertRelationship(state, "asked_for_depth", senderKey3, selfKey, input.messageId, 0.68, "message", text, now);
|
|
609875
|
+
}
|
|
609876
|
+
if (/\b(don't reply|do not reply|listen only|stay silent|no response needed|just observe)\b/i.test(text)) {
|
|
609877
|
+
upsertRelationship(state, "asked_for_silence", senderKey3, selfKey, input.messageId, 0.72, "message", text, now);
|
|
609878
|
+
}
|
|
609879
|
+
if (/\b(yes|exactly|correct|good point|that works|agreed)\b/i.test(text)) {
|
|
609880
|
+
upsertRelationship(state, "affirmed", senderKey3, selfKey, input.messageId, 0.52, "message", text, now);
|
|
609881
|
+
}
|
|
609882
|
+
if (/\b(no,|wrong|incorrect|not what|missing|regression|failed|doesn't work|dont do that|don't do that)\b/i.test(text)) {
|
|
609883
|
+
upsertRelationship(state, "corrected", senderKey3, selfKey, input.messageId, 0.56, "message", text, now);
|
|
609884
|
+
}
|
|
609885
|
+
}
|
|
609886
|
+
function updatePreferencesFromText(state, actorKey, text, messageId, now, actorKind) {
|
|
609887
|
+
const vector = state.preferences[actorKey] ?? {};
|
|
609888
|
+
if (/\b(concise|short|brief|tl;dr|summarize)\b/i.test(text)) setPreference(vector, "verbosity", -0.55, 0.58, messageId, now, "prefers concise replies");
|
|
609889
|
+
if (/\b(verbose|long form|exhaustive|full breakdown|deep dive|proper analysis|thorough)\b/i.test(text)) setPreference(vector, "verbosity", 0.65, 0.62, messageId, now, "accepts longer detailed replies");
|
|
609890
|
+
if (/\b(deep dive|go deeper|analyze|reason through|proper analysis|full breakdown)\b/i.test(text)) setPreference(vector, "depth", 0.72, 0.68, messageId, now, "prefers deeper analysis");
|
|
609891
|
+
if (/\b(don't reply|do not reply|stay silent|listen only|just observe|silent reflection)\b/i.test(text)) setPreference(vector, "silence", 0.76, 0.7, messageId, now, "explicitly values silence/observation");
|
|
609892
|
+
if (/\b(direct|straight answer|no fluff|be clear|plainly)\b/i.test(text)) setPreference(vector, "directness", 0.68, 0.62, messageId, now, "prefers direct language");
|
|
609893
|
+
if (actorKind === "bot") setPreference(vector, "botToBotTolerance", 0.25, 0.4, messageId, now, "peer bot observed; keep bot-to-bot exchanges low-intrusion");
|
|
609894
|
+
state.preferences[actorKey] = vector;
|
|
609895
|
+
}
|
|
609896
|
+
function upsertParticipant(state, actor, now, countMessage) {
|
|
609897
|
+
const key = telegramSocialActorKey(actor);
|
|
609898
|
+
const username = cleanUsername(actor.username);
|
|
609899
|
+
const displayName = compactOptional(actor.firstName, 120);
|
|
609900
|
+
const node = state.participants[key] ?? {
|
|
609901
|
+
key,
|
|
609902
|
+
userId: actor.userId,
|
|
609903
|
+
username,
|
|
609904
|
+
displayName,
|
|
609905
|
+
actorKind: telegramSocialActorKind(actor),
|
|
609906
|
+
aliases: [],
|
|
609907
|
+
firstSeenAt: now,
|
|
609908
|
+
lastSeenAt: now,
|
|
609909
|
+
messageCount: 0,
|
|
609910
|
+
lastMessageIds: []
|
|
609911
|
+
};
|
|
609912
|
+
node.userId = actor.userId ?? node.userId;
|
|
609913
|
+
node.username = username || node.username;
|
|
609914
|
+
node.displayName = displayName || node.displayName;
|
|
609915
|
+
node.actorKind = actor.isSelf || actor.isBot ? "bot" : node.actorKind === "bot" ? "bot" : telegramSocialActorKind(actor);
|
|
609916
|
+
for (const alias of [username, displayName, actor.userId !== void 0 ? String(actor.userId) : ""].filter(Boolean)) {
|
|
609917
|
+
if (!node.aliases.includes(alias)) node.aliases.push(alias);
|
|
609918
|
+
}
|
|
609919
|
+
node.aliases = node.aliases.slice(0, 20);
|
|
609920
|
+
node.lastSeenAt = now;
|
|
609921
|
+
if (countMessage) node.messageCount += 1;
|
|
609922
|
+
state.participants[key] = node;
|
|
609923
|
+
return key;
|
|
609924
|
+
}
|
|
609925
|
+
function upsertThread(state, input, senderKey3, now, countMessage) {
|
|
609926
|
+
const key = telegramSocialThreadKey(input);
|
|
609927
|
+
const thread = state.threads[key] ?? {
|
|
609928
|
+
key,
|
|
609929
|
+
chatId: String(input.chatId),
|
|
609930
|
+
chatType: input.chatType,
|
|
609931
|
+
chatTitle: input.chatTitle,
|
|
609932
|
+
messageThreadId: input.messageThreadId,
|
|
609933
|
+
firstSeenAt: now,
|
|
609934
|
+
lastSeenAt: now,
|
|
609935
|
+
messageCount: 0,
|
|
609936
|
+
participantKeys: [],
|
|
609937
|
+
lastMessageIds: [],
|
|
609938
|
+
lastOutcomeIds: []
|
|
609939
|
+
};
|
|
609940
|
+
thread.chatType = input.chatType || thread.chatType;
|
|
609941
|
+
thread.chatTitle = input.chatTitle || thread.chatTitle;
|
|
609942
|
+
thread.lastSeenAt = now;
|
|
609943
|
+
if (countMessage) thread.messageCount += 1;
|
|
609944
|
+
thread.participantKeys = appendUnique(thread.participantKeys, senderKey3, 40);
|
|
609945
|
+
thread.lastMessageIds = appendUnique(thread.lastMessageIds, input.messageId, 40);
|
|
609946
|
+
state.threads[key] = thread;
|
|
609947
|
+
return thread;
|
|
609948
|
+
}
|
|
609949
|
+
function upsertRelationship(state, kind, fromKey, toKey, messageId, confidence2, source, note, now) {
|
|
609950
|
+
const id = hashTelegramSocialId(["edge", kind, fromKey, toKey]);
|
|
609951
|
+
const edge = state.relationships.find((item) => item.id === id) ?? {
|
|
609952
|
+
id,
|
|
609953
|
+
kind,
|
|
609954
|
+
fromKey,
|
|
609955
|
+
toKey,
|
|
609956
|
+
confidence: 0,
|
|
609957
|
+
weight: 0,
|
|
609958
|
+
firstSeenAt: now,
|
|
609959
|
+
lastSeenAt: now,
|
|
609960
|
+
evidenceMessageIds: [],
|
|
609961
|
+
source
|
|
609962
|
+
};
|
|
609963
|
+
edge.confidence = Math.max(edge.confidence, clamp019(confidence2));
|
|
609964
|
+
edge.weight = Math.min(1, edge.weight + 0.12 + clamp019(confidence2) * 0.2);
|
|
609965
|
+
edge.lastSeenAt = now;
|
|
609966
|
+
edge.evidenceMessageIds = appendUnique(edge.evidenceMessageIds, messageId, 40);
|
|
609967
|
+
edge.note = compactOptional(note, 260) || edge.note;
|
|
609968
|
+
edge.source = source;
|
|
609969
|
+
if (!state.relationships.some((item) => item.id === id)) state.relationships.push(edge);
|
|
609970
|
+
}
|
|
609971
|
+
function addSalience(state, input, senderKey3, now, text) {
|
|
609972
|
+
const signals = [...new Set((input.salienceSignals ?? []).map(String))].slice(0, 16);
|
|
609973
|
+
state.salience.push({
|
|
609974
|
+
id: hashTelegramSocialId(["salience", input.sessionKey, input.messageId ?? now, signals.join("|")]),
|
|
609975
|
+
ts: now,
|
|
609976
|
+
chatId: String(input.chatId),
|
|
609977
|
+
messageId: input.messageId,
|
|
609978
|
+
messageThreadId: input.messageThreadId,
|
|
609979
|
+
senderKey: senderKey3,
|
|
609980
|
+
actorKind: telegramSocialActorKind(input),
|
|
609981
|
+
signals,
|
|
609982
|
+
textPreview: compact2(text, 240)
|
|
609983
|
+
});
|
|
609984
|
+
state.salience = state.salience.slice(-TELEGRAM_SOCIAL_LIMITS.salience);
|
|
609985
|
+
}
|
|
609986
|
+
function retireStaleDaydreamOpportunities(state, now) {
|
|
609987
|
+
for (const item of Object.values(state.daydreamOpportunities)) {
|
|
609988
|
+
if (item.lifecycle === "retired" || now - item.updatedAt <= TELEGRAM_SOCIAL_LIMITS.daydreamStaleMs) continue;
|
|
609989
|
+
item.lifecycle = "retired";
|
|
609990
|
+
item.retiredAt = now;
|
|
609991
|
+
item.updatedAt = now;
|
|
609992
|
+
}
|
|
609993
|
+
const entries = Object.values(state.daydreamOpportunities).sort((a2, b) => b.updatedAt - a2.updatedAt);
|
|
609994
|
+
state.daydreamOpportunities = Object.fromEntries(entries.slice(0, TELEGRAM_SOCIAL_LIMITS.daydreamOpportunities).map((item) => [item.id, item]));
|
|
609995
|
+
}
|
|
609996
|
+
function trimSocialState(state, now) {
|
|
609997
|
+
state.relationships = state.relationships.sort((a2, b) => b.lastSeenAt - a2.lastSeenAt).slice(0, TELEGRAM_SOCIAL_LIMITS.relationships);
|
|
609998
|
+
state.salience = state.salience.slice(-TELEGRAM_SOCIAL_LIMITS.salience);
|
|
609999
|
+
state.outcomes = state.outcomes.slice(-TELEGRAM_SOCIAL_LIMITS.outcomes);
|
|
610000
|
+
retireStaleDaydreamOpportunities(state, now);
|
|
610001
|
+
}
|
|
610002
|
+
function setPreference(vector, key, value2, confidence2, messageId, now, note) {
|
|
610003
|
+
const existing = vector[key];
|
|
610004
|
+
vector[key] = {
|
|
610005
|
+
value: existing ? existing.value * 0.7 + value2 * 0.3 : value2,
|
|
610006
|
+
confidence: Math.max(existing?.confidence ?? 0, clamp019(confidence2)),
|
|
610007
|
+
updatedAt: now,
|
|
610008
|
+
evidenceMessageIds: appendUnique(existing?.evidenceMessageIds ?? [], messageId, 12),
|
|
610009
|
+
note
|
|
610010
|
+
};
|
|
610011
|
+
}
|
|
610012
|
+
function replyNote(input) {
|
|
610013
|
+
const target = input.replySender ? input.replySender.username || input.replySender.firstName || String(input.replySender.userId || "unknown") : `message ${input.replyToMessageId}`;
|
|
610014
|
+
return `reply relationship to ${target}`;
|
|
610015
|
+
}
|
|
610016
|
+
var init_telegram_social_state = __esm({
|
|
610017
|
+
"packages/cli/src/tui/telegram-social-state.ts"() {
|
|
610018
|
+
"use strict";
|
|
610019
|
+
init_telegram_social_state_types();
|
|
610020
|
+
init_telegram_social_state_types();
|
|
610021
|
+
init_telegram_social_state_context();
|
|
610022
|
+
init_telegram_social_state_normalize();
|
|
610023
|
+
}
|
|
610024
|
+
});
|
|
610025
|
+
|
|
609418
610026
|
// packages/cli/src/tui/vision-ingress.ts
|
|
609419
610027
|
var vision_ingress_exports = {};
|
|
609420
610028
|
__export(vision_ingress_exports, {
|
|
@@ -609573,7 +610181,7 @@ import { mkdirSync as mkdirSync65, existsSync as existsSync113, unlinkSync as un
|
|
|
609573
610181
|
import { join as join127, resolve as resolve43, basename as basename27, relative as relative13, isAbsolute as isAbsolute8, extname as extname16 } from "node:path";
|
|
609574
610182
|
import { homedir as homedir40 } from "node:os";
|
|
609575
610183
|
import { writeFile as writeFileAsync } from "node:fs/promises";
|
|
609576
|
-
import { createHash as
|
|
610184
|
+
import { createHash as createHash24, randomBytes as randomBytes22, randomInt } from "node:crypto";
|
|
609577
610185
|
function cleanTelegramDecisionNote(value2, maxLength = 260) {
|
|
609578
610186
|
if (typeof value2 !== "string") return void 0;
|
|
609579
610187
|
const clean5 = stripTelegramHiddenThinking(value2).replace(/\s+/g, " ").trim();
|
|
@@ -609843,8 +610451,8 @@ function stripTelegramHiddenThinking(text) {
|
|
|
609843
610451
|
return withoutClosedThink.replace(/<think>[\s\S]*$/gi, "");
|
|
609844
610452
|
}
|
|
609845
610453
|
function sanitizeTelegramProgressText(text, maxLength) {
|
|
609846
|
-
const
|
|
609847
|
-
return
|
|
610454
|
+
const compact3 = stripTelegramHiddenThinking(text).replace(/\s+/g, " ").trim();
|
|
610455
|
+
return compact3.length > maxLength ? compact3.slice(0, Math.max(0, maxLength - 3)) + "..." : compact3;
|
|
609848
610456
|
}
|
|
609849
610457
|
function isCodebaseMemoryStatus(text) {
|
|
609850
610458
|
return /^\s*\[CODEBASE MEMORY\]/i.test(stripTelegramHiddenThinking(text));
|
|
@@ -609886,26 +610494,26 @@ function isTelegramNoReplySentinel(text) {
|
|
|
609886
610494
|
return lower === "no_reply" || lower.startsWith("no_reply");
|
|
609887
610495
|
}
|
|
609888
610496
|
function isTelegramInternalStatusText(text) {
|
|
609889
|
-
const
|
|
609890
|
-
if (!
|
|
609891
|
-
const lower =
|
|
609892
|
-
if (isTelegramNoReplySentinel(
|
|
610497
|
+
const compact3 = compactTelegramVisibleText(text);
|
|
610498
|
+
if (!compact3) return false;
|
|
610499
|
+
const lower = compact3.toLowerCase();
|
|
610500
|
+
if (isTelegramNoReplySentinel(compact3)) return true;
|
|
609893
610501
|
if (lower === "complete" || lower === "completed") return true;
|
|
609894
|
-
if (/^memory stage:/i.test(
|
|
609895
|
-
if (/^\[ppr[-_\s]?skip\]/i.test(
|
|
609896
|
-
if (/^(casual|ambient|group)\b.{0,180}\b(skipping|skipped|not directed|no action needed|no reply)\b/i.test(
|
|
609897
|
-
if (/^no further action needed\b/i.test(
|
|
609898
|
-
if (/^no action needed\b.{0,120}\b(task|complete|completed|done)\b/i.test(
|
|
609899
|
-
if (/^(there'?s|there is) no active task\b/i.test(
|
|
609900
|
-
if (/^everything'?s (done|complete|completed|wrapped up)\b/i.test(
|
|
609901
|
-
if (/\balready (been )?(provided|answered|handled|delivered) above\b/i.test(
|
|
609902
|
-
if (/\b(no remaining work|nothing left to do|task is complete|task has been completed)\b/i.test(
|
|
610502
|
+
if (/^memory stage:/i.test(compact3)) return true;
|
|
610503
|
+
if (/^\[ppr[-_\s]?skip\]/i.test(compact3)) return true;
|
|
610504
|
+
if (/^(casual|ambient|group)\b.{0,180}\b(skipping|skipped|not directed|no action needed|no reply)\b/i.test(compact3)) return true;
|
|
610505
|
+
if (/^no further action needed\b/i.test(compact3)) return true;
|
|
610506
|
+
if (/^no action needed\b.{0,120}\b(task|complete|completed|done)\b/i.test(compact3)) return true;
|
|
610507
|
+
if (/^(there'?s|there is) no active task\b/i.test(compact3)) return true;
|
|
610508
|
+
if (/^everything'?s (done|complete|completed|wrapped up)\b/i.test(compact3)) return true;
|
|
610509
|
+
if (/\balready (been )?(provided|answered|handled|delivered) above\b/i.test(compact3)) return true;
|
|
610510
|
+
if (/\b(no remaining work|nothing left to do|task is complete|task has been completed)\b/i.test(compact3)) return true;
|
|
609903
610511
|
return false;
|
|
609904
610512
|
}
|
|
609905
610513
|
function isTelegramStuckSelfTalkSegment(text) {
|
|
609906
|
-
const
|
|
609907
|
-
if (!
|
|
609908
|
-
return TELEGRAM_STUCK_SELF_TALK_PREFIXES.some((re) => re.test(
|
|
610514
|
+
const compact3 = text.trim();
|
|
610515
|
+
if (!compact3) return false;
|
|
610516
|
+
return TELEGRAM_STUCK_SELF_TALK_PREFIXES.some((re) => re.test(compact3));
|
|
609909
610517
|
}
|
|
609910
610518
|
function stripTelegramStuckSelfTalk(text) {
|
|
609911
610519
|
if (!text) return "";
|
|
@@ -609973,9 +610581,9 @@ function truncateTelegramContext(text, maxLength) {
|
|
|
609973
610581
|
[Telegram context truncated; use tools for full detail.]`;
|
|
609974
610582
|
}
|
|
609975
610583
|
function truncateTelegramContextLine(text, maxLength = TELEGRAM_CONTEXT_LINE_LIMIT) {
|
|
609976
|
-
const
|
|
609977
|
-
if (
|
|
609978
|
-
return `${
|
|
610584
|
+
const compact3 = stripTelegramHiddenThinking(text).replace(/\s+/g, " ").trim();
|
|
610585
|
+
if (compact3.length <= maxLength) return compact3;
|
|
610586
|
+
return `${compact3.slice(0, Math.max(0, maxLength - 3)).trimEnd()}...`;
|
|
609979
610587
|
}
|
|
609980
610588
|
function telegramRegexEscape(text) {
|
|
609981
610589
|
return text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -610185,7 +610793,7 @@ function buildTelegramRuntimeContext(now = /* @__PURE__ */ new Date(), repoRoot)
|
|
|
610185
610793
|
].filter(Boolean).join("\n");
|
|
610186
610794
|
}
|
|
610187
610795
|
function telegramSessionIdFromKey(sessionKey) {
|
|
610188
|
-
return `telegram-${
|
|
610796
|
+
return `telegram-${createHash24("sha1").update(sessionKey).digest("hex").slice(0, 16)}`;
|
|
610189
610797
|
}
|
|
610190
610798
|
function selectTelegramFinalResponse(args) {
|
|
610191
610799
|
const committedVisibleReply = cleanTelegramVisibleReply(args.visibleReplyText || "");
|
|
@@ -611012,6 +611620,7 @@ var init_telegram_bridge = __esm({
|
|
|
611012
611620
|
init_telegram_reflection_corpus();
|
|
611013
611621
|
init_memory_paths();
|
|
611014
611622
|
init_telegram_reflection_extraction();
|
|
611623
|
+
init_telegram_social_state();
|
|
611015
611624
|
init_dist7();
|
|
611016
611625
|
TELEGRAM_TOOL_ACTION_GROUPS = [
|
|
611017
611626
|
"read",
|
|
@@ -611433,6 +612042,8 @@ External acquisition contract:
|
|
|
611433
612042
|
chatMemoryCards = /* @__PURE__ */ new Map();
|
|
611434
612043
|
/** Durable associative memory by scoped Telegram chat key. */
|
|
611435
612044
|
chatAssociativeMemory = /* @__PURE__ */ new Map();
|
|
612045
|
+
/** Durable social cognition state by scoped Telegram chat key. */
|
|
612046
|
+
chatSocialState = /* @__PURE__ */ new Map();
|
|
611436
612047
|
/** Generic chronological attention cadence shared by live surfaces. */
|
|
611437
612048
|
stimulation = new StimulationController();
|
|
611438
612049
|
/** Throttles noisy "skipped group chatter" waterfall logs */
|
|
@@ -611634,7 +612245,7 @@ External acquisition contract:
|
|
|
611634
612245
|
return !!this.adminAuthChallenge && this.adminAuthChallenge.expiresAtMs > Date.now();
|
|
611635
612246
|
}
|
|
611636
612247
|
hashAdminAuthCode(code8) {
|
|
611637
|
-
return
|
|
612248
|
+
return createHash24("sha256").update(`omnius-telegram-admin:${code8.trim()}`).digest("hex");
|
|
611638
612249
|
}
|
|
611639
612250
|
viewIdForMessage(msg) {
|
|
611640
612251
|
return `telegram-${this.sessionKeyForMessage(msg).replace(/[^A-Za-z0-9_-]/g, "-")}`;
|
|
@@ -612110,11 +612721,11 @@ ${mediaContext}` : ""
|
|
|
612110
612721
|
return payload;
|
|
612111
612722
|
}
|
|
612112
612723
|
telegramConversationPath(sessionKey) {
|
|
612113
|
-
const safe =
|
|
612724
|
+
const safe = createHash24("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
612114
612725
|
return join127(this.telegramConversationDir, `${safe}.json`);
|
|
612115
612726
|
}
|
|
612116
612727
|
telegramConversationLedgerPath(sessionKey) {
|
|
612117
|
-
const safe =
|
|
612728
|
+
const safe = createHash24("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
612118
612729
|
return join127(this.telegramConversationDir, `${safe}.events.jsonl`);
|
|
612119
612730
|
}
|
|
612120
612731
|
telegramDb() {
|
|
@@ -612342,7 +612953,7 @@ ${mediaContext}` : ""
|
|
|
612342
612953
|
users,
|
|
612343
612954
|
relationships: Array.isArray(raw.relationships) ? raw.relationships.slice(0, TELEGRAM_ASSOCIATIVE_RELATION_LIMIT).map((fact) => this.normalizeTelegramAssociativeFact(fact)) : [],
|
|
612344
612955
|
actions: Array.isArray(raw.actions) ? raw.actions.slice(-TELEGRAM_ASSOCIATIVE_ACTION_LIMIT).map((action) => ({
|
|
612345
|
-
id: String(action.id ||
|
|
612956
|
+
id: String(action.id || createHash24("sha1").update(JSON.stringify(action)).digest("hex").slice(0, 12)),
|
|
612346
612957
|
ts: typeof action.ts === "number" ? action.ts : Date.now(),
|
|
612347
612958
|
role: action.role === "assistant" ? "assistant" : "user",
|
|
612348
612959
|
speaker: String(action.speaker || "unknown"),
|
|
@@ -612359,7 +612970,7 @@ ${mediaContext}` : ""
|
|
|
612359
612970
|
const text = String(raw.text || "").trim();
|
|
612360
612971
|
const now = Date.now();
|
|
612361
612972
|
return {
|
|
612362
|
-
id: String(raw.id ||
|
|
612973
|
+
id: String(raw.id || createHash24("sha1").update(text || String(now)).digest("hex").slice(0, 12)),
|
|
612363
612974
|
text,
|
|
612364
612975
|
tags: Array.isArray(raw.tags) ? raw.tags.map(String).slice(0, 16) : [],
|
|
612365
612976
|
speakers: Array.isArray(raw.speakers) ? raw.speakers.map(String).slice(0, 16) : [],
|
|
@@ -612380,6 +612991,98 @@ ${mediaContext}` : ""
|
|
|
612380
612991
|
}
|
|
612381
612992
|
return memory;
|
|
612382
612993
|
}
|
|
612994
|
+
telegramSocialStateForSession(sessionKey) {
|
|
612995
|
+
this.ensureTelegramConversationLoaded(sessionKey);
|
|
612996
|
+
let state = this.chatSocialState.get(sessionKey);
|
|
612997
|
+
if (!state) {
|
|
612998
|
+
state = createTelegramSocialState();
|
|
612999
|
+
this.chatSocialState.set(sessionKey, state);
|
|
613000
|
+
}
|
|
613001
|
+
return state;
|
|
613002
|
+
}
|
|
613003
|
+
telegramSelfSocialActorInput() {
|
|
613004
|
+
return {
|
|
613005
|
+
userId: this.currentTelegramBotUserId(),
|
|
613006
|
+
username: this.state.botUsername || void 0,
|
|
613007
|
+
firstName: this.state.botFirstName || "Omnius",
|
|
613008
|
+
isBot: true,
|
|
613009
|
+
isSelf: true
|
|
613010
|
+
};
|
|
613011
|
+
}
|
|
613012
|
+
telegramMessageSocialActorInput(msg) {
|
|
613013
|
+
return {
|
|
613014
|
+
userId: msg.fromUserId,
|
|
613015
|
+
username: msg.username,
|
|
613016
|
+
firstName: msg.firstName,
|
|
613017
|
+
isBot: Boolean(msg.isBot)
|
|
613018
|
+
};
|
|
613019
|
+
}
|
|
613020
|
+
telegramReplySocialActorInput(msg) {
|
|
613021
|
+
const sender = msg.replyContext?.sender;
|
|
613022
|
+
if (sender) {
|
|
613023
|
+
return {
|
|
613024
|
+
userId: sender.id,
|
|
613025
|
+
username: sender.username,
|
|
613026
|
+
firstName: sender.firstName || sender.title,
|
|
613027
|
+
isBot: Boolean(sender.isBot || sender.isSelf),
|
|
613028
|
+
isSelf: Boolean(sender.isSelf)
|
|
613029
|
+
};
|
|
613030
|
+
}
|
|
613031
|
+
if (!msg.replyToUsername) return void 0;
|
|
613032
|
+
return {
|
|
613033
|
+
username: msg.replyToUsername,
|
|
613034
|
+
isBot: Boolean(msg.replyToBot)
|
|
613035
|
+
};
|
|
613036
|
+
}
|
|
613037
|
+
observeTelegramSocialMessage(sessionKey, msg, text, salienceSignals) {
|
|
613038
|
+
try {
|
|
613039
|
+
observeTelegramSocialMessage(this.telegramSocialStateForSession(sessionKey), {
|
|
613040
|
+
sessionKey,
|
|
613041
|
+
chatId: msg.chatId,
|
|
613042
|
+
chatType: msg.chatType,
|
|
613043
|
+
chatTitle: msg.chatTitle,
|
|
613044
|
+
text,
|
|
613045
|
+
messageId: msg.messageId,
|
|
613046
|
+
messageThreadId: msg.messageThreadId,
|
|
613047
|
+
replyToMessageId: msg.replyToMessageId,
|
|
613048
|
+
replySender: this.telegramReplySocialActorInput(msg),
|
|
613049
|
+
salienceSignals: salienceSignals ?? this.telegramMessageIdentitySalienceSignals(msg),
|
|
613050
|
+
self: this.telegramSelfSocialActorInput(),
|
|
613051
|
+
...this.telegramMessageSocialActorInput(msg)
|
|
613052
|
+
});
|
|
613053
|
+
} catch {
|
|
613054
|
+
}
|
|
613055
|
+
}
|
|
613056
|
+
hydrateTelegramSocialStateFromHistory(sessionKey, history) {
|
|
613057
|
+
const state = createTelegramSocialState();
|
|
613058
|
+
this.chatSocialState.set(sessionKey, state);
|
|
613059
|
+
for (const entry of history) {
|
|
613060
|
+
if (entry.role !== "user") continue;
|
|
613061
|
+
observeTelegramSocialMessage(state, {
|
|
613062
|
+
sessionKey,
|
|
613063
|
+
chatId: entry.chatId ?? sessionKey.replace(/^chat:/, ""),
|
|
613064
|
+
chatType: entry.chatType,
|
|
613065
|
+
chatTitle: entry.chatTitle,
|
|
613066
|
+
text: entry.text,
|
|
613067
|
+
messageId: entry.messageId,
|
|
613068
|
+
messageThreadId: entry.messageThreadId,
|
|
613069
|
+
replyToMessageId: entry.replyToMessageId,
|
|
613070
|
+
replySender: entry.replyContext?.sender ? {
|
|
613071
|
+
userId: entry.replyContext.sender.id,
|
|
613072
|
+
username: entry.replyContext.sender.username,
|
|
613073
|
+
firstName: entry.replyContext.sender.firstName || entry.replyContext.sender.title,
|
|
613074
|
+
isBot: Boolean(entry.replyContext.sender.isBot || entry.replyContext.sender.isSelf),
|
|
613075
|
+
isSelf: Boolean(entry.replyContext.sender.isSelf)
|
|
613076
|
+
} : void 0,
|
|
613077
|
+
self: this.telegramSelfSocialActorInput(),
|
|
613078
|
+
userId: entry.fromUserId,
|
|
613079
|
+
username: entry.username,
|
|
613080
|
+
firstName: entry.firstName,
|
|
613081
|
+
isBot: Boolean(entry.isBot),
|
|
613082
|
+
ts: entry.ts
|
|
613083
|
+
});
|
|
613084
|
+
}
|
|
613085
|
+
}
|
|
612383
613086
|
telegramPersonalityScope(sessionKey, msg) {
|
|
612384
613087
|
const label = msg.chatType !== "private" ? `${msg.chatTitle || msg.chatType}-${String(msg.chatId)}` : `private-${msg.username || msg.fromUserId || msg.chatId}`;
|
|
612385
613088
|
return {
|
|
@@ -612439,6 +613142,11 @@ ${mediaContext}` : ""
|
|
|
612439
613142
|
} else if (loadedHistory.length > 0) {
|
|
612440
613143
|
this.hydrateTelegramAssociativeMemoryFromHistory(sessionKey, loadedHistory);
|
|
612441
613144
|
}
|
|
613145
|
+
if (parsed.socialState) {
|
|
613146
|
+
this.chatSocialState.set(sessionKey, normalizeTelegramSocialState(parsed.socialState));
|
|
613147
|
+
} else if (loadedHistory.length > 0) {
|
|
613148
|
+
this.hydrateTelegramSocialStateFromHistory(sessionKey, loadedHistory);
|
|
613149
|
+
}
|
|
612442
613150
|
if (loadedHistory.length > 0) {
|
|
612443
613151
|
this.backfillTelegramLoadedHistory(sessionKey, loadedHistory);
|
|
612444
613152
|
}
|
|
@@ -612464,7 +613172,7 @@ ${mediaContext}` : ""
|
|
|
612464
613172
|
}
|
|
612465
613173
|
telegramHistoryBackfillMessageId(sessionKey, entry, index) {
|
|
612466
613174
|
if (typeof entry.messageId === "number" && Number.isFinite(entry.messageId)) return entry.messageId;
|
|
612467
|
-
const digest3 =
|
|
613175
|
+
const digest3 = createHash24("sha1").update(`${sessionKey}:${index}:${entry.role}:${entry.ts ?? ""}:${entry.text}`).digest("hex").slice(0, 8);
|
|
612468
613176
|
return -Number.parseInt(digest3, 16);
|
|
612469
613177
|
}
|
|
612470
613178
|
backfillTelegramLoadedHistory(sessionKey, history) {
|
|
@@ -612611,6 +613319,7 @@ ${mediaContext}` : ""
|
|
|
612611
613319
|
participants,
|
|
612612
613320
|
memoryCards: this.chatMemoryCards.get(sessionKey) ?? [],
|
|
612613
613321
|
associativeMemory: this.telegramAssociativeMemoryForSession(sessionKey),
|
|
613322
|
+
socialState: this.telegramSocialStateForSession(sessionKey),
|
|
612614
613323
|
stimulation: this.stimulation.getState(sessionKey),
|
|
612615
613324
|
reflection: this.channelReflectionState.get(sessionKey) ?? { autoFollowup: false }
|
|
612616
613325
|
};
|
|
@@ -612883,6 +613592,7 @@ ${mediaContext}` : ""
|
|
|
612883
613592
|
}
|
|
612884
613593
|
}
|
|
612885
613594
|
formatLatestTelegramChannelDaydreamContext(sessionKey) {
|
|
613595
|
+
this.registerLatestTelegramDaydreamOpportunities(sessionKey);
|
|
612886
613596
|
return formatTelegramChannelDaydreamContext(this.latestTelegramChannelDaydream(sessionKey));
|
|
612887
613597
|
}
|
|
612888
613598
|
shouldForceAnalysisFromChannelDaydream(sessionKey) {
|
|
@@ -612896,6 +613606,81 @@ ${mediaContext}` : ""
|
|
|
612896
613606
|
this.channelDmnPromptedArtifactAt.set(sessionKey, artifact.generatedAt);
|
|
612897
613607
|
return true;
|
|
612898
613608
|
}
|
|
613609
|
+
latestTelegramDaydreamOpportunityInputs(sessionKey) {
|
|
613610
|
+
const artifact = this.latestTelegramChannelDaydream(sessionKey);
|
|
613611
|
+
if (!artifact || artifact.replyOpportunities.length === 0) return [];
|
|
613612
|
+
return artifact.replyOpportunities.map((opportunity) => ({
|
|
613613
|
+
id: opportunity.id,
|
|
613614
|
+
trigger: opportunity.trigger,
|
|
613615
|
+
confidence: opportunity.confidence,
|
|
613616
|
+
artifactId: artifact.id,
|
|
613617
|
+
generatedAt: artifact.generatedAt
|
|
613618
|
+
}));
|
|
613619
|
+
}
|
|
613620
|
+
registerLatestTelegramDaydreamOpportunities(sessionKey) {
|
|
613621
|
+
const opportunities = this.latestTelegramDaydreamOpportunityInputs(sessionKey);
|
|
613622
|
+
if (opportunities.length === 0) return;
|
|
613623
|
+
try {
|
|
613624
|
+
registerDaydreamOpportunities(this.telegramSocialStateForSession(sessionKey), opportunities);
|
|
613625
|
+
} catch {
|
|
613626
|
+
}
|
|
613627
|
+
}
|
|
613628
|
+
markLatestTelegramDaydreamOpportunitiesConsidered(sessionKey, msg) {
|
|
613629
|
+
const opportunities = this.latestTelegramDaydreamOpportunityInputs(sessionKey);
|
|
613630
|
+
if (opportunities.length === 0) return [];
|
|
613631
|
+
try {
|
|
613632
|
+
markTelegramDaydreamOpportunitiesConsidered(this.telegramSocialStateForSession(sessionKey), opportunities, msg.messageId);
|
|
613633
|
+
} catch {
|
|
613634
|
+
}
|
|
613635
|
+
return opportunities;
|
|
613636
|
+
}
|
|
613637
|
+
commitTelegramSocialDecision(sessionKey, msg, decision, salienceSignals, daydreamOpportunities = this.latestTelegramDaydreamOpportunityInputs(sessionKey)) {
|
|
613638
|
+
try {
|
|
613639
|
+
commitTelegramSocialDecision(this.telegramSocialStateForSession(sessionKey), {
|
|
613640
|
+
sessionKey,
|
|
613641
|
+
chatId: msg.chatId,
|
|
613642
|
+
messageId: msg.messageId,
|
|
613643
|
+
messageThreadId: msg.messageThreadId,
|
|
613644
|
+
sender: this.telegramMessageSocialActorInput(msg),
|
|
613645
|
+
replyToMessageId: msg.replyToMessageId,
|
|
613646
|
+
route: decision.route,
|
|
613647
|
+
shouldReply: decision.shouldReply,
|
|
613648
|
+
confidence: decision.confidence,
|
|
613649
|
+
reason: decision.reason,
|
|
613650
|
+
source: decision.source,
|
|
613651
|
+
silentDisposition: decision.silentDisposition,
|
|
613652
|
+
mentalNote: decision.mentalNote,
|
|
613653
|
+
memoryNote: decision.memoryNote,
|
|
613654
|
+
relationshipNote: decision.relationshipNote,
|
|
613655
|
+
salienceSignals,
|
|
613656
|
+
self: this.telegramSelfSocialActorInput(),
|
|
613657
|
+
daydreamOpportunities
|
|
613658
|
+
});
|
|
613659
|
+
this.saveTelegramConversationState(sessionKey);
|
|
613660
|
+
} catch {
|
|
613661
|
+
}
|
|
613662
|
+
}
|
|
613663
|
+
buildTelegramSocialStateContext(sessionKey, msg, salienceSignals = []) {
|
|
613664
|
+
try {
|
|
613665
|
+
this.registerLatestTelegramDaydreamOpportunities(sessionKey);
|
|
613666
|
+
return formatTelegramSocialStateContext(this.telegramSocialStateForSession(sessionKey), {
|
|
613667
|
+
sessionKey,
|
|
613668
|
+
chatId: msg.chatId,
|
|
613669
|
+
chatType: msg.chatType,
|
|
613670
|
+
chatTitle: msg.chatTitle,
|
|
613671
|
+
text: msg.text,
|
|
613672
|
+
messageId: msg.messageId,
|
|
613673
|
+
messageThreadId: msg.messageThreadId,
|
|
613674
|
+
replyToMessageId: msg.replyToMessageId,
|
|
613675
|
+
replySender: this.telegramReplySocialActorInput(msg),
|
|
613676
|
+
salienceSignals,
|
|
613677
|
+
self: this.telegramSelfSocialActorInput(),
|
|
613678
|
+
...this.telegramMessageSocialActorInput(msg)
|
|
613679
|
+
});
|
|
613680
|
+
} catch {
|
|
613681
|
+
return "";
|
|
613682
|
+
}
|
|
613683
|
+
}
|
|
612899
613684
|
renderTelegramScopedPersonality(sessionKey, msg) {
|
|
612900
613685
|
try {
|
|
612901
613686
|
return buildScopedPersonalityContext(this.telegramPersonalityScope(sessionKey, msg));
|
|
@@ -612971,6 +613756,7 @@ ${mediaContext}` : ""
|
|
|
612971
613756
|
this.updateTelegramParticipantProfile(sessionKey, msg, text);
|
|
612972
613757
|
this.updateTelegramMemoryCards(sessionKey, entry);
|
|
612973
613758
|
this.updateTelegramAssociativeMemory(sessionKey, entry);
|
|
613759
|
+
this.observeTelegramSocialMessage(sessionKey, msg, text);
|
|
612974
613760
|
try {
|
|
612975
613761
|
updateScopedPersonality(this.telegramPersonalityScope(sessionKey, msg), {
|
|
612976
613762
|
speaker: telegramSpeakerLabel(msg),
|
|
@@ -613212,7 +613998,7 @@ ${mediaContext}` : ""
|
|
|
613212
613998
|
const now = entry.ts ?? Date.now();
|
|
613213
613999
|
memory.updatedAt = now;
|
|
613214
614000
|
const speaker = telegramHistorySpeaker(entry);
|
|
613215
|
-
const actionId =
|
|
614001
|
+
const actionId = createHash24("sha1").update(`${sessionKey}:${entry.role}:${entry.messageId ?? ""}:${now}:${entry.text}`).digest("hex").slice(0, 16);
|
|
613216
614002
|
if (!memory.actions.some((action) => action.id === actionId)) {
|
|
613217
614003
|
memory.actions.push({
|
|
613218
614004
|
id: actionId,
|
|
@@ -613273,9 +614059,9 @@ ${mediaContext}` : ""
|
|
|
613273
614059
|
if (!userMemory.toneTags.includes(tag)) userMemory.toneTags.push(tag);
|
|
613274
614060
|
}
|
|
613275
614061
|
userMemory.toneTags = userMemory.toneTags.slice(0, 20);
|
|
613276
|
-
const
|
|
613277
|
-
if (
|
|
613278
|
-
userMemory.lastMessages.push(
|
|
614062
|
+
const compact3 = stripTelegramHiddenThinking(entry.text || "").replace(/\s+/g, " ").trim();
|
|
614063
|
+
if (compact3) {
|
|
614064
|
+
userMemory.lastMessages.push(compact3);
|
|
613279
614065
|
userMemory.lastMessages = userMemory.lastMessages.slice(-40);
|
|
613280
614066
|
}
|
|
613281
614067
|
for (const topic of telegramMemoryTags(entry.text, entry.mediaSummary).slice(0, 6)) {
|
|
@@ -613334,7 +614120,7 @@ ${mediaContext}` : ""
|
|
|
613334
614120
|
let fact = facts.find((item) => item.text.toLowerCase() === key);
|
|
613335
614121
|
if (!fact) {
|
|
613336
614122
|
fact = {
|
|
613337
|
-
id:
|
|
614123
|
+
id: createHash24("sha1").update(`${entry.chatId ?? ""}:${key}`).digest("hex").slice(0, 12),
|
|
613338
614124
|
text: clean5,
|
|
613339
614125
|
tags: telegramMemoryTags(clean5, entry.mediaSummary),
|
|
613340
614126
|
speakers: [],
|
|
@@ -613389,7 +614175,7 @@ ${mediaContext}` : ""
|
|
|
613389
614175
|
const titleTags = tags.slice(0, 4);
|
|
613390
614176
|
const title = titleTags.length > 0 ? `${speaker} / ${titleTags.join(" ")}` : `${speaker} / conversation`;
|
|
613391
614177
|
const card = {
|
|
613392
|
-
id:
|
|
614178
|
+
id: createHash24("sha1").update(`${sessionKey}:${now}:${speaker}:${text}`).digest("hex").slice(0, 12),
|
|
613393
614179
|
title,
|
|
613394
614180
|
notes: [],
|
|
613395
614181
|
tags: [],
|
|
@@ -614165,7 +614951,7 @@ ${lines.join("\n")}`);
|
|
|
614165
614951
|
lines.push(" 5. memory_search accepts NATURAL-LANGUAGE TIME phrases inside the `query` argument or explicit `since`/`until`/`bucket` args. Examples: query='what did manitcor say yesterday', query='last 3 hours', query='earlier today', query='2 days ago', query='since 2026-05-15', query='between 2026-05-15 and 2026-05-16', query='oldest memory about github', query='most recent flux discussion'. Use these for chronological/'how far back' style queries instead of guessing — the tool parses the phrase, filters by time, and returns the right window.");
|
|
614166
614952
|
return lines.join("\n");
|
|
614167
614953
|
}
|
|
614168
|
-
buildTelegramConversationContextStream(sessionKey, msg, maxRecent = TELEGRAM_CONTEXT_RECENT_DEFAULT) {
|
|
614954
|
+
buildTelegramConversationContextStream(sessionKey, msg, maxRecent = TELEGRAM_CONTEXT_RECENT_DEFAULT, salienceSignals = []) {
|
|
614169
614955
|
this.ensureTelegramConversationLoaded(sessionKey);
|
|
614170
614956
|
const history = this.chatHistory.get(sessionKey) ?? [];
|
|
614171
614957
|
const participants = [...this.chatParticipants.get(sessionKey)?.values() ?? []].sort((a2, b) => b.lastSeenTs - a2.lastSeenTs);
|
|
@@ -614197,6 +614983,10 @@ ${lines.join("\n")}`);
|
|
|
614197
614983
|
if (scopedPersonality) {
|
|
614198
614984
|
sections.push(scopedPersonality);
|
|
614199
614985
|
}
|
|
614986
|
+
const socialStateContext = this.buildTelegramSocialStateContext(sessionKey, msg, salienceSignals);
|
|
614987
|
+
if (socialStateContext) {
|
|
614988
|
+
sections.push(socialStateContext);
|
|
614989
|
+
}
|
|
614200
614990
|
if (participants.length > 0) {
|
|
614201
614991
|
const participantLines = participants.slice(0, 12).map((profile) => {
|
|
614202
614992
|
const label = profile.username && profile.username !== "unknown" ? `@${profile.username}` : profile.firstName || `user:${profile.fromUserId}`;
|
|
@@ -614417,7 +615207,7 @@ ${lines.join("\n")}`);
|
|
|
614417
615207
|
config.apiKey
|
|
614418
615208
|
);
|
|
614419
615209
|
const forcedLine = forcedRoute ? `The operator selected Telegram mode "${forcedRoute}". The route field MUST be "${forcedRoute}", but should_reply must still be inferred live from context.` : `The operator selected Telegram mode "auto". Infer route live from context.`;
|
|
614420
|
-
const context2 = this.buildTelegramConversationContextStream(sessionKey, msg, isGroup ? 36 : 20);
|
|
615210
|
+
const context2 = this.buildTelegramConversationContextStream(sessionKey, msg, isGroup ? 36 : 20, identitySalienceSignals);
|
|
614421
615211
|
const currentReplyContext = this.buildTelegramCurrentReplyContext(sessionKey, msg);
|
|
614422
615212
|
const selfIdentityContext = this.buildTelegramSelfIdentityContext();
|
|
614423
615213
|
const userPrompt = [
|
|
@@ -614627,7 +615417,7 @@ ${list}` : "No shared group target is currently known for this sender. Ask in th
|
|
|
614627
615417
|
}
|
|
614628
615418
|
telegramRunnerStateDir(sessionKey) {
|
|
614629
615419
|
if (!this.repoRoot) return void 0;
|
|
614630
|
-
const safe =
|
|
615420
|
+
const safe = createHash24("sha1").update(sessionKey).digest("hex").slice(0, 20);
|
|
614631
615421
|
return join127(this.repoRoot, ".omnius", "telegram-runner-state", safe);
|
|
614632
615422
|
}
|
|
614633
615423
|
buildTelegramAdminOverviewContext(currentSessionKey) {
|
|
@@ -615222,6 +616012,13 @@ Join: ${newUrl}`);
|
|
|
615222
616012
|
const attentionViewId2 = this.registerTelegramAttentionView(msg, existing.toolContext || toolContext, "active Telegram thread");
|
|
615223
616013
|
const decision2 = await this.inferTelegramInteractionDecision(msg, existing.toolContext || toolContext);
|
|
615224
616014
|
this.writeTelegramAttentionDecision(attentionViewId2, decision2);
|
|
616015
|
+
this.commitTelegramSocialDecision(
|
|
616016
|
+
sessionKey,
|
|
616017
|
+
msg,
|
|
616018
|
+
decision2,
|
|
616019
|
+
this.telegramMessageIdentitySalienceSignals(msg),
|
|
616020
|
+
this.markLatestTelegramDaydreamOpportunitiesConsidered(sessionKey, msg)
|
|
616021
|
+
);
|
|
615225
616022
|
this.markLastTelegramUserMessageMode(msg, decision2.shouldReply ? "steering" : "ambient");
|
|
615226
616023
|
this.subAgentViewCallbacks?.onWrite(
|
|
615227
616024
|
existing.viewId,
|
|
@@ -615259,6 +616056,13 @@ Join: ${newUrl}`);
|
|
|
615259
616056
|
const attentionViewId = this.registerTelegramAttentionView(msg, toolContext);
|
|
615260
616057
|
const decision = await this.inferTelegramInteractionDecision(msg, toolContext);
|
|
615261
616058
|
this.writeTelegramAttentionDecision(attentionViewId, decision);
|
|
616059
|
+
this.commitTelegramSocialDecision(
|
|
616060
|
+
sessionKey,
|
|
616061
|
+
msg,
|
|
616062
|
+
decision,
|
|
616063
|
+
this.telegramMessageIdentitySalienceSignals(msg),
|
|
616064
|
+
this.markLatestTelegramDaydreamOpportunitiesConsidered(sessionKey, msg)
|
|
616065
|
+
);
|
|
615262
616066
|
this.markLastTelegramUserMessageMode(msg, decision.shouldReply ? decision.route : "ambient");
|
|
615263
616067
|
this.subAgentViewCallbacks?.onWrite(
|
|
615264
616068
|
this.viewIdForMessage(msg),
|
|
@@ -615689,12 +616493,17 @@ ${conversationStream}`
|
|
|
615689
616493
|
};
|
|
615690
616494
|
let accumulated = "";
|
|
615691
616495
|
const streamable = backend;
|
|
615692
|
-
|
|
615693
|
-
|
|
615694
|
-
|
|
615695
|
-
|
|
615696
|
-
|
|
616496
|
+
const stream = typeof streamable.chatCompletionStream === "function" ? streamable.chatCompletionStream(request) : null;
|
|
616497
|
+
if (stream && typeof stream[Symbol.asyncIterator] === "function") {
|
|
616498
|
+
try {
|
|
616499
|
+
for await (const chunk of stream) {
|
|
616500
|
+
if (chunk.type === "content" && !chunk.thinking && chunk.content) {
|
|
616501
|
+
accumulated += chunk.content;
|
|
616502
|
+
await onToken(accumulated);
|
|
616503
|
+
}
|
|
615697
616504
|
}
|
|
616505
|
+
} catch {
|
|
616506
|
+
accumulated = "";
|
|
615698
616507
|
}
|
|
615699
616508
|
}
|
|
615700
616509
|
if (!accumulated.trim()) {
|
|
@@ -617941,9 +618750,9 @@ ${knownList}` : "Private-user telegram_send_file target must be this DM or a kno
|
|
|
617941
618750
|
}
|
|
617942
618751
|
const target = String(rawTarget).trim();
|
|
617943
618752
|
if (/^-?\d+$/.test(target)) return { ok: true, chatId: target };
|
|
617944
|
-
const
|
|
617945
|
-
if (/^[A-Za-z0-9_]{5,32}$/.test(
|
|
617946
|
-
return { ok: true, chatId: `@${
|
|
618753
|
+
const cleanUsername2 = target.replace(/^@/, "");
|
|
618754
|
+
if (/^[A-Za-z0-9_]{5,32}$/.test(cleanUsername2)) {
|
|
618755
|
+
return { ok: true, chatId: `@${cleanUsername2}` };
|
|
617947
618756
|
}
|
|
617948
618757
|
return { ok: false, error: "Expected chat_id/user_id as digits, or a valid @username." };
|
|
617949
618758
|
}
|
|
@@ -620488,14 +621297,14 @@ var init_access_policy = __esm({
|
|
|
620488
621297
|
});
|
|
620489
621298
|
|
|
620490
621299
|
// packages/cli/src/api/project-preferences.ts
|
|
620491
|
-
import { createHash as
|
|
621300
|
+
import { createHash as createHash25 } from "node:crypto";
|
|
620492
621301
|
import { existsSync as existsSync116, mkdirSync as mkdirSync68, readFileSync as readFileSync95, renameSync as renameSync8, writeFileSync as writeFileSync62, unlinkSync as unlinkSync24 } from "node:fs";
|
|
620493
621302
|
import { homedir as homedir43 } from "node:os";
|
|
620494
621303
|
import { join as join130, resolve as resolve45 } from "node:path";
|
|
620495
621304
|
import { randomUUID as randomUUID15 } from "node:crypto";
|
|
620496
621305
|
function projectKey(root) {
|
|
620497
621306
|
const canonical = resolve45(root);
|
|
620498
|
-
return
|
|
621307
|
+
return createHash25("sha256").update(canonical).digest("hex").slice(0, 16);
|
|
620499
621308
|
}
|
|
620500
621309
|
function projectDir(root) {
|
|
620501
621310
|
return join130(PROJECTS_DIR, projectKey(root));
|
|
@@ -620587,7 +621396,7 @@ __export(voicechat_exports, {
|
|
|
620587
621396
|
VoiceChatSession: () => VoiceChatSession
|
|
620588
621397
|
});
|
|
620589
621398
|
import { EventEmitter as EventEmitter12 } from "node:events";
|
|
620590
|
-
function
|
|
621399
|
+
function clamp0110(x) {
|
|
620591
621400
|
return x < 0 ? 0 : x > 1 ? 1 : x;
|
|
620592
621401
|
}
|
|
620593
621402
|
function alnumRatio(s2) {
|
|
@@ -620626,9 +621435,9 @@ function computeSignalFromText(text, confidence2) {
|
|
|
620626
621435
|
else score = 0.15;
|
|
620627
621436
|
score -= repeatingCharPenalty(t2) * 0.4;
|
|
620628
621437
|
if (typeof confidence2 === "number" && !Number.isNaN(confidence2)) {
|
|
620629
|
-
score = 0.7 * score + 0.3 *
|
|
621438
|
+
score = 0.7 * score + 0.3 * clamp0110(confidence2);
|
|
620630
621439
|
}
|
|
620631
|
-
return
|
|
621440
|
+
return clamp0110(score);
|
|
620632
621441
|
}
|
|
620633
621442
|
function truncateForLog(s2, n2) {
|
|
620634
621443
|
return s2.length <= n2 ? s2 : s2.slice(0, n2 - 1) + "…";
|
|
@@ -620898,7 +621707,7 @@ Rules:
|
|
|
620898
621707
|
}, MAX_SEGMENT_MS);
|
|
620899
621708
|
}
|
|
620900
621709
|
this.captureBuffer = text;
|
|
620901
|
-
this.lastSignalScore = typeof snr === "number" && !Number.isNaN(snr) ?
|
|
621710
|
+
this.lastSignalScore = typeof snr === "number" && !Number.isNaN(snr) ? clamp0110(snr) : computeSignalFromText(text, confidence2);
|
|
620902
621711
|
this.emit("snr", { score: this.lastSignalScore });
|
|
620903
621712
|
this.onPartialTranscript(text);
|
|
620904
621713
|
if (this.silenceTimer) clearTimeout(this.silenceTimer);
|
|
@@ -621673,7 +622482,7 @@ var init_disk_task_output = __esm({
|
|
|
621673
622482
|
});
|
|
621674
622483
|
|
|
621675
622484
|
// packages/cli/src/api/http.ts
|
|
621676
|
-
import { createHash as
|
|
622485
|
+
import { createHash as createHash26 } from "node:crypto";
|
|
621677
622486
|
function problemDetails(opts) {
|
|
621678
622487
|
const p2 = {
|
|
621679
622488
|
type: opts.type ?? "about:blank",
|
|
@@ -621736,7 +622545,7 @@ function paginated(items, page2, total) {
|
|
|
621736
622545
|
}
|
|
621737
622546
|
function computeEtag(payload) {
|
|
621738
622547
|
const json = typeof payload === "string" ? payload : JSON.stringify(payload);
|
|
621739
|
-
const hash =
|
|
622548
|
+
const hash = createHash26("sha1").update(json).digest("hex").slice(0, 16);
|
|
621740
622549
|
return `W/"${hash}"`;
|
|
621741
622550
|
}
|
|
621742
622551
|
function checkNotModified(req2, res, etag) {
|
|
@@ -636007,7 +636816,7 @@ import { homedir as homedir50 } from "node:os";
|
|
|
636007
636816
|
import { spawn as spawn30, execSync as execSync57 } from "node:child_process";
|
|
636008
636817
|
import { mkdirSync as mkdirSync76, writeFileSync as writeFileSync68, readFileSync as readFileSync103, readdirSync as readdirSync45, existsSync as existsSync127, watch as fsWatch3, renameSync as renameSync9, unlinkSync as unlinkSync26 } from "node:fs";
|
|
636009
636818
|
import { randomBytes as randomBytes25, randomUUID as randomUUID16 } from "node:crypto";
|
|
636010
|
-
import { createHash as
|
|
636819
|
+
import { createHash as createHash28 } from "node:crypto";
|
|
636011
636820
|
function memoryDbPaths3(baseDir = process.cwd()) {
|
|
636012
636821
|
const dir = join141(baseDir, ".omnius");
|
|
636013
636822
|
return {
|
|
@@ -641887,7 +642696,7 @@ function listScheduledTasks() {
|
|
|
641887
642696
|
const schedule = String(t2?.schedule || t2?.cron || t2?.when || "");
|
|
641888
642697
|
const enabled2 = typeof t2?.enabled === "boolean" ? t2.enabled : true;
|
|
641889
642698
|
const realId = typeof t2?.id === "string" && t2.id ? t2.id : null;
|
|
641890
|
-
const fallbackId =
|
|
642699
|
+
const fallbackId = createHash28("sha1").update(`${file}#${i2}`).digest("hex").slice(0, 16);
|
|
641891
642700
|
const uid = realId || fallbackId;
|
|
641892
642701
|
const key = `${uid}`;
|
|
641893
642702
|
if (seen.has(key)) return;
|
|
@@ -642004,8 +642813,8 @@ function deleteScheduledById(id) {
|
|
|
642004
642813
|
if (id) candidates.push(id);
|
|
642005
642814
|
if (typeof entry?.id === "string" && entry.id && !candidates.includes(entry.id)) candidates.push(entry.id);
|
|
642006
642815
|
try {
|
|
642007
|
-
const { createHash:
|
|
642008
|
-
const fallback =
|
|
642816
|
+
const { createHash: createHash29 } = require4("node:crypto");
|
|
642817
|
+
const fallback = createHash29("sha1").update(`${target.file}#${target.index}`).digest("hex").slice(0, 16);
|
|
642009
642818
|
if (!candidates.includes(fallback)) candidates.push(fallback);
|
|
642010
642819
|
} catch {
|
|
642011
642820
|
}
|
|
@@ -651921,13 +652730,13 @@ NEW TASK: ${fullInput}`;
|
|
|
651921
652730
|
writeContent(() => renderError(errMsg));
|
|
651922
652731
|
if (failureStore) {
|
|
651923
652732
|
try {
|
|
651924
|
-
const { createHash:
|
|
652733
|
+
const { createHash: createHash29 } = await import("node:crypto");
|
|
651925
652734
|
failureStore.insert({
|
|
651926
652735
|
taskId: "",
|
|
651927
652736
|
sessionId: `${Date.now()}`,
|
|
651928
652737
|
repoRoot,
|
|
651929
652738
|
failureType: "runtime-error",
|
|
651930
|
-
fingerprint:
|
|
652739
|
+
fingerprint: createHash29("sha256").update(errMsg.slice(0, 200)).digest("hex").slice(0, 16),
|
|
651931
652740
|
filePath: null,
|
|
651932
652741
|
errorMessage: errMsg.slice(0, 500),
|
|
651933
652742
|
context: null,
|