@pixelbyte-software/pixcode 1.53.7 → 1.53.8

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.
@@ -27,6 +27,8 @@ const TERMINAL_RUN_STATES = new Set(['completed', 'failed', 'canceled']);
27
27
  const CALLBACK_TTL_MS = 10 * 60 * 1000;
28
28
  const MAX_CALLBACK_ACTIONS = 1000;
29
29
  const MAX_TELEGRAM_TEXT = 3600;
30
+ const MAX_ACTIVITY_OUTPUT_CHARS = 48_000;
31
+ const MAX_SSE_BUFFER_CHARS = 256_000;
30
32
  const ACTIVITY_EDIT_THROTTLE_MS = 1200;
31
33
  const ACTIVITY_HEARTBEAT_MS = 8000;
32
34
  const INTENT_ROUTER_TIMEOUT_MS = 45_000;
@@ -85,6 +87,14 @@ function truncate(text, max = MAX_TELEGRAM_TEXT) {
85
87
  return value.length > max ? `${value.slice(0, max - 20)}\n\n…truncated…` : value;
86
88
  }
87
89
 
90
+ function appendBoundedText(current, chunk, maxChars = MAX_ACTIVITY_OUTPUT_CHARS) {
91
+ const nextChunk = String(chunk || '');
92
+ if (!nextChunk) return { text: current || '', truncated: false };
93
+ const combined = `${current || ''}${nextChunk}`;
94
+ if (combined.length <= maxChars) return { text: combined, truncated: false };
95
+ return { text: combined.slice(-maxChars), truncated: true };
96
+ }
97
+
88
98
  function languageFor(link) {
89
99
  return SUPPORTED_LANGUAGES.includes(link?.language) ? link.language : 'en';
90
100
  }
@@ -313,6 +323,9 @@ async function localAgentStream(userId, body, onEvent) {
313
323
  const { done, value } = await reader.read();
314
324
  if (done) break;
315
325
  buffer += decoder.decode(value, { stream: true });
326
+ if (buffer.length > MAX_SSE_BUFFER_CHARS) {
327
+ buffer = buffer.slice(-MAX_SSE_BUFFER_CHARS);
328
+ }
316
329
  let boundary = buffer.indexOf('\n\n');
317
330
  while (boundary !== -1) {
318
331
  const block = buffer.slice(0, boundary);
@@ -360,6 +373,7 @@ function createActivityState({ lang, type = 'agent', provider, project, prompt,
360
373
  workflowId: null,
361
374
  events: [],
362
375
  output: '',
376
+ outputTruncated: false,
363
377
  error: null,
364
378
  };
365
379
  }
@@ -386,6 +400,13 @@ function trimTelegramOutput(text, max, suffix = '') {
386
400
  return `${value.slice(0, room).trim()}\n\n${ending}`;
387
401
  }
388
402
 
403
+ function appendActivityOutput(activity, chunk) {
404
+ if (!activity) return;
405
+ const next = appendBoundedText(activity.output, chunk);
406
+ activity.output = next.text;
407
+ activity.outputTruncated = Boolean(activity.outputTruncated || next.truncated);
408
+ }
409
+
389
410
  function renderActivity(activity, { finalText = null } = {}) {
390
411
  const output = finalText || activity.output;
391
412
  if (activity.type === 'agent' && output && !activity.error) {
@@ -393,7 +414,9 @@ function renderActivity(activity, { finalText = null } = {}) {
393
414
  return trimTelegramOutput(
394
415
  output,
395
416
  3400,
396
- t(activity.lang, 'control.activity.outputTooLong'),
417
+ activity.outputTruncated
418
+ ? t(activity.lang, 'control.activity.outputHistoryTrimmed')
419
+ : t(activity.lang, 'control.activity.outputTooLong'),
397
420
  );
398
421
  }
399
422
 
@@ -839,13 +862,13 @@ function applyAgentStreamEvent(activity, event) {
839
862
  if (event.kind === 'stream_delta' || event.kind === 'text') {
840
863
  activity.status = 'running';
841
864
  activity.phase = t(activity.lang, 'control.activity.responding');
842
- activity.output = `${activity.output}${extractTextFromEvent(event)}`;
865
+ appendActivityOutput(activity, extractTextFromEvent(event));
843
866
  return;
844
867
  }
845
868
  if (event.type === 'claude-response' && event.data?.type === 'assistant') {
846
869
  activity.status = 'running';
847
870
  activity.phase = t(activity.lang, 'control.activity.responding');
848
- activity.output = `${activity.output}${extractTextFromEvent(event)}`;
871
+ appendActivityOutput(activity, extractTextFromEvent(event));
849
872
  return;
850
873
  }
851
874
  if (event.kind === 'tool_use') {
@@ -140,6 +140,7 @@ const EN = {
140
140
  'control.activity.tokens': 'Tokens',
141
141
  'control.activity.liveFooter': 'Response is still streaming · {{elapsed}}',
142
142
  'control.activity.outputShortened': 'Telegram output was shortened while the run continues.',
143
+ 'control.activity.outputHistoryTrimmed': 'Earlier response output was trimmed to protect memory. Open the Pixcode session for the full output.',
143
144
  'control.activity.outputTooLong': 'Long response shortened for Telegram. Open the session in Pixcode for the full output.',
144
145
  'notification.taskDone': '✅ {{title}} — task completed.',
145
146
  'notification.taskFailed': '⚠️ {{title}} — task failed: {{error}}',
@@ -281,6 +282,7 @@ const TR = {
281
282
  'control.activity.tokens': 'Token',
282
283
  'control.activity.liveFooter': 'Yanıt devam ediyor · {{elapsed}}',
283
284
  'control.activity.outputShortened': 'Telegram çıktısı çalışma devam ederken kısaltıldı.',
285
+ 'control.activity.outputHistoryTrimmed': 'Yanıtın önceki bölümü bellek koruması için kısaltıldı. Tam çıktı için Pixcode oturumunu aç.',
284
286
  'control.activity.outputTooLong': 'Uzun yanıt Telegram için kısaltıldı. Tam çıktı için Pixcode oturumunu aç.',
285
287
  'notification.taskDone': '✅ {{title}} — görev tamamlandı.',
286
288
  'notification.taskFailed': '⚠️ {{title}} — görev başarısız: {{error}}',