@seed-ship/mcp-ui-solid 2.12.0 → 2.14.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.cjs","sources":["../../src/services/chat-bus.ts"],"sourcesContent":["/**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n"],"names":[],"mappings":";;AAmCO,SAAS,qBAAuC;AACrD,QAAM,gCAAgB,IAAA;AAOtB,WAAS,gBAAoD,IAAO,IAA4B;AAC9F,QAAI,WAAW;AACf,QAAI,QAA8C;AAClD,QAAI,WAAyB;AAC7B,QAAI,YAAY;AAEhB,UAAM,aAAa,IAAI,SAAgB;AACrC,UAAI,UAAW;AACf,iBAAW;AACX,YAAM,MAAM,KAAK,IAAA;AACjB,YAAM,YAAY,MAAM,MAAM;AAE9B,UAAI,aAAa,GAAG;AAClB,YAAI,OAAO;AAAE,uBAAa,KAAK;AAAG,kBAAQ;AAAA,QAAK;AAC/C,mBAAW;AACX,WAAG,GAAG,IAAI;AAAA,MACZ,WAAW,CAAC,OAAO;AACjB,gBAAQ,WAAW,MAAM;AACvB,qBAAW,KAAK,IAAA;AAChB,kBAAQ;AACR,cAAI,YAAY,CAAC,WAAW;AAC1B,gBAAI;AAAE,iBAAG,GAAG,QAAQ;AAAA,YAAE,SAAS,KAAK;AAAE,sBAAQ,MAAM,yCAAyC,GAAG;AAAA,YAAE;AAAA,UACpG;AAAA,QACF,GAAG,SAAS;AAAA,MACd;AAAA,IACF;AAEA,WAAO;AAAA,MACL,IAAI;AAAA,MACJ,QAAQ,MAAM;AAAE,oBAAY;AAAM,YAAI,OAAO;AAAE,uBAAa,KAAK;AAAG,kBAAQ;AAAA,QAAK;AAAA,MAAE;AAAA,IAAA;AAAA,EAEvF;AAEA,SAAO;AAAA,IACL,GAAG,OAAO,SAAS,SAAS;AAC1B,UAAI,CAAC,UAAU,IAAI,KAAe,G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AACZ,gBAAQ,KAAK,gDAAgD,OAAiB,EAAE;AAChF,eAAO;AAAA,MACT;AACA,aAAO,QAAQ,GAAG,IAAI;AAAA,IACxB;AAAA,EAAA;AAEJ;AAcO,SAAS,gBAAyB;AACvC,SAAO;AAAA,IACL,QAAQ,mBAAA;AAAA,IACR,UAAU,qBAAA;AAAA,EAAqB;AAEnC;;;;"}
1
+ {"version":3,"file":"chat-bus.cjs","sources":["../../src/services/chat-bus.ts"],"sourcesContent":["/**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n ScratchpadSection,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n\n// ─── Scratchpad Section Merge Helper ─────────────────────────\n\n/**\n * Merge sections from a ScratchpadEvent into existing state sections.\n * Handles replace/append/upsert modes.\n *\n * @example\n * const newSections = mergeScratchpadSections(\n * currentState.sections,\n * event.sections,\n * event.sectionMode\n * )\n */\nexport function mergeScratchpadSections(\n existing: ScratchpadSection[],\n incoming: ScratchpadSection[] | undefined,\n mode: 'replace' | 'append' | 'upsert' = 'replace'\n): ScratchpadSection[] {\n if (!incoming) return existing\n\n switch (mode) {\n case 'append':\n return [...existing, ...incoming]\n\n case 'upsert': {\n const result = [...existing]\n for (const section of incoming) {\n const idx = result.findIndex((s) => s.id === section.id)\n if (idx >= 0) {\n result[idx] = section\n } else {\n result.push(section)\n }\n }\n return result\n }\n\n case 'replace':\n default:\n return incoming\n }\n}\n"],"names":[],"mappings":";;AAoCO,SAAS,qBAAuC;AACrD,QAAM,gCAAgB,IAAA;AAOtB,WAAS,gBAAoD,IAAO,IAA4B;AAC9F,QAAI,WAAW;AACf,QAAI,QAA8C;AAClD,QAAI,WAAyB;AAC7B,QAAI,YAAY;AAEhB,UAAM,aAAa,IAAI,SAAgB;AACrC,UAAI,UAAW;AACf,iBAAW;AACX,YAAM,MAAM,KAAK,IAAA;AACjB,YAAM,YAAY,MAAM,MAAM;AAE9B,UAAI,aAAa,GAAG;AAClB,YAAI,OAAO;AAAE,uBAAa,KAAK;AA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O;AAAA,QACrB;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IAEA,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb;;;;;"}
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @experimental — This API may change without major bump until v2.5.0.
6
6
  */
7
- import type { ChatEventEmitter, ChatCommandHandler, ChatBus } from '../types/chat-bus';
7
+ import type { ChatEventEmitter, ChatCommandHandler, ChatBus, ScratchpadSection } from '../types/chat-bus';
8
8
  /**
9
9
  * Create a typed event emitter with throttle and streamKey filtering support.
10
10
  *
@@ -40,4 +40,16 @@ export declare function createCommandHandler(): ChatCommandHandler;
40
40
  * bus.commands.handle('sendPrompt', (text) => { ... })
41
41
  */
