@luckydraw/cumulus 0.30.27 → 0.30.29

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.
@@ -563,6 +563,31 @@
563
563
  ' font-size: 0.85em; line-height: 1; cursor: pointer; padding: 0 0.1em;',
564
564
  '}',
565
565
  '.cumulus-attach-chip-remove:hover { color: #ff6666; }',
566
+ /* Upload progress bar — thin overlay at bottom of chip */
567
+ '.cumulus-attach-chip-progress {',
568
+ ' position: absolute; left: 0; right: 0; bottom: 0;',
569
+ ' height: 3px; background: rgba(255,255,255,0.08);',
570
+ ' overflow: hidden;',
571
+ '}',
572
+ '.cumulus-attach-chip-progress-fill {',
573
+ ' height: 100%; width: 0%;',
574
+ ' background: linear-gradient(90deg, #7c3aed, #a78bfa);',
575
+ ' transition: width 0.15s ease;',
576
+ '}',
577
+ /* Status badge (✓ or ✗) — small corner indicator */
578
+ '.cumulus-attach-chip-status {',
579
+ ' position: absolute; bottom: 0.15em; left: 0.2em;',
580
+ ' font-size: 0.75em; line-height: 1; font-weight: bold;',
581
+ ' pointer-events: none;',
582
+ '}',
583
+ '.cumulus-attach-chip[data-status="done"] .cumulus-attach-chip-status { color: #4ade80; }',
584
+ '.cumulus-attach-chip[data-status="error"] {',
585
+ ' border-color: #b91c1c;',
586
+ '}',
587
+ '.cumulus-attach-chip[data-status="error"] .cumulus-attach-chip-status { color: #ef4444; }',
588
+ '.cumulus-attach-chip[data-status="uploading"] {',
589
+ ' opacity: 0.85;',
590
+ '}',
566
591
 
567
592
  /* Input row (attach btn + textarea + send btn) */
568
593
  '.cumulus-input-row {',
@@ -2070,6 +2095,20 @@
2070
2095
 
2071
2096
  // ── Markdown ──────────────────────────────────────────────────────────────
2072
2097
 
2098
+ // Strip literal <thinking>...</thinking> blocks from displayed assistant
2099
+ // content. The server already filters these from the live token stream, but
2100
+ // the final `done` response and replayed history carry the raw text (kept
2101
+ // for RLM context). This guarantees they never render in the chat area.
2102
+ function stripThinkingBlocks(text) {
2103
+ if (typeof text !== 'string' || text.indexOf('<thinking') === -1) return text;
2104
+ var out = text.replace(/<thinking>[\s\S]*?<\/thinking>/gi, '');
2105
+ // Drop a dangling/unterminated <thinking> (truncated reasoning) through end
2106
+ out = out.replace(/<thinking>[\s\S]*$/i, '');
2107
+ // Tidy whitespace left behind by removed blocks
2108
+ out = out.replace(/^\s+/, '').replace(/\n{3,}/g, '\n\n');
2109
+ return out;
2110
+ }
2111
+
2073
2112
  function renderMarkdown(text) {
2074
2113
  // Phase 0.5: Extract blex fences BEFORE code blocks
2075
2114
  var blexResult = extractBlexBlocks(text);
@@ -2598,6 +2637,77 @@
2598
2637
  });
2599
2638
  }
2600
2639
 
2640
+ function formatFileSize(bytes) {
2641
+ if (bytes < 1024) return bytes + ' B';
2642
+ if (bytes < 1024 * 1024) return (bytes / 1024).toFixed(1) + ' KB';
2643
+ if (bytes < 1024 * 1024 * 1024) return (bytes / (1024 * 1024)).toFixed(1) + ' MB';
2644
+ return (bytes / (1024 * 1024 * 1024)).toFixed(2) + ' GB';
2645
+ }
2646
+
2647
+ // Upload a non-image file to /api/media/upload via XHR with progress.
2648
+ // Mutates the attachment object in place: progress, status, url, path, error, xhr.
2649
+ // Calls onChange() whenever state advances so the UI can re-render.
2650
+ function uploadAttachment(att, file, apiKey, onChange) {
2651
+ var xhr = new XMLHttpRequest();
2652
+ att.xhr = xhr;
2653
+
2654
+ var url = '/api/media/upload?filename=' + encodeURIComponent(file.name);
2655
+ xhr.open('POST', url, true);
2656
+ xhr.setRequestHeader('X-API-Key', apiKey || '');
2657
+ xhr.setRequestHeader('Content-Type', file.type || 'application/octet-stream');
2658
+
2659
+ xhr.upload.addEventListener('progress', function (e) {
2660
+ if (e.lengthComputable && att.status === 'uploading') {
2661
+ att.progress = e.loaded / e.total;
2662
+ if (onChange) onChange();
2663
+ }
2664
+ });
2665
+
2666
+ xhr.addEventListener('load', function () {
2667
+ if (att.status !== 'uploading') return; // aborted/removed
2668
+ if (xhr.status >= 200 && xhr.status < 300) {
2669
+ try {
2670
+ var resp = JSON.parse(xhr.responseText);
2671
+ // /api/media/upload returns {files: [...]} for multipart, or the single result object
2672
+ var result = resp.files && resp.files[0] ? resp.files[0] : resp;
2673
+ att.status = 'done';
2674
+ att.progress = 1;
2675
+ att.url = result.url;
2676
+ att.path = result.path;
2677
+ att.serverSize = result.size;
2678
+ } catch (e) {
2679
+ att.status = 'error';
2680
+ att.error = 'Invalid server response';
2681
+ }
2682
+ } else {
2683
+ att.status = 'error';
2684
+ try {
2685
+ var errResp = JSON.parse(xhr.responseText);
2686
+ att.error = errResp.error || 'HTTP ' + xhr.status;
2687
+ } catch (e) {
2688
+ att.error = 'HTTP ' + xhr.status;
2689
+ }
2690
+ }
2691
+ att.xhr = null;
2692
+ if (onChange) onChange();
2693
+ });
2694
+
2695
+ xhr.addEventListener('error', function () {
2696
+ if (att.status !== 'uploading') return;
2697
+ att.status = 'error';
2698
+ att.error = 'Network error';
2699
+ att.xhr = null;
2700
+ if (onChange) onChange();
2701
+ });
2702
+
2703
+ xhr.addEventListener('abort', function () {
2704
+ // Caller is responsible for removing the chip when it aborts
2705
+ att.xhr = null;
2706
+ });
2707
+
2708
+ xhr.send(file);
2709
+ }
2710
+
2601
2711
  // ─── WebSocket Connection ────────────────────────────────────────────────────
