Garry's Opinionated OpenClaw/Hermes Agent Brain
TypeScript
fix(wakeshift): pass Wakeshift's addition through whole (cap 16000, was 2000, which cut the listener step); cron wake names its finish time
garrytan8222e51fbaa6
diff --git a/src/core/wakeshift/events.ts b/src/core/wakeshift/events.tsindex 18adf4875c..d20eabda09 100644--- a/src/core/wakeshift/events.ts+++ b/src/core/wakeshift/events.ts@@ -193,6 +193,6 @@ export function cronWake(name: string, run: CronRun): { payload: Record<string,const next = `watch_cron ${name} to hear about its next run`;return {payload: { name, status: run.status, finished_at: iso(run.finished_at), next },- text: `gbrain: cron ${name} finished ${run.status === 'ok' ? 'ok' : 'with a failure'}. Read its output where it writes it; call watch_cron ${name} to hear about the next run.`,+ text: `gbrain: cron ${name} finished ${run.status === 'ok' ? 'ok' : 'with a failure'}${iso(run.finished_at) ? ` at ${iso(run.finished_at)!.slice(0, 16).replace('T', ' ')} UTC` : ''}. Read its output where it writes it; call watch_cron ${name} to hear about the next run.`,};}diff --git a/src/mcp/dispatch.ts b/src/mcp/dispatch.tsindex 2e077047ca..d5d03b7614 100644--- a/src/mcp/dispatch.ts+++ b/src/mcp/dispatch.ts@@ -819,7 +819,7 @@ type ToolTail = Parameters<NonNullable<OperationContext['emitToolTail']>>[0];* under gbrain's own keys, which it never replaces (a conversation credential: never logged).*/function appendToolTail(out: ToolResult, tail: ToolTail): void {- if (tail.text) out.content.push({ type: 'text', text: tail.text.slice(0, 2000) });+ if (tail.text) out.content.push({ type: 'text', text: tail.text.slice(0, 16_000) });if (tail.meta && typeof tail.meta === 'object') out._meta = { ...tail.meta, ...(out._meta ?? {}) };}diff --git a/test/wakeshift-client.test.ts b/test/wakeshift-client.test.tsindex a47a14eecf..d671783f43 100644--- a/test/wakeshift-client.test.ts+++ b/test/wakeshift-client.test.ts@@ -6,7 +6,7 @@import { describe, test, expect } from 'bun:test';import { createPublicKey, verify } from 'node:crypto';import { crc32, encodeWakeshiftKey, normalizeWakeshiftUrl, parseWakeshiftKey, wakeshiftAssertion, WakeshiftKeyError } from '../src/core/wakeshift/client.ts';-import { formatDuration, jobMarker, jobWake, wakeEmitId, wakeshiftManifest, JOB_FINISHED } from '../src/core/wakeshift/events.ts';+import { cronWake, formatDuration, jobMarker, jobWake, wakeEmitId, wakeshiftManifest, JOB_FINISHED } from '../src/core/wakeshift/events.ts';import { wakeshiftUserId } from '../src/core/wakeshift/config.ts';const SEED = Buffer.alloc(32, 7);@@ -86,6 +86,13 @@ describe('wakeshift events', () => {expect(jobWake(5, { ...job, id: 5, status: 'dead' }).text).toContain('is dead');});+ test('a cron wake says when the run finished, so the agent need not look it up', () => {+ const w = cronWake('nightly-example', { id: 3, status: 'ok', finished_at: '2026-11-06T08:58:58.900Z' });+ expect(w.text).toContain('nightly-example finished ok at 2026-11-06 08:58 UTC.');+ expect(cronWake('nightly-example', { id: 4, status: 'failed', finished_at: null }).text).toContain('finished with a failure.');+ expect(Buffer.byteLength(w.text)).toBeLessThan(1000);+ });+test('markers and emit ids differ per status, per run and per watcher', () => {const j = { id: 1, name: 'x', status: 'failed', started_at: null, finished_at: null, finished_us: '100' };expect(jobMarker(j)).toBe('100:failed');diff --git a/test/wakeshift.serial.test.ts b/test/wakeshift.serial.test.tsindex 8f7eb9023f..b5c6d1082e 100644--- a/test/wakeshift.serial.test.ts+++ b/test/wakeshift.serial.test.ts@@ -79,6 +79,20 @@ const emits = () => fake.calls.filter(c => c.path === '/events/emit');const body = (r: { content: Array<{ text: string }> }) => JSON.parse(r.content[0]!.text);describe('watch_job → completion → one pointer emit', () => {+ test('a real-sized addition (the notify question plus the listener command) reaches the agent whole; a runaway one is capped', async () => {+ const id = await seedJob('active');+ const real = 'Ask them one question. '.repeat(150) + 'Then start the Monitor with: ~/.wakeshift/bin/wakeshift wait --session claude-code#1';+ const subscribed = (text: string) => (b: { call: { user: string }; name: string; arguments: unknown }) => ({ status: 200, body: {+ event_subscription: { id: 'sub_big', user: b.call.user, event: b.name, arguments: b.arguments, created: true, expires_at: new Date(Date.now() + 86_400_000).toISOString() },+ addition: { text }, agent: { harness: 'claude-code', via: 'client', claimed: 'claude-code' } } });+ fake.respond.set('/event-subscriptions', subscribed(real));+ const r = await dispatchToolCall(engine, 'watch_job', { id, harness: 'claude-code' }, stdio);+ expect(real.length).toBeGreaterThan(3000);+ expect(r.content.at(-1)!.text).toBe(real);+ fake.respond.set('/event-subscriptions', subscribed('x'.repeat(100_000)));+ const capped = await dispatchToolCall(engine, 'watch_job', { id, harness: 'claude-code' }, stdio);+ expect(capped.content.at(-1)!.text.length).toBe(16_000);+ });test('subscribes the conversation, renders the addition last, and emits once with metadata only', async () => {const id = await seedJob('active');const r = await dispatchToolCall(engine, 'watch_job', { id, harness: 'claude-code' }, stdio);