Repository Public
1/**2 * What of the journal reaches the browser. A `model_call` step result carries `native`: the3 * provider-native assistant message(s) (thinking blocks with signatures, encrypted reasoning items),4 * kept so the worker can replay the transcript byte for byte. It is large and provider-internal: the5 * console only ever needs the normalised view (`blocks` — text, the reasoning SUMMARY, tool calls —6 * `stop`, `usage`, `model`). `native` is therefore removed from every step result and every7 * `step.completed` event before it is sent.8 */9import type { AosEvent } from '@aos/shared';1011const isObj = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v);1213export function stepResultForBrowser(kind: string, result: unknown): unknown {14 if (kind !== 'model_call' || !isObj(result) || !('native' in result)) return result;15 const { native: _native, ...rest } = result;16 void _native;17 return rest;18}1920export function eventForBrowser(ev: AosEvent): AosEvent {21 if (ev.kind !== 'step.completed' || ev.payload.kind !== 'model_call' || !isObj(ev.payload.result) || !('native' in ev.payload.result)) return ev;22 return { ...ev, payload: { ...ev.payload, result: stepResultForBrowser('model_call', ev.payload.result) } };23}24