blun-king-cli 9.1.388 → 9.1.389

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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  const { openCognitiveStateStore } = require('./cognitive-state-store.cjs');
4
4
 
5
- const COGNITIVE_MEMORY_ADAPTER_VERSION = 3;
5
+ const COGNITIVE_MEMORY_ADAPTER_VERSION = 4;
6
6
  const KIND_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
7
7
  const ACCESS_KEYS = Object.freeze([
8
8
  'actorId', 'agentId', 'channelId', 'conversationId', 'permissionContext',
@@ -92,6 +92,7 @@ function assertCommitAccess(input, access) {
92
92
  }
93
93
  for (const observation of input.observations) assertVisibleScope(observation?.scope, access);
94
94
  if (safeId(input?.source?.provider) !== access.portalId
95
+ || safeId(input?.source?.channel_id) !== access.channelId
95
96
  || safeId(input?.source?.actor_id) !== access.actorId
96
97
  || safeId(input?.source?.context_id) !== access.conversationId) {
97
98
  fail('COGNITIVE_MEMORY_SOURCE_MISMATCH');
@@ -110,6 +110,7 @@ function matchesRevisionReplay(items, target, command, commandSource) {
110
110
  : item.withdraws === target.observationId && item.value === 'withdrawn';
111
111
  return linked
112
112
  && item.source?.provider === commandSource.source.provider
113
+ && item.source?.channel_id === commandSource.source.channelId
113
114
  && item.source?.actor_id === commandSource.source.actorId
114
115
  && item.source?.context_id === commandSource.source.contextId
115
116
  && item.source?.message_id === commandSource.source.messageId
@@ -133,6 +134,7 @@ function normalizeTelegramSource(source) {
133
134
  occurredAt: timestamp,
134
135
  source: {
135
136
  provider: 'telegram',
137
+ channelId: 'direct',
136
138
  actorId: `tg_user_${userId}`,
137
139
  contextId: `tg_chat_${chatId}`,
138
140
  messageId: `tg_message_${messageId}`,
@@ -153,6 +155,7 @@ function localSource({ env, sessionId, occurredAt, nonce }) {
153
155
  occurredAt,
154
156
  source: {
155
157
  provider: 'cli',
158
+ channelId: 'terminal',
156
159
  actorId: digestId('localuser', [actor]),
157
160
  contextId: digestId('clisession', [session]),
158
161
  messageId: digestId('cliinput', [unique]),
@@ -42,10 +42,11 @@ function exactKeys(value, keys) {
42
42
  }
43
43
 
44
44
  function normalizeSource(source) {
45
- const allowed = new Set(['provider', 'actor_id', 'context_id', 'message_id']);
45
+ const allowed = new Set(['provider', 'channel_id', 'actor_id', 'context_id', 'message_id']);
46
46
  if (!exactKeys(source, allowed) || hasForbiddenKey(source)) fail('COGNITIVE_FORBIDDEN_FIELD');
47
47
  const normalized = {
48
48
  provider: safeId(source.provider),
49
+ channel_id: safeId(source.channel_id),
49
50
  actor_id: safeId(source.actor_id),
50
51
  context_id: safeId(source.context_id),
51
52
  message_id: safeId(source.message_id),
@@ -129,6 +129,7 @@ function createCognitiveTurnLifecycle({
129
129
  occurredAt,
130
130
  source: {
131
131
  provider: 'runtime',
132
+ channel_id: 'runtime',
132
133
  actor_id: agent,
133
134
  context_id: runtime,
134
135
  message_id: stageKey,
@@ -177,6 +178,7 @@ function createCognitiveTurnLifecycle({
177
178
  occurredAt,
178
179
  source: {
179
180
  provider: 'runtime',
181
+ channel_id: 'runtime',
180
182
  actor_id: agent,
181
183
  context_id: 'durable-focus',
182
184
  message_id: stageKey,
@@ -282,11 +284,12 @@ function createCognitiveTurnLifecycle({
282
284
  if (!requestId || !targetObservationId || !FOCUS_DOMAINS.has(domain) || !key
283
285
  || AUTHORITY_KEY_RE.test(key) || !scope || scope === 'runtime'
284
286
  || Number.isNaN(Date.parse(occurredAt))
285
- || !exactKeys(source, new Set(['provider', 'actorId', 'contextId', 'messageId']))) {
287
+ || !exactKeys(source, new Set(['provider', 'channelId', 'actorId', 'contextId', 'messageId']))) {
286
288
  fail('COGNITIVE_REVISION_INVALID');
287
289
  }
288
290
  const normalizedSource = {
289
291
  provider: safeId(source.provider),
292
+ channel_id: safeId(source.channelId),
290
293
  actor_id: safeId(source.actorId),
291
294
  context_id: safeId(source.contextId),
292
295
  message_id: safeId(source.messageId),
@@ -313,7 +316,7 @@ function createCognitiveTurnLifecycle({
313
316
  actorId: normalizedSource.actor_id,
314
317
  agentId: agent,
315
318
  portalId: normalizedSource.provider,
316
- channelId: normalizedSource.provider,
319
+ channelId: normalizedSource.channel_id,
317
320
  conversationId: normalizedSource.context_id,
318
321
  requestedScope: scope,
319
322
  permissionContext: {
@@ -332,6 +335,7 @@ function createCognitiveTurnLifecycle({
332
335
  && existing.supersedes === (observation.supersedes ?? null)
333
336
  && existing.withdraws === (observation.withdraws ?? null)
334
337
  && existing.source.provider === normalizedSource.provider
338
+ && existing.source.channel_id === normalizedSource.channel_id
335
339
  && existing.source.actor_id === normalizedSource.actor_id
336
340
  && existing.source.context_id === normalizedSource.context_id
337
341
  && existing.source.message_id === normalizedSource.message_id;
@@ -140,6 +140,7 @@ function createPersonalityMemoryAdapter({ identityRoot, memoryAdapter } = {}) {
140
140
  occurredAt: value.occurredAt,
141
141
  source: {
142
142
  provider: value.sourcePortal,
143
+ channel_id: value.sourceChannel,
143
144
  actor_id: value.actorId,
144
145
  context_id: value.conversationId,
145
146
  message_id: value.messageId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "blun-king-cli",
3
- "version": "9.1.388",
3
+ "version": "9.1.389",
4
4
  "description": "BLUN CLI - your own AI agent with a Telegram channel. Get it done. With BLUN.",
5
5
  "license": "MIT",
6
6
  "bin": {