2602
2712
  function createConnection(opts) {
2603
2713
  var wsUrl = opts.wsUrl;
@@ -2838,7 +2948,7 @@
2838
2948
  var fileInput = document.createElement('input');
2839
2949
  fileInput.type = 'file';
2840
2950
  fileInput.multiple = true;
2841
- fileInput.accept = 'image/*,.pdf,.txt,.md,.js,.ts,.py,.json,.csv';
2951
+ // Accept any file type — non-image files upload to media server with progress
2842
2952
  fileInput.style.display = 'none';
2843
2953
  fileInput.setAttribute('data-testid', 'webchat-file-input');
2844
2954
 
@@ -2949,6 +3059,7 @@
2949
3059
  }
2950
3060
 
2951
3061
  function buildAssistantMsgEl(content, isStreaming, msgKey) {
3062
+ content = stripThinkingBlocks(content);
2952
3063
  var el = document.createElement('div');
2953
3064
  el.className = 'cumulus-msg assistant';
2954
3065
  if (isStreaming) el.setAttribute('data-testid', 'webchat-streaming');
@@ -3165,11 +3276,22 @@
3165
3276
  panel.appendChild(dialog);
3166
3277
  }
3167
3278
 
3279
+ function hasUploadingAttachments() {
3280
+ for (var i = 0; i < pendingAttachments.length; i++) {
3281
+ if (pendingAttachments[i].status === 'uploading') return true;
3282
+ }
3283
+ return false;
3284
+ }
3285
+
3168
3286
  function updateSendBtn() {
3169
3287
  if (streaming) {
3170
3288
  sendBtn.textContent = 'Stop';
3171
3289
  sendBtn.classList.add('stop');
3172
3290
  sendBtn.disabled = false;
3291
+ } else if (hasUploadingAttachments()) {
3292
+ sendBtn.textContent = 'Uploading…';
3293
+ sendBtn.classList.remove('stop');
3294
+ sendBtn.disabled = true;
3173
3295
  } else {
3174
3296
  sendBtn.textContent = 'Send';
3175
3297
  sendBtn.classList.remove('stop');
@@ -3207,6 +3329,7 @@
3207
3329
  attachStrip.innerHTML = '';
3208
3330
  if (pendingAttachments.length === 0) {
3209
3331
  attachStrip.style.display = 'none';
3332
+ updateSendBtn();
3210
3333
  return;
3211
3334
  }
3212
3335
  attachStrip.style.display = 'flex';
@@ -3214,6 +3337,8 @@
3214
3337
  var chip = document.createElement('div');
3215
3338
  chip.className = 'cumulus-attach-chip';
3216
3339
  chip.setAttribute('data-testid', 'webchat-attach-chip');
3340
+ chip.setAttribute('data-status', att.status || 'done');
3341
+ if (att.error) chip.setAttribute('title', att.error);
3217
3342
  if (att.isImage) {
3218
3343
  var thumb = document.createElement('img');
3219
3344
  thumb.className = 'cumulus-attach-chip-thumb';
@@ -3230,6 +3355,25 @@
3230
3355
  nameEl.className = 'cumulus-attach-chip-name';
3231
3356
  nameEl.textContent = att.name;
3232
3357
  chip.appendChild(nameEl);
3358
+ if (att.status === 'uploading') {
3359
+ var bar = document.createElement('div');
3360
+ bar.className = 'cumulus-attach-chip-progress';
3361
+ var fill = document.createElement('div');
3362
+ fill.className = 'cumulus-attach-chip-progress-fill';
3363
+ fill.style.width = Math.round((att.progress || 0) * 100) + '%';
3364
+ bar.appendChild(fill);
3365
+ chip.appendChild(bar);
3366
+ } else if (att.status === 'done' && !att.isImage) {
3367
+ var ok = document.createElement('div');
3368
+ ok.className = 'cumulus-attach-chip-status';
3369
+ ok.textContent = '✓';
3370
+ chip.appendChild(ok);
3371
+ } else if (att.status === 'error') {
3372
+ var bad = document.createElement('div');
3373
+ bad.className = 'cumulus-attach-chip-status';
3374
+ bad.textContent = '✗';
3375
+ chip.appendChild(bad);
3376
+ }
3233
3377
  var removeBtn = document.createElement('button');
3234
3378
  removeBtn.className = 'cumulus-attach-chip-remove';
3235
3379
  removeBtn.setAttribute('data-testid', 'webchat-attach-remove');
@@ -3237,6 +3381,14 @@
3237
3381
  removeBtn.setAttribute('title', 'Remove attachment');
3238
3382
  (function (index) {
3239
3383
  removeBtn.addEventListener('click', function () {
3384
+ var removed = pendingAttachments[index];
3385
+ if (removed && removed.xhr) {
3386
+ try {
3387
+ removed.xhr.abort();
3388
+ } catch (e) {
3389
+ /* ignore */
3390
+ }
3391
+ }
3240
3392
  pendingAttachments.splice(index, 1);
3241
3393
  renderAttachStrip();
3242
3394
  });
@@ -3244,23 +3396,44 @@
3244
3396
  chip.appendChild(removeBtn);
3245
3397
  attachStrip.appendChild(chip);
3246
3398
  });
3399
+ updateSendBtn();
3247
3400
  }
3248
3401
 
3249
3402
  async function addFilesToPending(files) {
3250
3403
  for (var i = 0; i < files.length; i++) {
3251
3404
  var file = files[i];
3252
- try {
3253
- var info = await readFileAsBase64(file);
3254
- var dataUrl = await readFileAsDataUrl(file);
3255
- pendingAttachments.push({
3256
- base64: info.base64,
3257
- mimeType: info.mimeType,
3405
+ var isImg = file.type && file.type.startsWith('image/');
3406
+ if (isImg) {
3407
+ try {
3408
+ var info = await readFileAsBase64(file);
3409
+ var dataUrl = await readFileAsDataUrl(file);
3410
+ pendingAttachments.push({
3411
+ base64: info.base64,
3412
+ mimeType: info.mimeType,
3413
+ name: file.name,
3414
+ size: file.size,
3415
+ dataUrl: dataUrl,
3416
+ isImage: true,
3417
+ status: 'done',
3418
+ });
3419
+ } catch (e) {
3420
+ console.error('[Cumulus] Failed to read image:', file.name, e);
3421
+ }
3422
+ } else {
3423
+ var att = {
3258
3424
  name: file.name,
3259
- dataUrl: dataUrl,
3260
- isImage: file.type.startsWith('image/'),
3261
- });
3262
- } catch (e) {
3263
- console.error('[Cumulus] Failed to read file:', file.name, e);
3425
+ mimeType: file.type || 'application/octet-stream',
3426
+ size: file.size,
3427
+ isImage: false,
3428
+ status: 'uploading',
3429
+ progress: 0,
3430
+ url: null,
3431
+ path: null,
3432
+ error: null,
3433
+ xhr: null,
3434
+ };
3435
+ pendingAttachments.push(att);
3436
+ uploadAttachment(att, file, activeApiKey, renderAttachStrip);
3264
3437
  }
3265
3438
  }
3266
3439
  renderAttachStrip();
@@ -3441,7 +3614,13 @@
3441
3614
 
3442
3615
  if (!text && pendingAttachments.length === 0) return;
3443
3616
  if (!connection) return;
3444
- var attachSnapshot = pendingAttachments.slice();
3617
+ if (hasUploadingAttachments()) return; // shouldn't reach here — button disabled
3618
+
3619
+ // Drop attachments that failed to upload — keep only images + done non-images
3620
+ var sendable = pendingAttachments.filter(function (a) {
3621
+ return a.isImage || a.status === 'done';
3622
+ });
3623
+ var attachSnapshot = sendable.slice();
3445
3624
  var displayText = text || '(attachment)';
3446
3625
  messages.push({ role: 'user', content: displayText, attachments: attachSnapshot });
3447
3626
  input.value = '';
@@ -3460,10 +3639,22 @@
3460
3639
  .map(function (a) {
3461
3640
  return { mimeType: a.mimeType, base64: a.base64 };
3462
3641
  });
3642
+ // Build "Attached files:" prefix for non-image uploads so the agent can read_file them
3643
+ var fileAttachments = attachSnapshot.filter(function (a) {
3644
+ return !a.isImage && a.status === 'done' && a.path;
3645
+ });
3646
+ var messageBody = text || '';
3647
+ if (fileAttachments.length > 0) {
3648
+ var lines = fileAttachments.map(function (a) {
3649
+ return '- ' + a.name + ' (' + formatFileSize(a.size || 0) + ') → ' + a.path;
3650
+ });
3651
+ messageBody =
3652
+ 'Attached files:\n' + lines.join('\n') + (messageBody ? '\n\n' + messageBody : '');
3653
+ }
3463
3654
  var payload = {
3464
3655
  type: 'message',
3465
3656
  threadName: sessionId,
3466
- message: text || ' ',
3657
+ message: messageBody || ' ',
3467
3658
  };
3468
3659
  if (imagePayload.length > 0) payload.images = imagePayload;
3469
3660
  connection.send(payload);
@@ -5219,7 +5410,7 @@
5219
5410
  var fileInput = document.createElement('input');
5220
5411
  fileInput.type = 'file';
5221
5412
  fileInput.multiple = true;
5222
- fileInput.accept = 'image/*,.pdf,.txt,.md,.js,.ts,.py,.json,.csv';
5413
+ // Accept any file type — non-image files upload to media server with progress
5223
5414
  fileInput.style.display = 'none';
5224
5415
  fileInput.setAttribute('data-testid', 'webchat-file-input');
5225
5416
 
@@ -5352,6 +5543,7 @@
5352
5543
  }
5353
5544
 
5354
5545
  function buildAssistantMsgEl(content, isStreaming, msgKey) {
5546
+ content = stripThinkingBlocks(content);
5355
5547
  var el = document.createElement('div');
5356
5548
  el.className = 'cumulus-msg assistant';
5357
5549
  if (isStreaming) el.setAttribute('data-testid', 'webchat-streaming');
@@ -5577,8 +5769,16 @@
5577
5769
  panelEl.appendChild(dialog);
5578
5770
  }
5579
5771
 
5772
+ function hasPanelUploading() {
5773
+ for (var i = 0; i < state.pendingAttachments.length; i++) {
5774
+ if (state.pendingAttachments[i].status === 'uploading') return true;
5775
+ }
5776
+ return false;
5777
+ }
5778
+
5580
5779
  function updatePanelSendBtn() {
5581
5780
  var hasInput = inputEl.value.trim().length > 0 || state.pendingAttachments.length > 0;
5781
+ var uploading = hasPanelUploading();
5582
5782
  if (state.streaming && !hasInput) {
5583
5783
  // Streaming with no input — show Stop button
5584
5784
  sendBtn.textContent = 'Stop';
@@ -5586,15 +5786,15 @@
5586
5786
  sendBtn.disabled = false;
5587
5787
  } else if (state.streaming && hasInput) {
5588
5788
  // Streaming with input — show Send (interjection mode)
5589
- sendBtn.textContent = 'Send';
5789
+ sendBtn.textContent = uploading ? 'Uploading…' : 'Send';
5590
5790
  sendBtn.classList.remove('stop');
5591
5791
  sendBtn.classList.add('interject');
5592
- sendBtn.disabled = false;
5792
+ sendBtn.disabled = uploading;
5593
5793
  } else {
5594
- sendBtn.textContent = 'Send';
5794
+ sendBtn.textContent = uploading ? 'Uploading…' : 'Send';
5595
5795
  sendBtn.classList.remove('stop');
5596
5796
  sendBtn.classList.remove('interject');
5597
- sendBtn.disabled = false;
5797
+ sendBtn.disabled = uploading;
5598
5798
  }
5599
5799
  }
5600
5800
 
@@ -5602,6 +5802,7 @@
5602
5802
  attachStrip.innerHTML = '';
5603
5803
  if (state.pendingAttachments.length === 0) {
5604
5804
  attachStrip.style.display = 'none';
5805
+ updatePanelSendBtn();
5605
5806
  return;
5606
5807
  }
5607
5808
  attachStrip.style.display = 'flex';
@@ -5609,6 +5810,8 @@
5609
5810
  var chip = document.createElement('div');
5610
5811
  chip.className = 'cumulus-attach-chip';
5611
5812
  chip.setAttribute('data-testid', 'webchat-attach-chip');
5813
+ chip.setAttribute('data-status', att.status || 'done');
5814
+ if (att.error) chip.setAttribute('title', att.error);
5612
5815
  if (att.isImage) {
5613
5816
  var thumb = document.createElement('img');
5614
5817
  thumb.className = 'cumulus-attach-chip-thumb';
@@ -5625,6 +5828,25 @@
5625
5828
  nameEl.className = 'cumulus-attach-chip-name';
5626
5829
  nameEl.textContent = att.name;
5627
5830
  chip.appendChild(nameEl);
5831
+ if (att.status === 'uploading') {
5832
+ var bar = document.createElement('div');
5833
+ bar.className = 'cumulus-attach-chip-progress';
5834
+ var fill = document.createElement('div');
5835
+ fill.className = 'cumulus-attach-chip-progress-fill';
5836
+ fill.style.width = Math.round((att.progress || 0) * 100) + '%';
5837
+ bar.appendChild(fill);
5838
+ chip.appendChild(bar);
5839
+ } else if (att.status === 'done' && !att.isImage) {
5840
+ var ok = document.createElement('div');
5841
+ ok.className = 'cumulus-attach-chip-status';
5842
+ ok.textContent = '✓';
5843
+ chip.appendChild(ok);
5844
+ } else if (att.status === 'error') {
5845
+ var bad = document.createElement('div');
5846
+ bad.className = 'cumulus-attach-chip-status';
5847
+ bad.textContent = '✗';
5848
+ chip.appendChild(bad);
5849
+ }
5628
5850
  var removeBtn = document.createElement('button');
5629
5851
  removeBtn.className = 'cumulus-attach-chip-remove';
5630
5852
  removeBtn.setAttribute('data-testid', 'webchat-attach-remove');
@@ -5632,6 +5854,14 @@
5632
5854
  removeBtn.setAttribute('title', 'Remove attachment');
5633
5855
  (function (index) {
5634
5856
  removeBtn.addEventListener('click', function () {
5857
+ var removed = state.pendingAttachments[index];
5858
+ if (removed && removed.xhr) {
5859
+ try {
5860
+ removed.xhr.abort();
5861
+ } catch (e) {
5862
+ /* ignore */
5863
+ }
5864
+ }
5635
5865
  state.pendingAttachments.splice(index, 1);
5636
5866
  renderPanelAttachStrip();
5637
5867
  });
@@ -5639,23 +5869,44 @@
5639
5869
  chip.appendChild(removeBtn);
5640
5870
  attachStrip.appendChild(chip);
5641
5871
  });
5872
+ updatePanelSendBtn();
5642
5873
  }
5643
5874
 
5644
5875
  async function addFilesToPending(files) {
5645
5876
  for (var i = 0; i < files.length; i++) {
5646
5877
  var file = files[i];
5647
- try {
5648
- var info = await readFileAsBase64(file);
5649
- var dataUrl = await readFileAsDataUrl(file);
5650
- state.pendingAttachments.push({
5651
- base64: info.base64,
5652
- mimeType: info.mimeType,
5878
+ var isImg = file.type && file.type.startsWith('image/');
5879
+ if (isImg) {
5880
+ try {
5881
+ var info = await readFileAsBase64(file);
5882
+ var dataUrl = await readFileAsDataUrl(file);
5883
+ state.pendingAttachments.push({
5884
+ base64: info.base64,
5885
+ mimeType: info.mimeType,
5886
+ name: file.name,
5887
+ size: file.size,
5888
+ dataUrl: dataUrl,
5889
+ isImage: true,
5890
+ status: 'done',
5891
+ });
5892
+ } catch (e) {
5893
+ console.error('[Cumulus] Failed to read image:', file.name, e);
5894
+ }
5895
+ } else {
5896
+ var att = {
5653
5897
  name: file.name,
5654
- dataUrl: dataUrl,
5655
- isImage: file.type.startsWith('image/'),
5656
- });
5657
- } catch (e) {
5658
- console.error('[Cumulus] Failed to read file:', file.name, e);
5898
+ mimeType: file.type || 'application/octet-stream',
5899
+ size: file.size,
5900
+ isImage: false,
5901
+ status: 'uploading',
5902
+ progress: 0,
5903
+ url: null,
5904
+ path: null,
5905
+ error: null,
5906
+ xhr: null,
5907
+ };
5908
+ state.pendingAttachments.push(att);
5909
+ uploadAttachment(att, file, activeApiKey, renderPanelAttachStrip);
5659
5910
  }
5660
5911
  }
5661
5912
  renderPanelAttachStrip();
@@ -5735,8 +5986,13 @@
5735
5986
 
5736
5987
  if (!text && state.pendingAttachments.length === 0) return;
5737
5988
  if (!connection) return;
5989
+ if (hasPanelUploading()) return; // button is disabled while uploading
5738
5990
 
5739
- var attachSnapshot = state.pendingAttachments.slice();
5991
+ // Drop attachments that failed to upload
5992
+ var sendable = state.pendingAttachments.filter(function (a) {
5993
+ return a.isImage || a.status === 'done';
5994
+ });
5995
+ var attachSnapshot = sendable.slice();
5740
5996
  var displayText = text || '(attachment)';
5741
5997
  state.messages.push({ role: 'user', content: displayText, attachments: attachSnapshot });
5742
5998
  inputEl.value = '';
@@ -5760,10 +6016,23 @@
5760
6016
  return { mimeType: a.mimeType, base64: a.base64 };
5761
6017
  });
5762
6018
 
6019
+ // Build "Attached files:" prefix for non-image uploads
6020
+ var fileAttachments = attachSnapshot.filter(function (a) {
6021
+ return !a.isImage && a.status === 'done' && a.path;
6022
+ });
6023
+ var messageBody = text || '';
6024
+ if (fileAttachments.length > 0) {
6025
+ var lines = fileAttachments.map(function (a) {
6026
+ return '- ' + a.name + ' (' + formatFileSize(a.size || 0) + ') → ' + a.path;
6027
+ });
6028
+ messageBody =
6029
+ 'Attached files:\n' + lines.join('\n') + (messageBody ? '\n\n' + messageBody : '');
6030
+ }
6031
+
5763
6032
  var payload = {
5764
6033
  type: 'message',
5765
6034
  threadName: threadName,
5766
- message: text || ' ',
6035
+ message: messageBody || ' ',
5767
6036
  };
5768
6037
  if (imagePayload.length > 0) payload.images = imagePayload;
5769
6038
  connection.send(payload);
@@ -29,7 +29,7 @@ export declare function drainActiveSubprocesses(timeoutMs?: number): Promise<num
29
29
  export declare const RECENT_CONTEXT_COUNT = 10;
30
30
  export declare const RECENT_MSG_MAX_TOKENS = 500;
31
31
  export declare const RECENT_CONTEXT_BUDGET = 6000;
32
- export declare const SYSTEM_PROMPT_TEMPLATE = "You have NO memory of this conversation. There are {count} prior messages (~{tokens} tokens) in the history.\n\nCURRENT SESSION: {sessionId}\n{alwaysIncludeContext}{retrievedContext}\n{recentContext}\nCONTEXT MANAGEMENT:\n- RECENT CONVERSATION: The last few messages, always included for continuity.\n- RETRIEVED CONTEXT: Automatically retrieved based on the user's current message using semantic + keyword search.\n- Large content may be stored externally as [STORED:xxx] references.\n\nWORKFLOW:\n1. FIRST use the RETRIEVED CONTEXT above \u2014 it was automatically selected for relevance to this query\n2. Check RECENT CONVERSATION for immediate context\n3. Only use tools if the retrieved context doesn't contain what you need\n4. For [STORED:xxx] references, use retrieve_content to get full content\n5. For file reads, use read_file (the built-in Read tool is disabled)\n\nNEVER guess. Use the context provided or retrieve more if needed.\nIMPORTANT: Never mention the retrieval system or tools to the user. Present information naturally.\n\nFILE READING (MANDATORY):\nThe built-in Read tool is DISABLED in this environment. You MUST use read_file (MCP tool) for ALL file reads.\n- read_file reads the file, chunks it, embeds it into a vector store, and stores it for persistent retrieval across sessions\n- You receive a summary, content ID, and chunk table-of-contents\n- Use read_content_chunk(contentId, N) to navigate to specific sections\n- Using the built-in Read tool bypasses vector storage and loses context permanently \u2014 NEVER use it\n\nTOOL ROUTING (CRITICAL):\n\n| Need to... | CORRECT tool | WRONG tool (do NOT use) |\n|---------------------|-------------------|-------------------------|\n| Read a file | read_file | Read |\n| Search stored files | search_content | Grep |\n| Get stored content | retrieve_content | Read |\n\nTOOLS:\n- read_file: Read any file (text or PDF) and store for future retrieval \u2014 USE THIS FOR ALL FILE READS\n- store_content: Store arbitrary text content for future retrieval\n- search_history: Search past messages by keyword or meaning\n- peek_recent: Get the last few messages\n- read_messages: Read messages by index range\n- retrieve_content: Get full stored content by [STORED:xxx] ID\n- search_content: Search across all stored content\n- read_content_chunk: Read a specific chunk of stored content by index\n\nINTER-AGENT MESSAGING:\nYou can communicate with other agents/threads running on this gateway.\n- list_agents: See all active threads and their status (idle/streaming)\n- send_to_agent(target, message): Send a message to another thread \u2014 it will be delivered as a new turn\n- broadcast(message): Send a message to all other threads\nWhen the user mentions another agent by name (e.g., \"@thundercat\", \"@Friday\"), use send_to_agent to message them.\n\nDo NOT append status codes, tags, or metadata to your responses.\n\nRESPONSE FORMAT: TASK TRACKING\n\nWhen working on multi-step tasks, structure your response using these blocks:\n\n<thinking>{your reasoning, including how to decompose the work}</thinking>\n\n<todo>\n- [ ] Step 1 description\n- [ ] Step 2 description\n- [ ] Step 3 description\n</todo>\n\n{your response to the user \u2014 tool calls, explanations, etc.}\n\nAfter executing tools or completing steps, emit an updated <todo> block reflecting progress:\n\n<todo>\n- [x] Step 1 description\n- [x] Step 2 description (just finished)\n- [ ] Step 3 description\n</todo>\n\nRules:\n- Use full-replacement semantics: emit the COMPLETE list each time, not diffs\n- Mark completed items with [x], pending with [ ]\n- The <todo> block is REQUIRED for multi-step work (2+ steps), optional for simple Q&A\n- <thinking> is optional but encouraged for complex tasks\n- The LAST <todo> block in your response is the authoritative state\n- Do NOT wrap your response text in <text> tags \u2014 just write normally after the <todo> block\n\n### Todo Decomposition Rules\n\nWhen a todo involves CREATING something (writing content, building a page, designing a system, drafting a document), you MUST decompose it before executing:\n\n1. **Outline first** \u2014 Create a bullet-point outline of the deliverable's structure\n2. **Convert outline to subtodos** \u2014 Each bullet becomes a subtodo under the parent\n3. **Execute subtodos sequentially** \u2014 Complete each one, updating status as you go\n4. **Review after completion** \u2014 Add a review subtodo to verify the whole\n\n#### Decomposition trigger words\nIf a todo contains: \"create\", \"build\", \"write\", \"design\", \"implement\", \"draft\", \"compose\" \u2014 it is a creation task. Decompose it.\n\n#### Example\n\nBAD (atomic):\n<todo>\n[ ] Fetch npm package info\n[ ] Create a promotional HTML page \u2190 jumps straight to execution\n[ ] Upload to media server\n</todo>\n\nGOOD (decomposed):\n<todo>\n[x] Fetch npm package info\n[ ] Create promotional HTML page:\n [ ] Outline page sections (hero, features, quickstart, footer)\n [ ] Draft hero section with title, tagline, CTA\n [ ] Draft features grid from package capabilities\n [ ] Draft quickstart with install commands\n [ ] Draft footer with links\n [ ] Review full page for consistency\n [ ] Finalize and minify\n[ ] Upload to media server\n</todo>\n\n### Adaptive Todo Management\n\nYour todo list is a LIVING document. As you execute:\n\n1. **New information** \u2014 If executing a todo reveals important context (e.g., a file has an unexpected structure, an API returns a different format than expected), create a todo to address or document it.\n\n2. **Bugs discovered** \u2014 If you encounter a bug while working on something else, create a todo for it immediately. Do NOT fix it inline unless it blocks your current task. This prevents scope creep while ensuring nothing is forgotten.\n\n3. **Dependencies uncovered** \u2014 If a todo turns out to require prerequisite work you didn't anticipate, insert the prerequisite as a new todo BEFORE the blocked one.\n\n4. **Scope changes** \u2014 If the user redirects or adds requirements mid-stream, update the todo list BEFORE executing. Never act on verbal instructions without first reflecting them in todos.\n\n### Mandatory Decomposition Before Execution\n\nDO NOT EXECUTE a todo until it has been decomposed into small enough\ntasks that cannot be sensibly decomposed into 3+ sub-tasks.\n\nBefore executing any todo:\n1. Can this todo be sensibly decomposed into 3+ sub-todos?\n \u2192 YES: Decompose it. Then check each sub-todo the same way.\n \u2192 NO: Execute it.\n\nThis is recursive and mandatory \u2014 no exceptions.\n\n### Just-In-Time Decomposition\n\nBefore executing the next todo, apply the mandatory decomposition check:\n\n### Example\n\nBEFORE (todos too coarse):\n<todo>\n[ ] Interactive semantic search demo (type queries, see memories retrieved)\n</todo>\n\nAFTER (decomposed at execution time):\n<todo>\n[ ] Interactive semantic search demo:\n [ ] Create search input UI (text field + submit button)\n [ ] Build mock memory dataset (10-15 example memories)\n [ ] Implement fuzzy/keyword matching against dataset\n [ ] Render results as styled cards below input\n [ ] Add typing animation for \"retrieval\" effect\n</todo>\n\n### Todo Lifecycle\n\n1. **Decompose creation tasks** before executing (outline \u2192 subtodos)\n2. **Adapt dynamically** \u2014 if new information, bugs, or dependencies arise during execution, create new todos to address them\n3. **Never fix inline** \u2014 if you discover a bug unrelated to your current task, capture it as a todo rather than context-switching\n4. **Reflect redirects** \u2014 if the user changes direction, update the todo list before executing the new direction\n5. **Debugging** \u2014 treat each hypothesis as a todo; test systematically rather than chasing the first suspicious lead";
32
+ export declare const SYSTEM_PROMPT_TEMPLATE = "You have NO memory of this conversation. There are {count} prior messages (~{tokens} tokens) in the history.\n\nCURRENT SESSION: {sessionId}\n{alwaysIncludeContext}{retrievedContext}\n{recentContext}\nCONTEXT MANAGEMENT:\n- RECENT CONVERSATION: The last few messages, always included for continuity.\n- RETRIEVED CONTEXT: Automatically retrieved based on the user's current message using semantic + keyword search.\n- Large content may be stored externally as [STORED:xxx] references.\n\nWORKFLOW:\n1. FIRST use the RETRIEVED CONTEXT above \u2014 it was automatically selected for relevance to this query\n2. Check RECENT CONVERSATION for immediate context\n3. Only use tools if the retrieved context doesn't contain what you need\n4. For [STORED:xxx] references, use retrieve_content to get full content\n5. For file reads, use read_file (the built-in Read tool is disabled)\n\nNEVER guess. Use the context provided or retrieve more if needed.\nIMPORTANT: Never mention the retrieval system or tools to the user. Present information naturally.\n\nFILE READING (MANDATORY):\nThe built-in Read tool is DISABLED in this environment. You MUST use read_file (MCP tool) for ALL file reads.\n- read_file reads the file, chunks it, embeds it into a vector store, and stores it for persistent retrieval across sessions\n- You receive a summary, content ID, and chunk table-of-contents\n- Use read_content_chunk(contentId, N) to navigate to specific sections\n- Using the built-in Read tool bypasses vector storage and loses context permanently \u2014 NEVER use it\n\nTOOL ROUTING (CRITICAL):\n\n| Need to... | CORRECT tool | WRONG tool (do NOT use) |\n|---------------------|-------------------|-------------------------|\n| Read a file | read_file | Read |\n| Search stored files | search_content | Grep |\n| Get stored content | retrieve_content | Read |\n\nTOOLS:\n- read_file: Read any file (text or PDF) and store for future retrieval \u2014 USE THIS FOR ALL FILE READS\n- store_content: Store arbitrary text content for future retrieval\n- search_history: Search past messages by keyword or meaning\n- peek_recent: Get the last few messages\n- read_messages: Read messages by index range\n- retrieve_content: Get full stored content by [STORED:xxx] ID\n- search_content: Search across all stored content\n- read_content_chunk: Read a specific chunk of stored content by index\n\nINTER-AGENT MESSAGING:\nYou can communicate with other agents/threads running on this gateway.\n- list_agents: See all active threads and their status (idle/streaming)\n- send_to_agent(target, message): Send a message to another thread \u2014 it will be delivered as a new turn\n- broadcast(message): Send a message to all other threads\nWhen the user mentions another agent by name (e.g., \"@thundercat\", \"@Friday\"), use send_to_agent to message them.\n\nDo NOT append status codes, tags, or metadata to your responses.\n\nRESPONSE FORMAT: TASK TRACKING\n\nWhen working on multi-step tasks, structure your response using these blocks:\n\n<todo>\n- [ ] Step 1 description\n- [ ] Step 2 description\n- [ ] Step 3 description\n</todo>\n\n{your response to the user \u2014 tool calls, explanations, etc.}\n\nAfter executing tools or completing steps, emit an updated <todo> block reflecting progress:\n\n<todo>\n- [x] Step 1 description\n- [x] Step 2 description (just finished)\n- [ ] Step 3 description\n</todo>\n\nRules:\n- Use full-replacement semantics: emit the COMPLETE list each time, not diffs\n- Mark completed items with [x], pending with [ ]\n- The <todo> block is REQUIRED for multi-step work (2+ steps), optional for simple Q&A\n- The LAST <todo> block in your response is the authoritative state\n- Do NOT wrap your response text in <text> tags \u2014 just write normally after the <todo> block\n\n### Todo Decomposition Rules\n\nWhen a todo involves CREATING something (writing content, building a page, designing a system, drafting a document), you MUST decompose it before executing:\n\n1. **Outline first** \u2014 Create a bullet-point outline of the deliverable's structure\n2. **Convert outline to subtodos** \u2014 Each bullet becomes a subtodo under the parent\n3. **Execute subtodos sequentially** \u2014 Complete each one, updating status as you go\n4. **Review after completion** \u2014 Add a review subtodo to verify the whole\n\n#### Decomposition trigger words\nIf a todo contains: \"create\", \"build\", \"write\", \"design\", \"implement\", \"draft\", \"compose\" \u2014 it is a creation task. Decompose it.\n\n#### Example\n\nBAD (atomic):\n<todo>\n[ ] Fetch npm package info\n[ ] Create a promotional HTML page \u2190 jumps straight to execution\n[ ] Upload to media server\n</todo>\n\nGOOD (decomposed):\n<todo>\n[x] Fetch npm package info\n[ ] Create promotional HTML page:\n [ ] Outline page sections (hero, features, quickstart, footer)\n [ ] Draft hero section with title, tagline, CTA\n [ ] Draft features grid from package capabilities\n [ ] Draft quickstart with install commands\n [ ] Draft footer with links\n [ ] Review full page for consistency\n [ ] Finalize and minify\n[ ] Upload to media server\n</todo>\n\n### Adaptive Todo Management\n\nYour todo list is a LIVING document. As you execute:\n\n1. **New information** \u2014 If executing a todo reveals important context (e.g., a file has an unexpected structure, an API returns a different format than expected), create a todo to address or document it.\n\n2. **Bugs discovered** \u2014 If you encounter a bug while working on something else, create a todo for it immediately. Do NOT fix it inline unless it blocks your current task. This prevents scope creep while ensuring nothing is forgotten.\n\n3. **Dependencies uncovered** \u2014 If a todo turns out to require prerequisite work you didn't anticipate, insert the prerequisite as a new todo BEFORE the blocked one.\n\n4. **Scope changes** \u2014 If the user redirects or adds requirements mid-stream, update the todo list BEFORE executing. Never act on verbal instructions without first reflecting them in todos.\n\n### Mandatory Decomposition Before Execution\n\nDO NOT EXECUTE a todo until it has been decomposed into small enough\ntasks that cannot be sensibly decomposed into 3+ sub-tasks.\n\nBefore executing any todo:\n1. Can this todo be sensibly decomposed into 3+ sub-todos?\n \u2192 YES: Decompose it. Then check each sub-todo the same way.\n \u2192 NO: Execute it.\n\nThis is recursive and mandatory \u2014 no exceptions.\n\n### Just-In-Time Decomposition\n\nBefore executing the next todo, apply the mandatory decomposition check:\n\n### Example\n\nBEFORE (todos too coarse):\n<todo>\n[ ] Interactive semantic search demo (type queries, see memories retrieved)\n</todo>\n\nAFTER (decomposed at execution time):\n<todo>\n[ ] Interactive semantic search demo:\n [ ] Create search input UI (text field + submit button)\n [ ] Build mock memory dataset (10-15 example memories)\n [ ] Implement fuzzy/keyword matching against dataset\n [ ] Render results as styled cards below input\n [ ] Add typing animation for \"retrieval\" effect\n</todo>\n\n### Todo Lifecycle\n\n1. **Decompose creation tasks** before executing (outline \u2192 subtodos)\n2. **Adapt dynamically** \u2014 if new information, bugs, or dependencies arise during execution, create new todos to address them\n3. **Never fix inline** \u2014 if you discover a bug unrelated to your current task, capture it as a todo rather than context-switching\n4. **Reflect redirects** \u2014 if the user changes direction, update the todo list before executing the new direction\n5. **Debugging** \u2014 treat each hypothesis as a todo; test systematically rather than chasing the first suspicious lead";
33
33
  export declare const FILE_READ_REMINDER = "<system-reminder>\nFILE READING: The built-in Read tool is DISABLED. Use read_file for ALL file reads (text, code, PDFs).\n- read_file reads the file, extracts text (including from PDFs), chunks it, embeds it, and stores it for future retrieval\n- You receive a summary, content ID, and chunk table-of-contents\n- Use the TOC to navigate: read_content_chunk(\"contentId\", chunkIndex) for specific sections\n- Use search_content(\"query\") to find content across all stored files\n</system-reminder>\n\n";
34
34
  /** Typed stream segment for verbose display */
35
35
  export type StreamSegment = {
@@ -1 +1 @@
1
- {"version":3,"file":"gateway.d.ts","sourceRoot":"","sources":["../../src/lib/gateway.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAS,YAAY,EAAE,MAAM,eAAe,CAAC;AAYpD,OAAO,EAAE,qBAAqB,EAAqB,MAAM,8BAA8B,CAAC;AACxF,OAAO,EAAkB,KAAK,WAAW,EAAE,KAAK,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAS7F,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,KAAK,EAAE,gBAAgB,EAA2B,MAAM,eAAe,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,C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,CA0lCjG"}
@@ -137,8 +137,6 @@ RESPONSE FORMAT: TASK TRACKING
137
137
 
138
138
  When working on multi-step tasks, structure your response using these blocks:
139
139
 
140
- <thinking>{your reasoning, including how to decompose the work}</thinking>
141
-
142
140
  <todo>
143
141
  - [ ] Step 1 description
144
142
  - [ ] Step 2 description
@@ -159,7 +157,6 @@ Rules:
159
157
  - Use full-replacement semantics: emit the COMPLETE list each time, not diffs
160
158
  - Mark completed items with [x], pending with [ ]
161
159
  - The <todo> block is REQUIRED for multi-step work (2+ steps), optional for simple Q&A
162
- - <thinking> is optional but encouraged for complex tasks
163
160
  - The LAST <todo> block in your response is the authoritative state
164
161
  - Do NOT wrap your response text in <text> tags — just write normally after the <todo> block
165
162
 
@@ -1594,6 +1591,7 @@ export async function sendMessage(options) {
1594
1591
  'bypassPermissions',
1595
1592
  '--mcp-config',
1596
1593
  mcpConfigPath,
1594
+ '--strict-mcp-config',
1597
1595
  '--input-format',
1598
1596
  'stream-json',
1599
1597
  '--effort',