42
42
  export declare function createChatBus(): ChatBus;
43
+ /**
44
+ * Merge sections from a ScratchpadEvent into existing state sections.
45
+ * Handles replace/append/upsert modes.
46
+ *
47
+ * @example
48
+ * const newSections = mergeScratchpadSections(
49
+ * currentState.sections,
50
+ * event.sections,
51
+ * event.sectionMode
52
+ * )
53
+ */
54
+ export declare function mergeScratchpadSections(existing: ScratchpadSection[], incoming: ScratchpadSection[] | undefined, mode?: 'replace' | 'append' | 'upsert'): ScratchpadSection[];
43
55
  //# sourceMappingURL=chat-bus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.d.ts","sourceRoot":"","sources":["../../src/services/chat-bus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,EAER,MAAM,mBAAmB,CAAA;AAU1B;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAgGrD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CAiBzD;AAID;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC"}
1
+ {"version":3,"file":"chat-bus.d.ts","sourceRoot":"","sources":["../../src/services/chat-bus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAGV,gBAAgB,EAChB,kBAAkB,EAClB,OAAO,EAEP,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAU1B;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,IAAI,gBAAgB,CAgGrD;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,IAAI,kBAAkB,CAiBzD;AAID;;;;;;;;;GASG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAKvC;AAID;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,iBAAiB,EAAE,EAC7B,QAAQ,EAAE,iBAAiB,EAAE,GAAG,SAAS,EACzC,IAAI,GAAE,SAAS,GAAG,QAAQ,GAAG,QAAoB,GAChD,iBAAiB,EAAE,CAwBrB"}
@@ -110,9 +110,32 @@ function createChatBus() {
110
110
  commands: createCommandHandler()
111
111
  };
112
112
  }
113
+ function mergeScratchpadSections(existing, incoming, mode = "replace") {
114
+ if (!incoming) return existing;
115
+ switch (mode) {
116
+ case "append":
117
+ return [...existing, ...incoming];
118
+ case "upsert": {
119
+ const result = [...existing];
120
+ for (const section of incoming) {
121
+ const idx = result.findIndex((s) => s.id === section.id);
122
+ if (idx >= 0) {
123
+ result[idx] = section;
124
+ } else {
125
+ result.push(section);
126
+ }
127
+ }
128
+ return result;
129
+ }
130
+ case "replace":
131
+ default:
132
+ return incoming;
133
+ }
134
+ }
113
135
  export {
114
136
  createChatBus,
115
137
  createCommandHandler,
116
- createEventEmitter
138
+ createEventEmitter,
139
+ mergeScratchpadSections
117
140
  };
