@luckydraw/cumulus 1.0.33 → 1.0.34

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/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.0.34
4
+
5
+ - Background jobs and scheduled tasks now show clearly as automated senders in chat
6
+
3
7
  ## v1.0.33
4
8
 
5
9
  Patch release. A third of the past-conversation context in every prompt was the same messages printed twice. Fixing it cuts retrieved-context size by a quarter on a real thread with no loss of recall.
@@ -486,6 +486,10 @@
486
486
  ' word-wrap: break-word;',
487
487
  ' border-left: 2px solid var(--agent-color, #9966cc);',
488
488
  '}',
489
+ /* Automated senders (task 173): a background job or a scheduled trigger is
490
+ inter-agent traffic, not the user talking — same bubble, dashed rule,
491
+ because unlike a peer thread it cannot be replied to. */
492
+ '.cumulus-msg.agent.automated { border-left-style: dashed; }',
489
493
  '.cumulus-agent-header {',
490
494
  ' display: flex; align-items: center; gap: 0.4em;',
491
495
  ' margin-bottom: 0.3em; font-size: 0.82em;',
@@ -2230,9 +2234,60 @@
2230
2234
  };
2231
2235
  }
2232
2236
 
2237
+ // Gateway-minted automated senders (task 173): a finished background job
2238
+ // (task 139) and a firing scheduled trigger (task 120). Both start a turn via
2239
+ // deliverAgentTurn, which applies none of send_to_agent's prefix, so both fell
2240
+ // through to the plain user bubble — the same defect AGENT_BATCH_RE already
2241
+ // fixed for the batched case. senders.ts names this class, but the identity is
2242
+ // not persisted onto the message, so content is the only signal here.
2243
+ var JOB_MSG_RE = /^\[background job (\S+) "(.*)"\]\s*/;
2244
+ var SCHEDULE_MSG_RE = /^\[Scheduled trigger: ([^\]]+)\]\s*/;
2245
+
2246
+ var AUTOMATED_OK_COLOR = '#5f8fa8';
2247
+ var AUTOMATED_WARN_COLOR = '#e69500';
2248
+ var AUTOMATED_BAD_COLOR = '#ff6b6b';
2249
+
2250
+ function jobOutcomeColor(outcome) {
2251
+ if (/^succeeded/.test(outcome)) return AUTOMATED_OK_COLOR;
2252
+ if (/^was (cancelled|INTERRUPTED)/.test(outcome)) return AUTOMATED_WARN_COLOR;
2253
+ return AUTOMATED_BAD_COLOR; // FAILED (exit n) / was killed by SIGxxx
2254
+ }
2255
+
2256
+ function parseAutomatedMessage(content) {
2257
+ var job = content.match(JOB_MSG_RE);
2258
+ if (job) {
2259
+ // Only the bracketed prefix is stripped; the outcome sentence stays in the
2260
+ // body, so the long "was INTERRUPTED — …" caveat cannot be lost to a
2261
+ // one-line header, and status is never carried by colour alone.
2262
+ var body = content.slice(job[0].length);
2263
+ return {
2264
+ sender: job[2].trim() || job[1],
2265
+ recipient: null,
2266
+ context: 'background job',
2267
+ color: jobOutcomeColor(body),
2268
+ automated: true,
2269
+ body: body.trim(),
2270
+ };
2271
+ }
2272
+ var sched = content.match(SCHEDULE_MSG_RE);
2273
+ if (sched) {
2274
+ return {
2275
+ sender: sched[1].trim(),
2276
+ recipient: null,
2277
+ context: 'scheduled trigger',
2278
+ color: AUTOMATED_OK_COLOR,
2279
+ automated: true,
2280
+ body: content.slice(sched[0].length).trim(),
2281
+ };
2282
+ }
2283
+ return null;
2284
+ }
2285
+
2233
2286
  function parseAgentMessage(content) {
2234
2287
  var batch = parseAgentBatchMessage(content);
2235
2288
  if (batch) return batch;
2289
+ var automated = parseAutomatedMessage(content);
2290
+ if (automated) return automated;
2236
2291
  var match = content.match(AGENT_MSG_RE);
2237
2292
  if (!match) return null;
2238
2293
  var body = content
@@ -2263,8 +2318,11 @@
2263
2318
 
2264
2319
  function buildAgentMsgEl(agent) {
2265
2320
  var el = document.createElement('div');
2266
- el.className = 'cumulus-msg agent';
2267
- el.style.setProperty('--agent-color', getAgentColor(agent.sender));
2321
+ // Automated senders reuse this bubble rather than getting a fourth one. Only
2322
+ // the border differs, and it says the one thing that differs: a peer thread
2323
+ // can be replied to, a script cannot (senders.ts isAutomatedSender).
2324
+ el.className = 'cumulus-msg agent' + (agent.automated ? ' automated' : '');
2325
+ el.style.setProperty('--agent-color', agent.color || getAgentColor(agent.sender));
2268
2326
 
2269
2327
  var header = document.createElement('div');
2270
2328
  header.className = 'cumulus-agent-header';
@@ -2274,10 +2332,13 @@
2274
2332
  header.appendChild(nameEl);
2275
2333
  var ctx = document.createElement('span');
2276
2334
  ctx.className = 'cumulus-agent-context';
2277
- // A drained batch names no recipient \u2014 it says how many arrived instead.
2278
- ctx.textContent = agent.recipient
2279
- ? '\u2192 ' + agent.recipient
2280
- : agent.batchCount + ' messages while busy';
2335
+ // A drained batch names no recipient \u2014 it says how many arrived instead;
2336
+ // an automated sender says what kind of thing it is (task 173).
2337
+ ctx.textContent = agent.context
2338
+ ? agent.context
2339
+ : agent.recipient
2340
+ ? '\u2192 ' + agent.recipient
2341
+ : agent.batchCount + ' messages while busy';
2281
2342
  header.appendChild(ctx);
2282
2343
  el.appendChild(header);
2283
2344
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luckydraw/cumulus",
3
- "version": "1.0.33",
3
+ "version": "1.0.34",
4
4
  "description": "RLM-based CLI chat wrapper for Claude with external history context management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",