blun-king-cli 9.1.417 → 9.1.418
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/LIESMICH.txt +8 -0
- package/README.md +8 -0
- package/bin/identity-context-policy.cjs +61 -3
- package/package.json +1 -1
- package/telegram-plugin/dist/bridge.mjs +1 -0
package/LIESMICH.txt
CHANGED
|
@@ -75,6 +75,14 @@ sämtliche zurückgegebenen Nachrichten-IDs zusammen mit dem vollständigen Text
|
|
|
75
75
|
Schlägt ein Teil fehl, endet die Zustellung an dieser Stelle, statt die Antwort
|
|
76
76
|
fälschlich als vollständig zu melden.
|
|
77
77
|
|
|
78
|
+
Ab BLUN King 9.1.418 übernimmt der Identitätsgraph die von Telegram bestätigte
|
|
79
|
+
Unterscheidung zwischen Menschen und Bots. Bereits vorhandene
|
|
80
|
+
Telegram-Kontakte, die mangels dieses Merkmals als Menschen angelegt wurden,
|
|
81
|
+
werden bei der nächsten eindeutig als Bot bestätigten Nachricht einmalig als
|
|
82
|
+
Agent korrigiert. Alle Rollen, Zuständigkeiten, Beziehungsnotizen und sonstigen
|
|
83
|
+
Felder bleiben unverändert. Ein Agent wird niemals zu einer Person
|
|
84
|
+
zurückgestuft; Namen oder Benutzernamen dienen nicht als Beweis.
|
|
85
|
+
|
|
78
86
|
Zuverlässiger King-Start
|
|
79
87
|
-----------------------
|
|
80
88
|
Bei einer ausdrücklich als wiederholbar gekennzeichneten Serverüberlastung
|
package/README.md
CHANGED
|
@@ -90,6 +90,14 @@ sämtliche zurückgegebenen Nachrichten-IDs zusammen mit dem vollständigen Text
|
|
|
90
90
|
Schlägt ein Teil fehl, endet die Zustellung an dieser Stelle, statt die Antwort
|
|
91
91
|
fälschlich als vollständig zu melden.
|
|
92
92
|
|
|
93
|
+
Ab BLUN King 9.1.418 übernimmt der Identitätsgraph die von Telegram bestätigte
|
|
94
|
+
Unterscheidung zwischen Menschen und Bots. Bereits vorhandene
|
|
95
|
+
Telegram-Kontakte, die mangels dieses Merkmals als Menschen angelegt wurden,
|
|
96
|
+
werden bei der nächsten eindeutig als Bot bestätigten Nachricht einmalig als
|
|
97
|
+
Agent korrigiert. Alle Rollen, Zuständigkeiten, Beziehungsnotizen und sonstigen
|
|
98
|
+
Felder bleiben unverändert. Ein Agent wird niemals zu einer Person
|
|
99
|
+
zurückgestuft; Namen oder Benutzernamen dienen nicht als Beweis.
|
|
100
|
+
|
|
93
101
|
`Strg+C` und `Esc` brechen einen aktiven Zug zuverlässig ab, ohne den bereits
|
|
94
102
|
geschriebenen Entwurf zu löschen. Das gilt auch bei Autovervollständigung,
|
|
95
103
|
Geistervorschlägen, Bash-Eingabe und einer noch offenen Mehrzeileneingabe.
|
|
@@ -93,6 +93,51 @@ function createJsonOnce(root, segments, value) {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
function updateJsonAtomically(root, segments, update) {
|
|
97
|
+
const target = path.resolve(root, ...segments);
|
|
98
|
+
if (!isInside(root, target)) return false;
|
|
99
|
+
let handle;
|
|
100
|
+
let temp = '';
|
|
101
|
+
try {
|
|
102
|
+
const stat = fs.lstatSync(target);
|
|
103
|
+
if (!stat.isFile() || stat.isSymbolicLink() || stat.size > MAX_FILE_BYTES) return false;
|
|
104
|
+
const original = fs.readFileSync(target, 'utf8');
|
|
105
|
+
const current = JSON.parse(original);
|
|
106
|
+
if (!current || typeof current !== 'object' || Array.isArray(current)) return false;
|
|
107
|
+
const next = update(current);
|
|
108
|
+
if (!next || typeof next !== 'object' || Array.isArray(next)) return false;
|
|
109
|
+
const serialized = `${JSON.stringify(next, null, 2)}\n`;
|
|
110
|
+
if (Buffer.byteLength(serialized, 'utf8') > MAX_FILE_BYTES) return false;
|
|
111
|
+
|
|
112
|
+
const parent = path.dirname(target);
|
|
113
|
+
const realParent = fs.realpathSync(parent);
|
|
114
|
+
if (!isInside(root, realParent)) return false;
|
|
115
|
+
temp = path.join(parent, `.${path.basename(target)}.${process.pid}.${Date.now()}.tmp`);
|
|
116
|
+
handle = fs.openSync(temp, 'wx', 0o600);
|
|
117
|
+
fs.writeFileSync(handle, serialized, 'utf8');
|
|
118
|
+
fs.fsyncSync(handle);
|
|
119
|
+
fs.closeSync(handle);
|
|
120
|
+
handle = undefined;
|
|
121
|
+
|
|
122
|
+
const currentStat = fs.lstatSync(target);
|
|
123
|
+
if (!currentStat.isFile() || currentStat.isSymbolicLink() || fs.readFileSync(target, 'utf8') !== original) return false;
|
|
124
|
+
fs.renameSync(temp, target);
|
|
125
|
+
temp = '';
|
|
126
|
+
return true;
|
|
127
|
+
} catch {
|
|
128
|
+
return false;
|
|
129
|
+
} finally {
|
|
130
|
+
if (handle !== undefined) fs.closeSync(handle);
|
|
131
|
+
if (temp) {
|
|
132
|
+
try { fs.rmSync(temp, { force: true }); } catch {}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function isExplicitTelegramBot(meta) {
|
|
138
|
+
return meta?.is_bot === true || String(meta?.is_bot ?? '').toLowerCase() === 'true';
|
|
139
|
+
}
|
|
140
|
+
|
|
96
141
|
function cleanText(value, maxChars = 240) {
|
|
97
142
|
if (typeof value !== 'string') return '';
|
|
98
143
|
return value.replace(/[\u0000-\u001f\u007f]+/gu, ' ').replace(/\s+/gu, ' ').trim().slice(0, maxChars);
|
|
@@ -485,19 +530,31 @@ function recordChannelIdentity(envelope, env = process.env) {
|
|
|
485
530
|
const firstSeenAt = trustedTimestamp(meta.ts);
|
|
486
531
|
const receivedAt = trustedTimestamp(meta.received_at) || firstSeenAt;
|
|
487
532
|
const created = [];
|
|
488
|
-
|
|
533
|
+
const updated = [];
|
|
534
|
+
const actorSegments = ['actors', `${actorId}.json`];
|
|
535
|
+
const actorCreated = createJsonOnce(root, actorSegments, {
|
|
489
536
|
version: 1,
|
|
490
537
|
actor_id: actorId,
|
|
491
538
|
provider: 'telegram',
|
|
492
539
|
provider_subject_id: subjectId,
|
|
493
540
|
display_name: displayName,
|
|
494
|
-
kind:
|
|
541
|
+
kind: isExplicitTelegramBot(meta) ? 'agent' : 'person',
|
|
495
542
|
role: '',
|
|
496
543
|
responsibilities: [],
|
|
497
544
|
traits: [],
|
|
498
545
|
aliases: [],
|
|
499
546
|
...(firstSeenAt ? { first_seen_at: firstSeenAt } : {}),
|
|
500
|
-
})
|
|
547
|
+
});
|
|
548
|
+
if (actorCreated) created.push('actor');
|
|
549
|
+
else if (isExplicitTelegramBot(meta) && updateJsonAtomically(root, actorSegments, (actor) => (
|
|
550
|
+
actor.version === 1
|
|
551
|
+
&& actor.actor_id === actorId
|
|
552
|
+
&& actor.provider === 'telegram'
|
|
553
|
+
&& actor.provider_subject_id === subjectId
|
|
554
|
+
&& actor.kind === 'person'
|
|
555
|
+
? { ...actor, kind: 'agent' }
|
|
556
|
+
: undefined
|
|
557
|
+
))) updated.push('actor_kind');
|
|
501
558
|
if (createJsonOnce(root, ['agents', agentId, 'relationships', `${actorId}.json`], {
|
|
502
559
|
version: 1,
|
|
503
560
|
actor_id: actorId,
|
|
@@ -621,6 +678,7 @@ function recordChannelIdentity(envelope, env = process.env) {
|
|
|
621
678
|
actor_id: actorId,
|
|
622
679
|
...(groupId ? { group_id: groupId } : {}),
|
|
623
680
|
created,
|
|
681
|
+
updated,
|
|
624
682
|
...(learning ? { learning } : {}),
|
|
625
683
|
...(journal ? { journal } : {}),
|
|
626
684
|
model_context: modelContext,
|
package/package.json
CHANGED
|
@@ -4702,6 +4702,7 @@ async function handleInbound(event) {
|
|
|
4702
4702
|
...msgId !== void 0 ? { message_id: String(msgId) } : {},
|
|
4703
4703
|
addressed: String(addressed),
|
|
4704
4704
|
user: ctx.from?.username ?? String(ctx.from?.id),
|
|
4705
|
+
is_bot: String(ctx.from?.is_bot === true),
|
|
4705
4706
|
user_id: String(ctx.from?.id),
|
|
4706
4707
|
ts: (/* @__PURE__ */ new Date((ctx.date ?? 0) * 1e3)).toISOString(),
|
|
4707
4708
|
...imagePath !== void 0 ? { image_path: imagePath } : {},
|