118
141
  //# sourceMappingURL=chat-bus.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.js","sources":["../../src/services/chat-bus.ts"],"sourcesContent":["/**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n"],"names":[],"mappings":"AAmCO,SAAS,qBAAuC;AACrD,QAAM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**\n * Chat Bus — Event Emitter + Command Handler\n * v2.4.0: Core primitives for the chat event/command bus\n *\n * @experimental — This API may change without major bump until v2.5.0.\n */\n\nimport type {\n ChatEvents,\n ChatCommands,\n ChatEventEmitter,\n ChatCommandHandler,\n ChatBus,\n EventSubscribeOptions,\n ScratchpadSection,\n} from '../types/chat-bus'\n\n// ─── Event Emitter ───────────────────────────────────────────\n\ninterface Listener<F extends (...args: any[]) => any> {\n handler: F\n options?: EventSubscribeOptions\n throttledHandler?: F\n}\n\n/**\n * Create a typed event emitter with throttle and streamKey filtering support.\n *\n * @experimental\n *\n * @example\n * const emitter = createEventEmitter<ChatEvents>()\n * const unsub = emitter.on('onToken', (event) => console.log(event.token), { throttle: 100 })\n * emitter.emit('onToken', { streamKey: 'abc', token: 'hello' })\n * unsub()\n */\nexport function createEventEmitter(): ChatEventEmitter {\n const listeners = new Map<string, Set<Listener<any>>>()\n\n interface ThrottledFn<F> {\n fn: F\n cancel: () => void\n }\n\n function createThrottled<F extends (...args: any[]) => void>(fn: F, ms: number): ThrottledFn<F> {\n let lastCall = 0\n let timer: ReturnType<typeof setTimeout> | null = null\n let lastArgs: any[] | null = null\n let cancelled = false\n\n const throttled = ((...args: any[]) => {\n if (cancelled) return\n lastArgs = args\n const now = Date.now()\n const remaining = ms - (now - lastCall)\n\n if (remaining <= 0) {\n if (timer) { clearTimeout(timer); timer = null }\n lastCall = now\n fn(...args)\n } else if (!timer) {\n timer = setTimeout(() => {\n lastCall = Date.now()\n timer = null\n if (lastArgs && !cancelled) {\n try { fn(...lastArgs) } catch (err) { console.error('[ChatBus] Error in throttled handler:', err) }\n }\n }, remaining)\n }\n }) as F\n\n return {\n fn: throttled,\n cancel: () => { cancelled = true; if (timer) { clearTimeout(timer); timer = null } },\n }\n }\n\n return {\n on(event, handler, options) {\n if (!listeners.has(event as string)) {\n listeners.set(event as string, new Set())\n }\n\n const listener: Listener<typeof handler> = { handler, options }\n\n // Apply throttle if requested\n let throttleHandle: ThrottledFn<typeof handler> | null = null\n if (options?.throttle && options.throttle > 0) {\n throttleHandle = createThrottled(handler, options.throttle)\n listener.throttledHandler = throttleHandle.fn\n }\n\n listeners.get(event as string)!.add(listener)\n\n // Return unsubscribe function — cancels pending throttle timers\n return () => {\n throttleHandle?.cancel()\n listeners.get(event as string)?.delete(listener)\n }\n },\n\n emit(event, ...args) {\n const set = listeners.get(event as string)\n if (!set) return\n\n for (const listener of set) {\n // StreamKey filtering: skip if listener wants a specific streamKey\n // For most events args[0] has streamKey; for onCustomEvent args[1] has it\n if (listener.options?.streamKey) {\n let streamKeyArg: unknown\n for (const arg of args) {\n if (arg && typeof arg === 'object' && 'streamKey' in (arg as any)) {\n streamKeyArg = (arg as any).streamKey\n break\n }\n }\n if (streamKeyArg !== undefined && streamKeyArg !== listener.options.streamKey) continue\n }\n\n const fn = listener.throttledHandler || listener.handler\n try {\n fn(...args)\n } catch (err) {\n console.error(`[ChatBus] Error in ${event as string} handler:`, err)\n }\n }\n },\n\n clear() {\n listeners.clear()\n },\n } as ChatEventEmitter\n}\n\n// ─── Command Handler ─────────────────────────────────────────\n\n/**\n * Create a typed command handler. The host app registers handlers,\n * agents execute commands.\n *\n * @experimental\n *\n * @example\n * const commands = createCommandHandler<ChatCommands>()\n * commands.handle('injectPrompt', (text) => setInputValue(text))\n * commands.exec('injectPrompt', 'Hello world')\n */\nexport function createCommandHandler(): ChatCommandHandler {\n const handlers = new Map<string, (...args: any[]) => any>()\n\n return {\n handle(command, handler) {\n handlers.set(command as string, handler)\n },\n\n exec(command, ...args) {\n const handler = handlers.get(command as string)\n if (!handler) {\n console.warn(`[ChatBus] No handler registered for command: ${command as string}`)\n return undefined as any\n }\n return handler(...args)\n },\n } as ChatCommandHandler\n}\n\n// ─── Chat Bus Factory ────────────────────────────────────────\n\n/**\n * Create a complete ChatBus with events + commands.\n *\n * @experimental\n *\n * @example\n * const bus = createChatBus()\n * bus.events.on('onStreamEnd', (event) => { ... })\n * bus.commands.handle('sendPrompt', (text) => { ... })\n */\nexport function createChatBus(): ChatBus {\n return {\n events: createEventEmitter(),\n commands: createCommandHandler(),\n }\n}\n\n// ─── Scratchpad Section Merge Helper ─────────────────────────\n\n/**\n * Merge sections from a ScratchpadEvent into existing state sections.\n * Handles replace/append/upsert modes.\n *\n * @example\n * const newSections = mergeScratchpadSections(\n * currentState.sections,\n * event.sections,\n * event.sectionMode\n * )\n */\nexport function mergeScratchpadSections(\n existing: ScratchpadSection[],\n incoming: ScratchpadSection[] | undefined,\n mode: 'replace' | 'append' | 'upsert' = 'replace'\n): ScratchpadSection[] {\n if (!incoming) return existing\n\n switch (mode) {\n case 'append':\n return [...existing, ...incoming]\n\n case 'upsert': {\n const result = [...existing]\n for (const section of incoming) {\n const idx = result.findIndex((s) => s.id === section.id)\n if (idx >= 0) {\n result[idx] = section\n } else {\n result.push(section)\n }\n }\n return result\n }\n\n case 'replace':\n default:\n return incoming\n }\n}\n"],"names":[],"mappings":"AAoCO,SAAS,qBAAuC;AACrD,QAAM,gCAAgB,IAAA;AAOtB,WAAS,gBAAoD,IAAO,IAA4B;AAC9F,QAAI,WAAW;AACf,QAAI,QAA8C;AAClD,QAAI,WAAyB;AAC7B,QAAI,YAAY;AAEhB,UAAM,aAAa,IAAI,SAAgB;AACrC,UAAI,UAAW;AACf,iBAAW;AACX,YAAM,MAAM,KAAK,IAAA;AACjB,YAAM,YAAY,MAAM,MAAM;AAE9B,UAAI,aAAa,GAAG;AAClB,YAAI,OAAO;AAAE,uBAAa,KAAK;AAAG,kBAAQ;AAAA,QAAK;AAC/C,mBAAW;AACX,WAAG,GAAG,IAAI;AAAA,MACZ,WAAW,CAAC,OAAO;AACjB,gBAAQ,WAAW,MAAM;AACvB,qBAAW,KAAK,IAAA;AAChB,kBAAQ;AACR,cAAI,YAAY,CAAC,WAAW;AAC1B,gBAAI;AAAE,iBAAG,GAAG,QAAQ;AAAA,YAAE,SAAS,KAAK;AAAE,sBAAQ,MAAM,yCAAyC,GAAG;AAAA,YAAE;AAA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AA,QACrE;AAAA,MACF;AAAA,IACF;AAAA,IAEA,QAAQ;AACN,gBAAU,MAAA;AAAA,IACZ;AAAA,EAAA;AAEJ;AAeO,SAAS,uBAA2C;AACzD,QAAM,+BAAe,IAAA;AAErB,SAAO;AAAA,IACL,OAAO,SAAS,SAAS;AACvB,eAAS,IAAI,SAAmB,OAAO;AAAA,IACzC;AAAA,IAEA,KAAK,YAAY,MAAM;AACrB,YAAM,UAAU,SAAS,IAAI,OAAiB;AAC9C,UAAI,CAAC,SAAS;AACZ,gBAAQ,KAAK,gDAAgD,OAAiB,EAAE;AAChF,eAAO;AAAA,MACT;AACA,aAAO,QAAQ,GAAG,IAAI;AAAA,IACxB;AAAA,EAAA;AAEJ;AAcO,SAAS,gBAAyB;AACvC,SAAO;AAAA,IACL,QAAQ,mBAAA;AAAA,IACR,UAAU,qBAAA;AAAA,EAAqB;AAEnC;AAeO,SAAS,wBACd,UACA,UACA,OAAwC,WACnB;AACrB,MAAI,CAAC,SAAU,QAAO;AAEtB,UAAQ,MAAA;AAAA,IACN,KAAK;AACH,aAAO,CAAC,GAAG,UAAU,GAAG,QAAQ;AAAA,IAElC,KAAK,UAAU;AACb,YAAM,SAAS,CAAC,GAAG,QAAQ;AAC3B,iBAAW,WAAW,UAAU;AAC9B,cAAM,MAAM,OAAO,UAAU,CAAC,MAAM,EAAE,OAAO,QAAQ,EAAE;AACvD,YAAI,OAAO,GAAG;AACZ,iBAAO,GAAG,IAAI;AAAA,QAChB,OAAO;AACL,iBAAO,KAAK,OAAO;AAAA,QACrB;AAAA,MACF;AACA,aAAO;AAAA,IACT;AAAA,IAEA,KAAK;AAAA,IACL;AACE,aAAO;AAAA,EAAA;AAEb;"}
@@ -5,5 +5,5 @@
5
5
  */
6
6
  export { validateComponent, validateLayout, validateIframeDomain, getIframeSandbox, DEFAULT_RESOURCE_LIMITS, DEFAULT_IFRAME_DOMAINS, TRUSTED_IFRAME_DOMAINS, } from './validation';
7
7
  export { ComponentRegistry } from './component-registry';
8
- export { createEventEmitter, createCommandHandler, createChatBus } from './chat-bus';
8
+ export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from './chat-bus';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,gBAAgB,EAChB,uBAAuB,EACvB,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,cAAc,CAAA;AAErB,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA"}
@@ -350,7 +350,7 @@ export interface ScratchpadState {
350
350
  export interface ScratchpadSection {
351
351
  id: string;
352
352
  title: string;
353
- type: 'data' | 'filter' | 'preview' | 'message' | 'action' | 'steps' | 'form' | 'understanding' | 'feedback' | 'prompt';
353
+ type: 'data' | 'filter' | 'preview' | 'message' | 'action' | 'steps' | 'form' | 'understanding' | 'feedback' | 'prompt' | 'stepper' | 'error' | 'source_card' | 'diff';
354
354
  content: unknown;
355
355
  /** Can the human edit this section? */
356
356
  editable: boolean;
@@ -366,6 +366,10 @@ export interface ScratchpadEvent {
366
366
  action: 'create' | 'update' | 'close';
367
367
  title?: string;
368
368
  sections?: ScratchpadSection[];
369
+ /** How to merge sections on update (default: 'replace') */
370
+ sectionMode?: 'replace' | 'append' | 'upsert';
371
+ /** If true, scratchpad stays visible during stream (no auto-close on complete) */
372
+ pinned?: boolean;
369
373
  filters?: Record<string, string | string[]>;
370
374
  preview?: {
371
375
  count: number;
@@ -1 +1 @@
1
- {"version":3,"file":"chat-bus.d.ts","sourceRoot":"","sources":["../../src/types/chat-bus.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAIpD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAA;IACjB,qCAAqC;IACrC,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,uBAAuB;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,+EAA+E;IAC/E,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAID;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IAEzB,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAC3D,aAAa,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAA;IAC7C,WAAW,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,QAAQ,EAAE,kBAAkB,CAAA;KAAE,KAAK,IAAI,CAAA;IAC9E,OAAO,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,KAAK,EAAE,SAAS,CAAA;KAAE,KAAK,IAAI,CAAA;IAG9D,UAAU,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,MAAM,EAAE,QAAQ,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,UAAU,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG;QAAE,QAAQ,EAAE,QAAQ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A;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CAAC,CAAA;IACF,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-ship/mcp-ui-solid",
3
- "version": "2.12.0",
3
+ "version": "2.14.0",
4
4
  "description": "SolidJS components for rendering MCP-generated UI resources",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -20,6 +20,10 @@ export interface ScratchpadPanelProps {
20
20
  /** Called when user clicks retry on error state */
21
21
  onRetry?: () => void
22
22
  onClose?: () => void
23
+ /** When true, action buttons show loading spinner and stay open until next server update */
24
+ asyncAction?: boolean
25
+ /** When true (set by server), scratchpad stays visible during stream */
26
+ pinned?: boolean
23
27
  closable?: boolean
24
28
  autoCloseDelay?: number
25
29
  collapsible?: boolean
@@ -28,7 +32,7 @@ export interface ScratchpadPanelProps {
28
32
 
29
33
  const STATUS_BADGES: Record<ScratchpadState['status'], { label: string; class: string }> = {
30
34
  loading: { label: 'Loading...', class: 'bg-yellow-100 text-yellow-700 dark:bg-yellow-900/30 dark:text-yellow-400' },
31
- ready: { label: 'Ready', class: 'bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400' },
35
+ ready: { label: 'Ready', class: 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400' },
32
36
  waiting_human: { label: 'Your turn', class: 'bg-blue-100 text-blue-700 dark:bg-blue-900/30 dark:text-blue-400 animate-pulse' },
33
37
  processing: { label: 'Processing...', class: 'bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400' },
34
38
  complete: { label: 'Complete', class: 'bg-green-100 text-green-600 dark:bg-green-900/30 dark:text-green-400' },
@@ -38,6 +42,7 @@ const STATUS_BADGES: Record<ScratchpadState['status'], { label: string; class: s
38
42
  export const ScratchpadPanel: Component<ScratchpadPanelProps> = (props) => {
39
43
  const [collapsed, setCollapsed] = createSignal(false)
40
44
  const [localPreview, setLocalPreview] = createSignal<ScratchpadState['preview']>(undefined)
45
+ const [loadingAction, setLoadingAction] = createSignal<string | null>(null)
41
46
  let previewTimer: ReturnType<typeof setTimeout> | null = null
42
47
  const badge = () => STATUS_BADGES[props.state.status] || STATUS_BADGES.loading
43
48
  const isClosable = () => props.closable !== false
@@ -45,12 +50,29 @@ export const ScratchpadPanel: Component<ScratchpadPanelProps> = (props) => {
45
50
  const preview = () => localPreview() || props.state.preview
46
51
  const hasFilters = () => Object.keys(props.state.filters || {}).length > 0
47
52
 
48
- // Auto-close on complete
53
+ // Action aliases that auto-close the scratchpad
54
+ const CLOSE_ALIASES = new Set(['done', 'close', 'dismiss', 'validate', 'cancel', 'sufficient'])
55
+
56
+ const handleAction = (action: string, data?: unknown) => {
57
+ if (props.asyncAction && !CLOSE_ALIASES.has(action)) {
58
+ setLoadingAction(action)
59
+ }
60
+ props.onAction?.(action, data)
61
+ if (CLOSE_ALIASES.has(action) && props.onClose) {
62
+ props.onClose()
63
+ }
64
+ }
65
+
66
+ // Auto-close on complete (unless pinned)
49
67
  createEffect(() => {
50
- if (props.state.status === 'complete' && props.autoCloseDelay) {
68
+ if (props.state.status === 'complete' && props.autoCloseDelay && !props.pinned) {
51
69
  const timer = setTimeout(() => props.onClose?.(), props.autoCloseDelay)
52
70
  onCleanup(() => clearTimeout(timer))
53
71
  }
72
+ // Clear loading action when server responds
73
+ if (props.state.status !== 'processing' && loadingAction()) {
74
+ setLoadingAction(null)
75
+ }
54
76
  })
55
77
 
56
78
  // Preview auto-refresh when filters change
@@ -144,7 +166,7 @@ export const ScratchpadPanel: Component<ScratchpadPanelProps> = (props) => {
144
166
  section={section}
145
167
  filters={props.state.filters}
146
168
  onFilterChange={props.onFilterChange}
147
- onAction={props.onAction}
169
+ onAction={handleAction}
148
170
  onSectionEdit={props.onSectionEdit}
149
171
  onSubmit={props.onSubmit}
150
172
  />
@@ -233,7 +255,7 @@ export const ScratchpadPanel: Component<ScratchpadPanelProps> = (props) => {
233
255
  <div class="px-4 py-3 border-t border-gray-100 dark:border-gray-700">
234
256
  <button
235
257
  type="button"
236
- onClick={() => props.onAction?.('search', { filters: props.state.filters })}
258
+ onClick={() => handleAction('search', { filters: props.state.filters })}
237
259
  class="w-full px-4 py-2.5 text-sm font-semibold rounded-lg text-white bg-blue-600 hover:bg-blue-700 transition-colors flex items-center justify-center gap-2"
238
260
  >
239
261
  <svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z" /></svg>
@@ -274,6 +296,10 @@ const SectionRenderer: Component<{
274
296
  <Match when={props.section.type === 'understanding'}><UnderstandingSection content={props.section.content} /></Match>
275
297
  <Match when={props.section.type === 'feedback'}><FeedbackSection content={props.section.content} onAction={props.onAction} /></Match>
276
298
  <Match when={props.section.type === 'prompt'}><PromptSection content={props.section.content} onAction={props.onAction} /></Match>
299
+ <Match when={props.section.type === 'stepper'}><StepperProgressSection content={props.section.content} /></Match>
300
+ <Match when={props.section.type === 'error'}><ErrorSectionRenderer content={props.section.content} onAction={props.onAction} /></Match>
301
+ <Match when={props.section.type === 'source_card'}><SourceCardSection content={props.section.content} /></Match>
302
+ <Match when={props.section.type === 'diff'}><DiffSection content={props.section.content} /></Match>
277
303
  <Match when={true}><pre class="text-xs text-gray-500 overflow-auto">{JSON.stringify(props.section.content, null, 2)}</pre></Match>
278
304
  </Switch>
279
305
  </div>
@@ -717,3 +743,186 @@ const PromptSection: Component<{
717
743
  </div>
718
744
  )
719
745
  }
746
+
747
+ // ─── Stepper Progress Section (multi-source) ─────────────────
748
+
749
+ const StepperProgressSection: Component<{ content: unknown }> = (props) => {
750
+ const data = () => {
751
+ const c = props.content as any
752
+ return {
753
+ steps: (c?.steps || []) as Array<{ id: string; label: string; status: string; summary?: string; duration_ms?: number }>,
754
+ orientation: c?.orientation || 'horizontal',
755
+ }
756
+ }
757
+
758
+ const statusIcon = (status: string) => {
759
+ switch (status) {
760
+ case 'done': return '✅'
761
+ case 'active': return '🔄'
762
+ case 'error': return '❌'
763
+ default: return '⏳'
764
+ }
765
+ }
766
+
767
+ const isHorizontal = () => data().orientation === 'horizontal'
768
+
769
+ return (
770
+ <Show when={isHorizontal()} fallback={
771
+ <div class="space-y-2">
772
+ <For each={data().steps}>
773
+ {(step) => (
774
+ <div class={`flex items-start gap-2 text-sm ${step.status === 'active' ? 'font-medium' : ''} ${step.status === 'pending' ? 'text-gray-400' : 'text-gray-700 dark:text-gray-300'}`}>
775
+ <span class="flex-shrink-0">{statusIcon(step.status)}</span>
776
+ <div>
777
+ <span>{step.label}</span>
778
+ <Show when={step.summary}>
779
+ <span class="ml-1 text-xs text-gray-500 dark:text-gray-400">— {step.summary}</span>
780
+ </Show>
781
+ <Show when={step.duration_ms}>
782
+ <span class="ml-1 text-xs text-gray-400">({step.duration_ms}ms)</span>
783
+ </Show>
784
+ </div>
785
+ </div>
786
+ )}
787
+ </For>
788
+ </div>
789
+ }>
790
+ <div class="flex items-center gap-1 flex-wrap">
791
+ <For each={data().steps}>
792
+ {(step, i) => (
793
+ <>
794
+ <Show when={i() > 0}>
795
+ <svg class="w-3 h-3 text-gray-300 dark:text-gray-600 flex-shrink-0" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" /></svg>
796
+ </Show>
797
+ <div class={`flex items-center gap-1 px-2 py-1 rounded text-xs ${
798
+ step.status === 'done' ? 'bg-green-50 dark:bg-green-900/20 text-green-700 dark:text-green-400'
799
+ : step.status === 'active' ? 'bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-400 font-medium'
800
+ : step.status === 'error' ? 'bg-red-50 dark:bg-red-900/20 text-red-700 dark:text-red-400'
801
+ : 'text-gray-400'
802
+ }`}>
803
+ <span>{statusIcon(step.status)}</span>
804
+ <span>{step.label}</span>
805
+ <Show when={step.summary}>
806
+ <span class="text-[10px] opacity-75">{step.summary}</span>
807
+ </Show>
808
+ </div>
809
+ </>
810
+ )}
811
+ </For>
812
+ </div>
813
+ </Show>
814
+ )
815
+ }
816
+
817
+ // ─── Error Section (F6) ──────────────────────────────────────
818
+
819
+ const ErrorSectionRenderer: Component<{
820
+ content: unknown
821
+ onAction?: (action: string, data?: unknown) => void
822
+ }> = (props) => {
823
+ const [showDetails, setShowDetails] = createSignal(false)
824
+ const data = () => {
825
+ const c = props.content as any
826
+ return { message: c?.message || 'Error', severity: c?.severity || 'error', retryAction: c?.retryAction, retryLabel: c?.retryLabel || 'Retry', details: c?.details, timestamp: c?.timestamp }
827
+ }
828
+ const isWarning = () => data().severity === 'warning'
829
+
830
+ return (
831
+ <div class={`rounded-lg px-3 py-2 text-sm ${isWarning() ? 'bg-amber-50 dark:bg-amber-900/10 text-amber-700 dark:text-amber-400 border border-amber-200 dark:border-amber-800' : 'bg-red-50 dark:bg-red-900/10 text-red-700 dark:text-red-400 border border-red-200 dark:border-red-800'}`}>
832
+ <div class="flex items-start gap-2">
833
+ <span class="flex-shrink-0">{isWarning() ? '⚠️' : '❌'}</span>
834
+ <div class="flex-1">
835
+ <p>{data().message}</p>
836
+ <div class="flex gap-2 mt-2">
837
+ <Show when={data().retryAction}>
838
+ <button type="button" onClick={() => props.onAction?.(data().retryAction!)} class={`px-2 py-1 text-xs font-medium rounded ${isWarning() ? 'bg-amber-600 text-white hover:bg-amber-700' : 'bg-red-600 text-white hover:bg-red-700'} transition-colors`}>&#128260; {data().retryLabel}</button>
839
+ </Show>
840
+ <Show when={data().details}>
841
+ <button type="button" onClick={() => setShowDetails(!showDetails())} class="px-2 py-1 text-xs opacity-70 hover:opacity-100">&#9654; Details</button>
842
+ </Show>
843
+ </div>
844
+ <Show when={showDetails() && data().details}>
845
+ <pre class="mt-2 text-xs opacity-70 overflow-x-auto">{data().details}</pre>
846
+ </Show>
847
+ </div>
848
+ </div>
849
+ </div>
850
+ )
851
+ }
852
+
853
+ // ─── Source Card Section (F9) ────────────────────────────────
854
+
855
+ const SourceCardSection: Component<{ content: unknown }> = (props) => {
856
+ const data = () => {
857
+ const c = props.content as any
858
+ return { name: c?.name || 'Source', status: c?.status || 'available', capabilities: c?.capabilities || [], latency_ms: c?.latency_ms, freshness: c?.freshness, row_count: c?.row_count }
859
+ }
860
+ const statusIcon = () => ({ queried: '✅', available: '📦', error: '❌' } as Record<string, string>)[data().status] || '📦'
861
+
862
+ return (
863
+ <div class="rounded-lg border border-gray-200 dark:border-gray-700 px-3 py-2">
864
+ <div class="flex items-center justify-between mb-1.5">
865
+ <span class="text-sm font-medium text-gray-900 dark:text-white">{statusIcon()} {data().name}</span>
866
+ <Show when={data().row_count !== undefined}>
867
+ <span class="text-xs font-bold text-blue-600 dark:text-blue-400">{data().row_count?.toLocaleString()} results</span>
868
+ </Show>
869
+ </div>
870
+ <div class="flex flex-wrap gap-1.5 mb-1">
871
+ <For each={data().capabilities}>
872
+ {(cap: any) => (
873
+ <span class={`text-[10px] px-1.5 py-0.5 rounded ${cap.supported ? 'bg-green-100 dark:bg-green-900/30 text-green-700 dark:text-green-400' : 'bg-red-100 dark:bg-red-900/30 text-red-600 dark:text-red-400'}`}>
874
+ {cap.supported ? '✅' : '❌'} {cap.label}
875
+ </span>
876
+ )}
877
+ </For>
878
+ </div>
879
+ <Show when={data().freshness || data().latency_ms}>
880
+ <p class="text-[10px] text-gray-400">{[data().freshness, data().latency_ms ? `${data().latency_ms}ms` : ''].filter(Boolean).join(' · ')}</p>
881
+ </Show>
882
+ </div>
883
+ )
884
+ }
885
+
886
+ // ─── Diff Section (F10) ──────────────────────────────────────
887
+
888
+ const DiffSection: Component<{ content: unknown }> = (props) => {
889
+ const data = () => {
890
+ const c = props.content as any
891
+ return { left: c?.left || { label: 'A', rows: [] }, right: c?.right || { label: 'B', rows: [] }, highlight: c?.highlight_columns || [] }
892
+ }
893
+ const allKeys = () => {
894
+ const l = data().left.rows[0] || {}
895
+ const r = data().right.rows[0] || {}
896
+ return [...new Set([...Object.keys(l), ...Object.keys(r)])]
897
+ }
898
+
899
+ return (
900
+ <div class="overflow-x-auto">
901
+ <table class="min-w-full text-xs">
902
+ <thead>
903
+ <tr>
904
+ <th class="px-2 py-1 text-left text-gray-500 dark:text-gray-400"></th>
905
+ <th class="px-2 py-1 text-left font-medium text-blue-600 dark:text-blue-400">{data().left.label}</th>
906
+ <th class="px-2 py-1 text-left font-medium text-purple-600 dark:text-purple-400">{data().right.label}</th>
907
+ </tr>
908
+ </thead>
909
+ <tbody>
910
+ <For each={allKeys()}>
911
+ {(key) => {
912
+ const lVal = () => data().left.rows[0]?.[key]
913
+ const rVal = () => data().right.rows[0]?.[key]
914
+ const isDiff = () => String(lVal()) !== String(rVal()) && data().highlight.includes(key)
915
+ return (
916
+ <tr class={`border-t border-gray-100 dark:border-gray-700 ${isDiff() ? 'bg-yellow-50 dark:bg-yellow-900/10' : ''}`}>
917
+ <td class="px-2 py-1 font-mono text-gray-500 dark:text-gray-400">{key}</td>
918
+ <td class="px-2 py-1 text-gray-900 dark:text-white">{lVal() !== undefined ? String(lVal()) : '—'}</td>
919
+ <td class="px-2 py-1 text-gray-900 dark:text-white">{rVal() !== undefined ? String(rVal()) : '—'}</td>
920
+ </tr>
921
+ )
922
+ }}
923
+ </For>
924
+ </tbody>
925
+ </table>
926
+ </div>
927
+ )
928
+ }
package/src/index.ts CHANGED
@@ -215,6 +215,7 @@ export {
215
215
  createEventEmitter,
216
216
  createCommandHandler,
217
217
  createChatBus,
218
+ mergeScratchpadSections,
218
219
  } from './services'
219
220
 
220
221
  // Chat Bus Types (v2.4.0 — @experimental)
@@ -12,6 +12,7 @@ import type {
12
12
  ChatCommandHandler,
13
13
  ChatBus,
14
14
  EventSubscribeOptions,
15
+ ScratchpadSection,
15
16
  } from '../types/chat-bus'
16
17
 
17
18
  // ─── Event Emitter ───────────────────────────────────────────
@@ -181,3 +182,46 @@ export function createChatBus(): ChatBus {
181
182
  commands: createCommandHandler(),
182
183
  }
183
184
  }
185
+
186
+ // ─── Scratchpad Section Merge Helper ─────────────────────────
187
+
188
+ /**
189
+ * Merge sections from a ScratchpadEvent into existing state sections.
190
+ * Handles replace/append/upsert modes.
191
+ *
192
+ * @example
193
+ * const newSections = mergeScratchpadSections(
194
+ * currentState.sections,
195
+ * event.sections,
196
+ * event.sectionMode
197
+ * )
198
+ */
199
+ export function mergeScratchpadSections(
200
+ existing: ScratchpadSection[],
201
+ incoming: ScratchpadSection[] | undefined,
202
+ mode: 'replace' | 'append' | 'upsert' = 'replace'
203
+ ): ScratchpadSection[] {
204
+ if (!incoming) return existing
205
+
206
+ switch (mode) {
207
+ case 'append':
208
+ return [...existing, ...incoming]
209
+
210
+ case 'upsert': {
211
+ const result = [...existing]
212
+ for (const section of incoming) {
213
+ const idx = result.findIndex((s) => s.id === section.id)
214
+ if (idx >= 0) {
215
+ result[idx] = section
216
+ } else {
217
+ result.push(section)
218
+ }
219
+ }
220
+ return result
221
+ }
222
+
223
+ case 'replace':
224
+ default:
225
+ return incoming
226
+ }
227
+ }
@@ -16,4 +16,4 @@ export {
16
16
 
17
17
  export { ComponentRegistry } from './component-registry'
18
18
 
19
- export { createEventEmitter, createCommandHandler, createChatBus } from './chat-bus'
19
+ export { createEventEmitter, createCommandHandler, createChatBus, mergeScratchpadSections } from './chat-bus'
@@ -366,7 +366,7 @@ export interface ScratchpadState {
366
366
  export interface ScratchpadSection {
367
367
  id: string
368
368
  title: string
369
- type: 'data' | 'filter' | 'preview' | 'message' | 'action' | 'steps' | 'form' | 'understanding' | 'feedback' | 'prompt'
369
+ type: 'data' | 'filter' | 'preview' | 'message' | 'action' | 'steps' | 'form' | 'understanding' | 'feedback' | 'prompt' | 'stepper' | 'error' | 'source_card' | 'diff'
370
370
  content: unknown
371
371
  /** Can the human edit this section? */
372
372
  editable: boolean
@@ -383,6 +383,10 @@ export interface ScratchpadEvent {
383
383
  action: 'create' | 'update' | 'close'
384
384
  title?: string
385
385
  sections?: ScratchpadSection[]
386
+ /** How to merge sections on update (default: 'replace') */
387
+ sectionMode?: 'replace' | 'append' | 'upsert'
388
+ /** If true, scratchpad stays visible during stream (no auto-close on complete) */
389
+ pinned?: boolean
386
390
  filters?: Record<string, string | string[]>
387
391
  preview?: { count: number; rows?: Record<string, unknown>[]; summary: string }
388
392
  agentMessages?: Array<{ text: string; type: 'info' | 'question' | 'warning' }>