juneau 0.3.4 → 0.4.1

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.
Files changed (36) hide show
  1. package/README.md +64 -2
  2. package/dist/adapters/dashboardAdapter.d.ts.map +1 -1
  3. package/dist/adapters/mockAdapter.d.ts.map +1 -1
  4. package/dist/components/AiChat/AiChat.d.ts +8 -1
  5. package/dist/components/AiChat/AiChat.d.ts.map +1 -1
  6. package/dist/components/AiInput/AiInput.d.ts.map +1 -1
  7. package/dist/components/AiMessageBubble/AiMessageBubble.d.ts +4 -1
  8. package/dist/components/AiMessageBubble/AiMessageBubble.d.ts.map +1 -1
  9. package/dist/components/AiMessageList/AiMessageList.d.ts +4 -1
  10. package/dist/components/AiMessageList/AiMessageList.d.ts.map +1 -1
  11. package/dist/components/AiSidebar/AiSidebar.d.ts +8 -1
  12. package/dist/components/AiSidebar/AiSidebar.d.ts.map +1 -1
  13. package/dist/components/parts/AiMessagePartRenderer.d.ts +11 -1
  14. package/dist/components/parts/AiMessagePartRenderer.d.ts.map +1 -1
  15. package/dist/core/types.d.ts +14 -4
  16. package/dist/core/types.d.ts.map +1 -1
  17. package/dist/index.cjs +28 -28
  18. package/dist/index.cjs.map +1 -1
  19. package/dist/index.d.ts +3 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +2769 -2743
  22. package/dist/index.js.map +1 -1
  23. package/dist/server/createSkillSet.d.ts +0 -6
  24. package/dist/server/createSkillSet.d.ts.map +1 -1
  25. package/dist/server/index.cjs +9 -6
  26. package/dist/server/index.cjs.map +1 -1
  27. package/dist/server/index.d.ts +2 -1
  28. package/dist/server/index.d.ts.map +1 -1
  29. package/dist/server/index.js +156 -123
  30. package/dist/server/index.js.map +1 -1
  31. package/dist/server/skillIndex.d.ts +25 -0
  32. package/dist/server/skillIndex.d.ts.map +1 -0
  33. package/dist/server/types.d.ts +45 -2
  34. package/dist/server/types.d.ts.map +1 -1
  35. package/dist/style.css +1 -1
  36. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/server/toSdkMessages.ts","../../src/server/createSkillSet.ts","../../src/server/streamToWire.ts","../../src/server/withToolRecovery.ts"],"sourcesContent":["import type { AiMessage } from '../core/types';\r\nimport type { CoreMessage } from './types';\r\n\r\n/**\r\n * Converts Juneau's AiMessage[] to the CoreMessage[] format expected by\r\n * ai-sdk's generateText / streamText.\r\n *\r\n * - Extracts plain text from parts (joins all type: \"text\" parts)\r\n * - Replaces activity-only assistant messages with an empty assistant turn\r\n * so conversation alternation stays valid\r\n * - Injects a placeholder assistant turn between consecutive user messages\r\n * - Filters out empty turns (unless they are a required alternation filler)\r\n */\r\nexport function toSdkMessages(messages: AiMessage[]): CoreMessage[] {\r\n // First pass: map each AiMessage to a CoreMessage, replacing activity-only\r\n // assistant messages with an empty-text assistant turn.\r\n const mapped: CoreMessage[] = messages.map(msg => {\r\n const text = msg.parts\r\n .filter(p => p.type === 'text')\r\n .map(p => (p as { type: 'text'; text: string }).text)\r\n .join('');\r\n\r\n return { role: msg.role as CoreMessage['role'], content: text };\r\n });\r\n\r\n // Second pass: inject a placeholder assistant turn between consecutive user\r\n // messages as a safety net for history bugs that would cause model errors.\r\n const result: CoreMessage[] = [];\r\n for (let i = 0; i < mapped.length; i++) {\r\n const current = mapped[i];\r\n const prev = result[result.length - 1];\r\n\r\n if (current.role === 'user' && prev?.role === 'user') {\r\n result.push({ role: 'assistant', content: '…' });\r\n }\r\n\r\n result.push(current);\r\n }\r\n\r\n // Third pass: filter out empty turns, but keep assistant placeholders that\r\n // serve as alternation fillers (they have content '…' set above, so they\r\n // won't be filtered). Only drop genuinely empty content strings.\r\n return result.filter(msg => msg.content.length > 0);\r\n}\r\n","import type { ZodType } from 'zod';\nimport type { SkillDefinition, SkillSet, SkillSetOptions } from './types';\n\ntype SkillMap = Record<string, SkillDefinition<ZodType>>;\n\nfunction formatActivityEvent(event: Record<string, unknown>): string {\n return `data: ${JSON.stringify(event)}\\n\\n`;\n}\n\nfunction pickLabel(labels: { cs: string; en: string }, language: string): string {\n return (labels as Record<string, string>)[language] ?? labels.en;\n}\n\n/**\n * Takes a map of skill definitions and returns a SkillSet containing:\n * - tools: ready-made tool definitions for ai-sdk's streamText({ tools })\n * - drainActivities(): flush buffered activity wire SSE strings\n * - hadFailure / failureContext: for driving tool failure recovery\n */\nexport function createSkillSet(skills: SkillMap, options: SkillSetOptions = {}): SkillSet {\n const language = options.language ?? 'en';\n const debug = options.debug ?? false;\n const activityBuffer: string[] = [];\n let hadFailure = false;\n let failureContext: string | null = null;\n\n const tools: Record<string, unknown> = {};\n\n for (const [name, skill] of Object.entries(skills)) {\n tools[name] = {\n description: skill.description,\n parameters: skill.input,\n execute: async (input: unknown) => {\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → executing, input:`, input);\n }\n\n const startMs = debug ? Date.now() : 0;\n\n // Emit a \"running\" activity event into the buffer\n activityBuffer.push(\n formatActivityEvent({\n type: 'activity',\n id: name,\n title: pickLabel(skill.labels.running, language),\n status: 'running',\n metadata: { skill: name },\n })\n );\n\n try {\n const result = await skill.execute(input as never);\n\n const durationMs = debug ? Date.now() - startMs : 0;\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → done in ${durationMs}ms, result:`, result);\n }\n\n // Emit a \"done\" activity event\n activityBuffer.push(\n formatActivityEvent({\n type: 'activity',\n id: name,\n title: pickLabel(skill.labels.done, language),\n status: 'done',\n metadata: { skill: name },\n })\n );\n\n return result;\n } catch (err) {\n const durationMs = debug ? Date.now() - startMs : 0;\n const message = err instanceof Error ? err.message : String(err);\n\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → FAILED in ${durationMs}ms: \"${message}\"`);\n }\n\n const failedLabels = skill.labels.failed ?? { cs: 'Nepodařilo se', en: 'Failed' };\n\n // Emit a \"failed\" activity event\n activityBuffer.push(\n formatActivityEvent({\n type: 'activity',\n id: name,\n title: pickLabel(failedLabels, language),\n status: 'failed',\n metadata: { skill: name },\n })\n );\n\n hadFailure = true;\n failureContext = `Tool \"${name}\" failed: ${message}`;\n\n // Re-throw so ai-sdk knows the tool call failed\n throw err;\n }\n },\n };\n }\n\n return {\n tools,\n\n drainActivities(): string[] {\n return activityBuffer.splice(0, activityBuffer.length);\n },\n\n get hadFailure() {\n return hadFailure;\n },\n\n get failureContext() {\n return failureContext;\n },\n };\n}\n","import type { SkillSet, StreamToWireOptions } from './types';\n\n// ai-sdk v7 chunk types that carry the model's text output.\n// - 'text-delta': standard streaming text (v6 + v7)\n// - 'text': emitted by some v7 model/provider combos as a completed text chunk\n// Both may appear in the same stream; we handle either.\nconst TEXT_CHUNK_TYPES = new Set(['text-delta', 'text']);\n\n// Chunk types we recognise but intentionally ignore — activities are driven by\n// the SkillSet execute fn, not by these wire events.\nconst IGNORED_CHUNK_TYPES = new Set([\n 'tool-call',\n 'tool-result',\n 'tool-input-start',\n 'tool-input-delta',\n 'tool-input-available',\n 'tool-output-available',\n 'step-start',\n 'finish-step',\n 'start',\n 'finish',\n 'response-metadata',\n 'stream-start',\n]);\n\n/**\n * Converts ai-sdk's fullStream AsyncIterable into Juneau wire SSE strings.\n *\n * Handles:\n * - All text chunk types used by ai-sdk v7 (text-delta, text) incl. v6 textDelta fallback\n * - Flushing skillSet.drainActivities() before each text chunk so activities\n * always appear before the text they precede\n * - A final drain after the loop ends (catches last-tool-call activities when\n * no text follows the tool result — the Gemini silent-response scenario)\n * - Emitting the done event when the stream finishes\n * - Structured debug logging of every chunk when options.debug is true\n */\nexport async function* streamToWire(\n fullStream: AsyncIterable<unknown>,\n skillSet?: SkillSet,\n options?: StreamToWireOptions\n): AsyncIterable<string> {\n const debug = options?.debug ?? false;\n\n for await (const chunk of fullStream) {\n const c = chunk as Record<string, unknown>;\n const type = c.type as string | undefined;\n\n if (debug) {\n if (type && TEXT_CHUNK_TYPES.has(type)) {\n const text = (c.text ?? c.textDelta) as string | undefined;\n console.debug(`[juneau] streamToWire chunk: ${type} ${JSON.stringify(text ?? '')}`);\n } else if (type === 'tool-call') {\n console.debug(`[juneau] streamToWire chunk: tool-call \"${c.toolName ?? c.name ?? '?'}\"`);\n } else if (type === 'tool-result') {\n console.debug(`[juneau] streamToWire chunk: tool-result (ignored)`);\n } else if (type) {\n if (IGNORED_CHUNK_TYPES.has(type)) {\n console.debug(`[juneau] streamToWire chunk: ${type} (ignored)`);\n } else {\n console.debug(`[juneau] streamToWire chunk: ${type} (unknown)`);\n }\n }\n }\n\n if (type && TEXT_CHUNK_TYPES.has(type)) {\n // Flush any buffered activity events before emitting text so the UI\n // shows running/done indicators before the model's reply appears.\n if (skillSet) {\n const activities = skillSet.drainActivities();\n if (debug && activities.length > 0) {\n console.debug(`[juneau] streamToWire → draining ${activities.length} activities`);\n }\n for (const event of activities) {\n yield event;\n }\n }\n\n // ai-sdk v7 uses `text`, v6 used `textDelta` — support both\n const text = (c.text ?? c.textDelta) as string | undefined;\n if (text) {\n if (debug) {\n console.debug(`[juneau] streamToWire → yielding text ${JSON.stringify(text)}`);\n }\n yield `data: ${JSON.stringify({ type: 'text', text })}\\n\\n`;\n }\n }\n\n // All other chunk types are intentionally silent — the SkillSet execute fn\n // emits activity events into its buffer which we drain above.\n }\n\n // Final drain — catches activity events from the last tool call when no\n // text-delta followed (Gemini sometimes calls a tool successfully but emits\n // the reply text in a subsequent step that never arrives as text-delta here).\n if (skillSet) {\n const remaining = skillSet.drainActivities();\n if (debug && remaining.length > 0) {\n console.debug(`[juneau] streamToWire → draining ${remaining.length} activities (end of stream)`);\n }\n for (const event of remaining) {\n yield event;\n }\n }\n\n if (debug) {\n console.debug('[juneau] streamToWire → end of stream, emitting done');\n }\n\n yield `data: ${JSON.stringify({ type: 'done' })}\\n\\n`;\n}\n","import type { ToolRecoveryOptions } from './types';\nimport { streamToWire } from './streamToWire';\n\nfunction wireError(message: string): string {\n return `data: ${JSON.stringify({ type: 'error', message })}\\n\\n`;\n}\n\nfunction wireDone(): string {\n return `data: ${JSON.stringify({ type: 'done' })}\\n\\n`;\n}\n\n/**\n * Encapsulates the multi-phase streaming pattern needed for Gemini 2.5 Flash\n * tool call scenarios where the model either fails or silently succeeds without\n * emitting any text in the same stream pass.\n *\n * Phase 1: Stream with tools. Collect whether any text was produced and whether\n * a tool failure occurred.\n *\n * Phase 2 (failure recovery) — triggers when a tool failed AND no text was produced:\n * - Injects failureContext as an assistant message so the model is forced to\n * write a recovery text response (no tools available in phase 2).\n *\n * Phase 3 (silent-success recovery) — triggers when the tool succeeded but the\n * model wrote no text. Confirmed Gemini 2.5 Flash behaviour: the fullStream ends\n * with tool-call → tool-result → finish-step → finish and no text-delta ever\n * arrives — Gemini treats the tool call as its complete response. Phase 3 receives\n * the full phase 1 message history including tool-call AND tool-result turns —\n * Gemini rejects histories where a tool-call turn is not immediately followed by\n * a tool-result turn (\"function call turn must come immediately after a user turn\n * or after a function response turn\"). The history is resolved from the consumed\n * phase 1 result's `messages` promise (ai-sdk v7 — resolves to all turns after\n * the stream is consumed), with `response.messages` as fallback.\n * If phase3 is not provided, falls back to emitting done (previous behaviour).\n *\n * Errors thrown by phase 2 / phase 3 model calls are surfaced as wire error\n * events — never swallowed into a silent done.\n *\n * @returns AsyncIterable<string> of Juneau wire SSE strings (activities + text + done)\n */\nexport async function* withToolRecovery(options: ToolRecoveryOptions): AsyncIterable<string> {\n const { phase1, phase2, phase3, skillSet, debug = false } = options;\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 1 start');\n }\n\n let producedText = false;\n\n const result1 = phase1();\n\n for await (const chunk of streamToWire(result1.fullStream, skillSet, { debug })) {\n // Track whether any text reached the wire (done event doesn't count)\n if (chunk.includes('\"type\":\"text\"')) {\n producedText = true;\n }\n\n // Hold back the done event — we may need to continue with phase 2 or 3\n if (chunk.includes('\"type\":\"done\"')) {\n continue;\n }\n\n yield chunk;\n }\n\n if (debug) {\n console.debug(\n `[juneau] withToolRecovery → phase 1 complete, textProduced=${producedText}, hadFailure=${skillSet.hadFailure}`\n );\n }\n\n if (skillSet.hadFailure && !producedText && skillSet.failureContext) {\n // Tool failed and model wrote nothing — run phase 2 to force a text response\n if (debug) {\n console.debug('[juneau] withToolRecovery → hadFailure=true, textProduced=false → triggering phase 2');\n }\n\n try {\n const result2 = phase2(skillSet.failureContext);\n\n // Phase 2 has no skillSet — plain text response, no tool calls expected\n yield* streamToWire(result2.fullStream, undefined, { debug });\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 2 complete');\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (debug) {\n console.debug(`[juneau] withToolRecovery → phase 2 FAILED: \"${message}\"`);\n }\n yield wireError(message);\n }\n return;\n }\n\n if (!producedText && !skillSet.hadFailure && phase3) {\n // Tool succeeded but model emitted no text — Gemini silent-response scenario.\n // Resolve the full message history from the consumed phase 1 result and let\n // phase 3 call the model again (no tools) to summarise the tool result.\n const fullMessages = await resolvePhase1Messages(result1);\n\n if (fullMessages) {\n if (debug) {\n console.debug(\n `[juneau] withToolRecovery → phase 3 messages resolved (${fullMessages.length}):`,\n JSON.stringify(fullMessages, null, 2)\n );\n if (!containsToolResult(fullMessages)) {\n console.debug(\n '[juneau] withToolRecovery → WARNING: resolved history contains no tool-result turn — Gemini will likely reject it as an invalid conversation structure'\n );\n }\n console.debug('[juneau] withToolRecovery → no failure, no text → triggering phase 3');\n }\n\n try {\n yield* streamToWire(phase3(fullMessages).fullStream, undefined, { debug });\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 3 complete');\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (debug) {\n console.debug(`[juneau] withToolRecovery → phase 3 FAILED: \"${message}\"`);\n }\n yield wireError(message);\n }\n return;\n }\n\n if (debug) {\n console.debug(\n '[juneau] withToolRecovery → phase 3 configured but phase 1 result exposes no message history — emitting done'\n );\n }\n } else if (!producedText && !skillSet.hadFailure && debug) {\n console.debug(\n '[juneau] withToolRecovery → no failure, no text, no phase3 — emitting done (Gemini silent response)'\n );\n }\n\n yield wireDone();\n}\n\n/**\n * Resolves the full message history (incl. tool-call/tool-result turns) from a\n * consumed ai-sdk StreamTextResult.\n *\n * ai-sdk v7: `result.messages` is the promise that resolves to ALL turns —\n * user, assistant(tool-call), tool(tool-result) — after the stream is consumed.\n * `result.response.messages` may resolve to an incomplete subset (observed:\n * tool-call turn without the following tool-result turn, which Gemini rejects),\n * so it is only used as a fallback when `messages` is unavailable.\n *\n * Both promises resolve only after the fullStream has been fully consumed,\n * which is guaranteed at the call site.\n */\nasync function resolvePhase1Messages(result: {\n messages?: Promise<unknown[]>;\n response?: Promise<{ messages?: unknown[] }>;\n}): Promise<unknown[] | null> {\n if (result.messages) {\n const messages = await result.messages;\n if (Array.isArray(messages) && messages.length > 0) {\n return messages;\n }\n }\n\n if (result.response) {\n const response = await result.response;\n if (Array.isArray(response?.messages) && response.messages.length > 0) {\n return response.messages;\n }\n }\n\n return null;\n}\n\n/**\n * Checks whether the resolved history contains a tool-result turn — either as\n * a `role: 'tool'` message or a content part with `type: 'tool-result'`.\n * Used only for the debug warning; the messages themselves are passed through opaquely.\n */\nfunction containsToolResult(messages: unknown[]): boolean {\n return messages.some((m) => {\n const msg = m as { role?: string; content?: unknown };\n if (msg.role === 'tool') return true;\n if (Array.isArray(msg.content)) {\n return msg.content.some(\n (part) => (part as { type?: string }).type === 'tool-result'\n );\n }\n return false;\n });\n}\n"],"names":["toSdkMessages","messages","mapped","msg","text","p","result","i","current","prev","formatActivityEvent","event","pickLabel","labels","language","createSkillSet","skills","options","debug","activityBuffer","hadFailure","failureContext","tools","name","skill","input","startMs","durationMs","err","message","failedLabels","TEXT_CHUNK_TYPES","IGNORED_CHUNK_TYPES","streamToWire","fullStream","skillSet","chunk","c","type","activities","remaining","wireError","wireDone","withToolRecovery","phase1","phase2","phase3","producedText","result1","result2","fullMessages","resolvePhase1Messages","containsToolResult","response","m","part"],"mappings":"AAaO,SAASA,EAAcC,GAAsC;AAGlE,QAAMC,IAAwBD,EAAS,IAAI,CAAA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GAGP;AAC5B,MAAIA,EAAO,UAAU;AACnB,UAAML,IAAW,MAAMK,EAAO;AAC9B,QAAI,MAAM,QAAQL,CAAQ,KAAKA,EAAS,SAAS;AAC/C,aAAOA;AAAA,EAEX;AAEA,MAAIK,EAAO,UAAU;AACnB,UAAM+C,IAAW,MAAM/C,EAAO;AAC9B,QAAI,MAAM,QAAQ+C,GAAU,QAAQ,KAAKA,EAAS,SAAS,SAAS;AAClE,aAAOA,EAAS;AAAA,EAEpB;AAEA,SAAO;AACT;AAOA,SAASD,EAAmBnD,GAA8B;AACxD,SAAOA,EAAS,KAAK,CAACqD,MAAM;AAC1B,UAAMnD,IAAMmD;AACZ,WAAInD,EAAI,SAAS,SAAe,KAC5B,MAAM,QAAQA,EAAI,OAAO,IACpBA,EAAI,QAAQ;AAAA,MACjB,CAACoD,MAAUA,EAA2B,SAAS;AAAA,IAAA,IAG5C;AAAA,EACT,CAAC;AACH;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/server/toSdkMessages.ts","../../src/server/createSkillSet.ts","../../src/server/skillIndex.ts","../../src/server/streamToWire.ts","../../src/server/withToolRecovery.ts"],"sourcesContent":["import type { AiMessage } from '../core/types';\r\nimport type { CoreMessage } from './types';\r\n\r\n/**\r\n * Converts Juneau's AiMessage[] to the CoreMessage[] format expected by\r\n * ai-sdk's generateText / streamText.\r\n *\r\n * - Extracts plain text from parts (joins all type: \"text\" parts)\r\n * - Replaces activity-only assistant messages with an empty assistant turn\r\n * so conversation alternation stays valid\r\n * - Injects a placeholder assistant turn between consecutive user messages\r\n * - Filters out empty turns (unless they are a required alternation filler)\r\n */\r\nexport function toSdkMessages(messages: AiMessage[]): CoreMessage[] {\r\n // First pass: map each AiMessage to a CoreMessage, replacing activity-only\r\n // assistant messages with an empty-text assistant turn.\r\n const mapped: CoreMessage[] = messages.map(msg => {\r\n const text = msg.parts\r\n .filter(p => p.type === 'text')\r\n .map(p => (p as { type: 'text'; text: string }).text)\r\n .join('');\r\n\r\n return { role: msg.role as CoreMessage['role'], content: text };\r\n });\r\n\r\n // Second pass: inject a placeholder assistant turn between consecutive user\r\n // messages as a safety net for history bugs that would cause model errors.\r\n const result: CoreMessage[] = [];\r\n for (let i = 0; i < mapped.length; i++) {\r\n const current = mapped[i];\r\n const prev = result[result.length - 1];\r\n\r\n if (current.role === 'user' && prev?.role === 'user') {\r\n result.push({ role: 'assistant', content: '…' });\r\n }\r\n\r\n result.push(current);\r\n }\r\n\r\n // Third pass: filter out empty turns, but keep assistant placeholders that\r\n // serve as alternation fillers (they have content '…' set above, so they\r\n // won't be filtered). Only drop genuinely empty content strings.\r\n return result.filter(msg => msg.content.length > 0);\r\n}\r\n","import type { ZodType } from 'zod';\nimport type { SkillDefinition, SkillExecuteContext, SkillSet, SkillSetOptions } from './types';\n\ntype SkillMap = Record<string, SkillDefinition<ZodType>>;\n\nfunction formatWireEvent(event: Record<string, unknown>): string {\n return `data: ${JSON.stringify(event)}\\n\\n`;\n}\n\nfunction pickLabel(labels: { cs: string; en: string }, language: string): string {\n return (labels as Record<string, string>)[language] ?? labels.en;\n}\n\n/**\n * Takes a map of skill definitions and returns a SkillSet containing:\n * - tools: ready-made tool definitions for ai-sdk's streamText({ tools })\n * - drainActivities(): flush buffered activity + part wire SSE strings\n * - hadFailure / failureContext: for driving tool failure recovery\n *\n * Each skill's execute fn receives a SkillExecuteContext as its second\n * argument with an `emit(part)` callback — parts are pushed into the same\n * buffer as activities and drained by streamToWire at the same points.\n */\n/**\n * Validates skill definitions at startup — throws immediately (not at runtime)\n * so a broken registry fails the server boot, not a user request.\n */\nfunction validateSkills(skills: SkillMap): void {\n const knownNames = new Set(Object.keys(skills));\n\n for (const [name, skill] of Object.entries(skills)) {\n if (!skill.tools) continue;\n for (const toolName of skill.tools) {\n if (!knownNames.has(toolName)) {\n throw new Error(\n `[juneau] createSkillSet: skill \"${name}\" references unknown tool \"${toolName}\". ` +\n `Known skills: ${[...knownNames].join(', ')}`\n );\n }\n }\n }\n}\n\nexport function createSkillSet(skills: SkillMap, options: SkillSetOptions = {}): SkillSet {\n validateSkills(skills);\n\n const language = options.language ?? 'en';\n const debug = options.debug ?? false;\n const activityBuffer: string[] = [];\n const calledSkillNames: string[] = [];\n let hadFailure = false;\n let failureContext: string | null = null;\n\n const tools: Record<string, unknown> = {};\n\n for (const [name, skill] of Object.entries(skills)) {\n tools[name] = {\n description: skill.description,\n parameters: skill.input,\n execute: async (input: unknown) => {\n if (!calledSkillNames.includes(name)) {\n calledSkillNames.push(name);\n }\n\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → executing, input:`, input);\n }\n\n const startMs = debug ? Date.now() : 0;\n\n // Emit a \"running\" activity event into the buffer\n activityBuffer.push(\n formatWireEvent({\n type: 'activity',\n id: name,\n title: pickLabel(skill.labels.running, language),\n status: 'running',\n metadata: { skill: name },\n })\n );\n\n const executeContext: SkillExecuteContext = {\n emit: (part) => {\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → emitting part \"${part.type}\"`);\n }\n activityBuffer.push(formatWireEvent({ type: 'part', part }));\n },\n };\n\n try {\n const result = await skill.execute(input as never, executeContext);\n\n const durationMs = debug ? Date.now() - startMs : 0;\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → done in ${durationMs}ms, result:`, result);\n }\n\n // Emit a \"done\" activity event\n activityBuffer.push(\n formatWireEvent({\n type: 'activity',\n id: name,\n title: pickLabel(skill.labels.done, language),\n status: 'done',\n metadata: { skill: name },\n })\n );\n\n return result;\n } catch (err) {\n const durationMs = debug ? Date.now() - startMs : 0;\n const message = err instanceof Error ? err.message : String(err);\n\n if (debug) {\n console.debug(`[juneau] skill \"${name}\" → FAILED in ${durationMs}ms: \"${message}\"`);\n }\n\n const failedLabels = skill.labels.failed ?? { cs: 'Nepodařilo se', en: 'Failed' };\n\n // Emit a \"failed\" activity event\n activityBuffer.push(\n formatWireEvent({\n type: 'activity',\n id: name,\n title: pickLabel(failedLabels, language),\n status: 'failed',\n metadata: { skill: name },\n })\n );\n\n hadFailure = true;\n failureContext = `Tool \"${name}\" failed: ${message}`;\n\n // Re-throw so ai-sdk knows the tool call failed\n throw err;\n }\n },\n };\n }\n\n return {\n tools,\n\n skills,\n\n calledSkillNames,\n\n drainActivities(): string[] {\n return activityBuffer.splice(0, activityBuffer.length);\n },\n\n get hadFailure() {\n return hadFailure;\n },\n\n get failureContext() {\n return failureContext;\n },\n };\n}\n","import type { SkillSet } from './types';\n\n/**\n * Builds a compact one-liner-per-skill index for the system prompt.\n * Inject the output into your system prompt instead of hand-maintaining a\n * skill list — adding a skill to the registry updates the index automatically.\n *\n * Output format:\n * - invoiceSearch (read): Find invoices by number, supplier, date, or status.\n * - invoiceApprove (write, requires confirmation): Approve an invoice.\n */\nexport function buildSkillIndex(skillSet: SkillSet): string {\n return Object.entries(skillSet.skills)\n .map(([name, skill]) => {\n const traits: string[] = [skill.readOnly === false ? 'write' : 'read'];\n if (skill.requiresConfirmation) {\n traits.push('requires confirmation');\n }\n return `- ${name} (${traits.join(', ')}): ${skill.description}`;\n })\n .join('\\n');\n}\n\n/**\n * Returns the concatenated workflow instructions for the given skill names —\n * typically skillSet.calledSkillNames after phase 1. Skills without\n * instructions and unknown names are skipped. Returns '' when nothing matches.\n *\n * This is the lazy-loading half of the skill format: full instructions enter\n * the prompt only for skills the model actually used.\n *\n * @example\n * const instructions = selectSkills(skillSet, skillSet.calledSkillNames);\n * // → inject into phase 3's system prompt as additional context\n */\nexport function selectSkills(skillSet: SkillSet, skillNames: string[]): string {\n return skillNames\n .map(name => skillSet.skills[name])\n .filter(skill => skill?.instructions)\n .map(skill => skill.instructions as string)\n .join('\\n\\n');\n}\n","import type { SkillSet, StreamToWireOptions } from './types';\n\n// ai-sdk v7 chunk types that carry the model's text output.\n// - 'text-delta': standard streaming text (v6 + v7)\n// - 'text': emitted by some v7 model/provider combos as a completed text chunk\n// Both may appear in the same stream; we handle either.\nconst TEXT_CHUNK_TYPES = new Set(['text-delta', 'text']);\n\n// Chunk types we recognise but intentionally ignore — activities are driven by\n// the SkillSet execute fn, not by these wire events.\nconst IGNORED_CHUNK_TYPES = new Set([\n 'tool-call',\n 'tool-result',\n 'tool-input-start',\n 'tool-input-delta',\n 'tool-input-available',\n 'tool-output-available',\n 'step-start',\n 'finish-step',\n 'start',\n 'finish',\n 'response-metadata',\n 'stream-start',\n]);\n\n/**\n * Converts ai-sdk's fullStream AsyncIterable into Juneau wire SSE strings.\n *\n * Handles:\n * - All text chunk types used by ai-sdk v7 (text-delta, text) incl. v6 textDelta fallback\n * - Flushing skillSet.drainActivities() before each text chunk so activities\n * always appear before the text they precede\n * - A final drain after the loop ends (catches last-tool-call activities when\n * no text follows the tool result — the Gemini silent-response scenario)\n * - Emitting the done event when the stream finishes\n * - Structured debug logging of every chunk when options.debug is true\n */\nexport async function* streamToWire(\n fullStream: AsyncIterable<unknown>,\n skillSet?: SkillSet,\n options?: StreamToWireOptions\n): AsyncIterable<string> {\n const debug = options?.debug ?? false;\n\n for await (const chunk of fullStream) {\n const c = chunk as Record<string, unknown>;\n const type = c.type as string | undefined;\n\n if (debug) {\n if (type && TEXT_CHUNK_TYPES.has(type)) {\n const text = (c.text ?? c.textDelta) as string | undefined;\n console.debug(`[juneau] streamToWire chunk: ${type} ${JSON.stringify(text ?? '')}`);\n } else if (type === 'tool-call') {\n console.debug(`[juneau] streamToWire chunk: tool-call \"${c.toolName ?? c.name ?? '?'}\"`);\n } else if (type === 'tool-result') {\n console.debug(`[juneau] streamToWire chunk: tool-result (ignored)`);\n } else if (type) {\n if (IGNORED_CHUNK_TYPES.has(type)) {\n console.debug(`[juneau] streamToWire chunk: ${type} (ignored)`);\n } else {\n console.debug(`[juneau] streamToWire chunk: ${type} (unknown)`);\n }\n }\n }\n\n if (type && TEXT_CHUNK_TYPES.has(type)) {\n // Flush any buffered activity events before emitting text so the UI\n // shows running/done indicators before the model's reply appears.\n if (skillSet) {\n const activities = skillSet.drainActivities();\n if (debug && activities.length > 0) {\n console.debug(`[juneau] streamToWire → draining ${activities.length} activities`);\n }\n for (const event of activities) {\n yield event;\n }\n }\n\n // ai-sdk v7 uses `text`, v6 used `textDelta` — support both\n const text = (c.text ?? c.textDelta) as string | undefined;\n if (text) {\n if (debug) {\n console.debug(`[juneau] streamToWire → yielding text ${JSON.stringify(text)}`);\n }\n yield `data: ${JSON.stringify({ type: 'text', text })}\\n\\n`;\n }\n }\n\n // All other chunk types are intentionally silent — the SkillSet execute fn\n // emits activity events into its buffer which we drain above.\n }\n\n // Final drain — catches activity events from the last tool call when no\n // text-delta followed (Gemini sometimes calls a tool successfully but emits\n // the reply text in a subsequent step that never arrives as text-delta here).\n if (skillSet) {\n const remaining = skillSet.drainActivities();\n if (debug && remaining.length > 0) {\n console.debug(`[juneau] streamToWire → draining ${remaining.length} activities (end of stream)`);\n }\n for (const event of remaining) {\n yield event;\n }\n }\n\n if (debug) {\n console.debug('[juneau] streamToWire → end of stream, emitting done');\n }\n\n yield `data: ${JSON.stringify({ type: 'done' })}\\n\\n`;\n}\n","import type { ToolRecoveryOptions } from './types';\nimport { streamToWire } from './streamToWire';\n\nfunction wireError(message: string): string {\n return `data: ${JSON.stringify({ type: 'error', message })}\\n\\n`;\n}\n\nfunction wireDone(): string {\n return `data: ${JSON.stringify({ type: 'done' })}\\n\\n`;\n}\n\n/**\n * Encapsulates the multi-phase streaming pattern needed for Gemini 2.5 Flash\n * tool call scenarios where the model either fails or silently succeeds without\n * emitting any text in the same stream pass.\n *\n * Phase 1: Stream with tools. Collect whether any text was produced and whether\n * a tool failure occurred.\n *\n * Phase 2 (failure recovery) — triggers when a tool failed AND no text was produced:\n * - Injects failureContext as an assistant message so the model is forced to\n * write a recovery text response (no tools available in phase 2).\n *\n * Phase 3 (silent-success recovery) — triggers when the tool succeeded but the\n * model wrote no text. Confirmed Gemini 2.5 Flash behaviour: the fullStream ends\n * with tool-call → tool-result → finish-step → finish and no text-delta ever\n * arrives — Gemini treats the tool call as its complete response. Phase 3 receives\n * the full phase 1 message history including tool-call AND tool-result turns —\n * Gemini rejects histories where a tool-call turn is not immediately followed by\n * a tool-result turn (\"function call turn must come immediately after a user turn\n * or after a function response turn\"). The history is resolved from the consumed\n * phase 1 result's `messages` promise (ai-sdk v7 — resolves to all turns after\n * the stream is consumed), with `response.messages` as fallback.\n * If phase3 is not provided, falls back to emitting done (previous behaviour).\n *\n * Errors thrown by phase 2 / phase 3 model calls are surfaced as wire error\n * events — never swallowed into a silent done.\n *\n * @returns AsyncIterable<string> of Juneau wire SSE strings (activities + text + done)\n */\nexport async function* withToolRecovery(options: ToolRecoveryOptions): AsyncIterable<string> {\n const { phase1, phase2, phase3, skillSet, debug = false } = options;\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 1 start');\n }\n\n let producedText = false;\n\n const result1 = phase1();\n\n for await (const chunk of streamToWire(result1.fullStream, skillSet, { debug })) {\n // Track whether any text reached the wire (done event doesn't count)\n if (chunk.includes('\"type\":\"text\"')) {\n producedText = true;\n }\n\n // Hold back the done event — we may need to continue with phase 2 or 3\n if (chunk.includes('\"type\":\"done\"')) {\n continue;\n }\n\n yield chunk;\n }\n\n if (debug) {\n console.debug(\n `[juneau] withToolRecovery → phase 1 complete, textProduced=${producedText}, hadFailure=${skillSet.hadFailure}`\n );\n }\n\n if (skillSet.hadFailure && !producedText && skillSet.failureContext) {\n // Tool failed and model wrote nothing — run phase 2 to force a text response\n if (debug) {\n console.debug('[juneau] withToolRecovery → hadFailure=true, textProduced=false → triggering phase 2');\n }\n\n try {\n const result2 = phase2(skillSet.failureContext);\n\n // Phase 2 has no skillSet — plain text response, no tool calls expected\n yield* streamToWire(result2.fullStream, undefined, { debug });\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 2 complete');\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (debug) {\n console.debug(`[juneau] withToolRecovery → phase 2 FAILED: \"${message}\"`);\n }\n yield wireError(message);\n }\n return;\n }\n\n if (!producedText && !skillSet.hadFailure && phase3) {\n // Tool succeeded but model emitted no text — Gemini silent-response scenario.\n // Resolve the full message history from the consumed phase 1 result and let\n // phase 3 call the model again (no tools) to summarise the tool result.\n const fullMessages = await resolvePhase1Messages(result1);\n\n if (fullMessages) {\n if (debug) {\n console.debug(\n `[juneau] withToolRecovery → phase 3 messages resolved (${fullMessages.length}):`,\n JSON.stringify(fullMessages, null, 2)\n );\n if (!containsToolResult(fullMessages)) {\n console.debug(\n '[juneau] withToolRecovery → WARNING: resolved history contains no tool-result turn — Gemini will likely reject it as an invalid conversation structure'\n );\n }\n console.debug('[juneau] withToolRecovery → no failure, no text → triggering phase 3');\n }\n\n try {\n yield* streamToWire(phase3(fullMessages).fullStream, undefined, { debug });\n\n if (debug) {\n console.debug('[juneau] withToolRecovery → phase 3 complete');\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err);\n if (debug) {\n console.debug(`[juneau] withToolRecovery → phase 3 FAILED: \"${message}\"`);\n }\n yield wireError(message);\n }\n return;\n }\n\n if (debug) {\n console.debug(\n '[juneau] withToolRecovery → phase 3 configured but phase 1 result exposes no message history — emitting done'\n );\n }\n } else if (!producedText && !skillSet.hadFailure && debug) {\n console.debug(\n '[juneau] withToolRecovery → no failure, no text, no phase3 — emitting done (Gemini silent response)'\n );\n }\n\n yield wireDone();\n}\n\n/**\n * Resolves the full message history (incl. tool-call/tool-result turns) from a\n * consumed ai-sdk StreamTextResult.\n *\n * ai-sdk v7: `result.messages` is the promise that resolves to ALL turns —\n * user, assistant(tool-call), tool(tool-result) — after the stream is consumed.\n * `result.response.messages` may resolve to an incomplete subset (observed:\n * tool-call turn without the following tool-result turn, which Gemini rejects),\n * so it is only used as a fallback when `messages` is unavailable.\n *\n * Both promises resolve only after the fullStream has been fully consumed,\n * which is guaranteed at the call site.\n */\nasync function resolvePhase1Messages(result: {\n messages?: Promise<unknown[]>;\n response?: Promise<{ messages?: unknown[] }>;\n}): Promise<unknown[] | null> {\n if (result.messages) {\n const messages = await result.messages;\n if (Array.isArray(messages) && messages.length > 0) {\n return messages;\n }\n }\n\n if (result.response) {\n const response = await result.response;\n if (Array.isArray(response?.messages) && response.messages.length > 0) {\n return response.messages;\n }\n }\n\n return null;\n}\n\n/**\n * Checks whether the resolved history contains a tool-result turn — either as\n * a `role: 'tool'` message or a content part with `type: 'tool-result'`.\n * Used only for the debug warning; the messages themselves are passed through opaquely.\n */\nfunction containsToolResult(messages: unknown[]): boolean {\n return messages.some((m) => {\n const msg = m as { role?: string; content?: unknown };\n if (msg.role === 'tool') return true;\n if (Array.isArray(msg.content)) {\n return msg.content.some(\n (part) => (part as { type?: string }).type === 'tool-result'\n );\n }\n return false;\n });\n}\n"],"names":["toSdkMessages","messages","mapped","msg","text","p","result","i","current","prev","formatWireEvent","event","pickLabel","labels","language","validateSkills","skills","knownNames","name","skill","toolName","createSkillSet","options","debug","activityBuffer","calledSkillNames","hadFailure","failureContext","tools","input","startMs","executeContext","part","durationMs","err","message","failedLabels","buildSkillIndex","skillSet","traits","selectSkills","skillNames","TEXT_CHUNK_TYPES","IGNORED_CHUNK_TYPES","streamToWire","fullStream","chunk","c","type","activities","remaining","wireError","wireDone","withToolRecovery","phase1","phase2","phase3","producedText","result1","result2","fullMessages","resolvePhase1Messages","containsToolResult","response","m"],"mappings":"AAaO,SAASA,EAAcC,GAAsC;AAGlE,QAAMC,IAAwBD,EAAS,IAAI,CAAAE,MAAO;AAChD,UAAMC,IAAOD,EAAI,MACd,OAAO,OAAKE,EAAE,SAAS,MAAM,EAC7B,IAAI,CAAAA,MAAMA,EAAqC,IAAI,EACnD,KAAK,EAAE;AAEV,WAAO,EAAE,MAAMF,EAAI,MAA6B,SAASC,EAAA;AAAA,EAC3D,CAAC,GAIKE,IAAwB,CAAA;AAC9B,WAASC,IAAI,GAAGA,IAAIL,EAAO,QAAQK,KAAK;AACtC,UAAMC,IAAUN,EAAOK,CAAC,GAClBE,IAAOH,EAAOA,EAAO,SAAS,CAAC;AAErC,IAAIE,EAAQ,SAAS,UAAUC,GAAM,SAAS,UAC5CH,EA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AAmB7D,GAA8B;AACxD,SAAOA,EAAS,KAAK,CAAC+D,MAAM;AAC1B,UAAM7D,IAAM6D;AACZ,WAAI7D,EAAI,SAAS,SAAe,KAC5B,MAAM,QAAQA,EAAI,OAAO,IACpBA,EAAI,QAAQ;AAAA,MACjB,CAAC6B,MAAUA,EAA2B,SAAS;AAAA,IAAA,IAG5C;AAAA,EACT,CAAC;AACH;"}
@@ -0,0 +1,25 @@
1
+ import type { SkillSet } from './types';
2
+ /**
3
+ * Builds a compact one-liner-per-skill index for the system prompt.
4
+ * Inject the output into your system prompt instead of hand-maintaining a
5
+ * skill list — adding a skill to the registry updates the index automatically.
6
+ *
7
+ * Output format:
8
+ * - invoiceSearch (read): Find invoices by number, supplier, date, or status.
9
+ * - invoiceApprove (write, requires confirmation): Approve an invoice.
10
+ */
11
+ export declare function buildSkillIndex(skillSet: SkillSet): string;
12
+ /**
13
+ * Returns the concatenated workflow instructions for the given skill names —
14
+ * typically skillSet.calledSkillNames after phase 1. Skills without
15
+ * instructions and unknown names are skipped. Returns '' when nothing matches.
16
+ *
17
+ * This is the lazy-loading half of the skill format: full instructions enter
18
+ * the prompt only for skills the model actually used.
19
+ *
20
+ * @example
21
+ * const instructions = selectSkills(skillSet, skillSet.calledSkillNames);
22
+ * // → inject into phase 3's system prompt as additional context
23
+ */
24
+ export declare function selectSkills(skillSet: SkillSet, skillNames: string[]): string;
25
+ //# sourceMappingURL=skillIndex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skillIndex.d.ts","sourceRoot":"","sources":["../../src/server/skillIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAExC;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAU1D;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,MAAM,CAM7E"}
@@ -1,9 +1,44 @@
1
1
  import type { ZodType, z } from 'zod';
2
2
  /**
3
- * A single skill definition description, zod input schema, i18n labels, and the execute fn.
3
+ * Helpers injected into a skill's execute fn as the second argument.
4
+ */
5
+ export interface SkillExecuteContext {
6
+ /**
7
+ * Emits a custom part wire event directly into the stream, alongside the
8
+ * automatic running/done/failed activities. Available synchronously at any
9
+ * point during execution — parts appear in the stream in emit order.
10
+ * The part is wrapped as { type: 'part', part } on the wire.
11
+ */
12
+ emit: (part: {
13
+ type: string;
14
+ [key: string]: unknown;
15
+ }) => void;
16
+ }
17
+ /**
18
+ * A single skill definition — metadata, zod input schema, i18n labels, and the execute fn.
19
+ *
20
+ * `description` is the tool description the model uses for tool selection.
21
+ * `instructions` is the "how to behave after calling this" workflow text —
22
+ * injected into the prompt only when the skill is relevant (see selectSkills).
4
23
  */
5
24
  export interface SkillDefinition<TInput extends ZodType = ZodType> {
25
+ /** Human-readable name, e.g. "Invoice Search". Used by buildSkillIndex. */
26
+ title: string;
6
27
  description: string;
28
+ /**
29
+ * Workflow instructions for the agent — separate from description. Loaded
30
+ * lazily via selectSkills() only for skills the model actually called.
31
+ */
32
+ instructions?: string;
33
+ /** False means the skill mutates data. Default: true. */
34
+ readOnly?: boolean;
35
+ /** True means the skill should emit a proposal before acting. Default: false. */
36
+ requiresConfirmation?: boolean;
37
+ /**
38
+ * Future-proofing for skill composition — names of other skills this skill
39
+ * depends on. Validated at createSkillSet() time against the skill map keys.
40
+ */
41
+ tools?: string[];
7
42
  input: TInput;
8
43
  labels: {
9
44
  running: {
@@ -19,7 +54,7 @@ export interface SkillDefinition<TInput extends ZodType = ZodType> {
19
54
  en: string;
20
55
  };
21
56
  };
22
- execute: (input: z.infer<TInput>) => Promise<unknown>;
57
+ execute: (input: z.infer<TInput>, context: SkillExecuteContext) => Promise<unknown>;
23
58
  }
24
59
  /**
25
60
  * The object returned by createSkillSet.
@@ -27,6 +62,14 @@ export interface SkillDefinition<TInput extends ZodType = ZodType> {
27
62
  export interface SkillSet {
28
63
  /** ai-sdk ToolSet — pass directly to streamText({ tools }) */
29
64
  tools: Record<string, unknown>;
65
+ /** The original skill definitions — used by buildSkillIndex / selectSkills. */
66
+ skills: Record<string, SkillDefinition>;
67
+ /**
68
+ * Names of skills the model actually called, in call order (deduplicated).
69
+ * Populated during phase 1 execution — pass to selectSkills() to load
70
+ * workflow instructions lazily for phase 3.
71
+ */
72
+ calledSkillNames: string[];
30
73
  /**
31
74
  * Returns and clears all buffered activity wire SSE strings.
32
75
  * Call before yielding text chunks to flush running/done/failed indicators.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/server/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,MAAM,SAAS,OAAO,GAAG,OAAO;IAC/D,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,OAAO,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACpC,IAAI,EAAK;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;QACpC,MAAM,CAAC,EAAE;YAAE,EAAE,EAAE,MAAM,CAAC;YAAC,EAAE,EAAE,MAAM,CAAA;SAAE,CAAC;KACrC,CAAC;IACF,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAE/B;;;OAGG;IACH,eAAe,IAAI,MAAM,EAAE,C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,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC"}
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- :root{--juneau-color-primary: #000000;--juneau-color-primary-dark: #252528;--juneau-color-primary-light: #ECECEC;--juneau-color-primary-border: #E8E8EC;--juneau-color-accent: #FF49A4;--juneau-color-accent-dark: #FF6BB3;--juneau-color-accent-light: #FFF0F7;--juneau-color-accent-border: #FFBDD9;--juneau-color-surface: #FFFFFF;--juneau-color-surface-raised: #F4F4F6;--juneau-color-surface-hover: #ECECEC;--juneau-color-border: #E8E8EC;--juneau-color-border-subtle: #ECECEC;--juneau-color-text-primary: #000000;--juneau-color-text-secondary: #474747;--juneau-color-text-muted: #474747;--juneau-color-text-faint: #9090A0;--juneau-color-text-inverse: #FFFFFF;--juneau-color-assistant-avatar: #FF49A4;--juneau-color-error-bg: #FFF0F7;--juneau-color-error-border: #E6244A;--juneau-color-error-text: #C41A3B;--juneau-color-success-bg: #F4FDE8;--juneau-color-success-text: #3F7528;--juneau-color-warning-bg: #FFF6E5;--juneau-color-warning-text: #B37400;--juneau-color-danger-bg: #FFF0F7;--juneau-color-danger-text: #C41A3B;--juneau-radius-sm: 6px;--juneau-radius-md: 8px;--juneau-radius-lg: 12px;--juneau-radius-full: 9999px;--juneau-font-size-xs: 11px;--juneau-font-size-sm: 12px;--juneau-font-size-base: 13px;--juneau-font-size-md: 14px;--juneau-font-size-lg: 15px;--juneau-font-size-xl: 16px;--juneau-font-size-2xl: 22px;--juneau-font-size-3xl: 24px;--juneau-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--juneau-transition-fast: .15s}._root_1etc2_1{display:contents;font-family:var(--juneau-font-family)}._wrapper_izvjy_1{overflow-x:auto;margin:8px 0;border-radius:var(--juneau-radius-md);border:1px solid var(--juneau-color-border)}._table_izvjy_15{width:100%;border-collapse:collapse;font-size:var(--juneau-font-size-base)}._th_izvjy_27{background-color:var(--juneau-color-surface-raised);padding:8px 12px;text-align:left;font-weight:600;color:var(--juneau-color-text-secondary);border-bottom:1px solid var(--juneau-color-border);white-space:nowrap}._tr_izvjy_47:nth-child(2n){background-color:var(--juneau-color-surface-raised)}._tr_izvjy_47:hover{background-color:var(--juneau-color-surface-hover)}._td_izvjy_63{padding:7px 12px;color:var(--juneau-color-text-primary);border-bottom:1px solid var(--juneau-color-border-subtle)}._card_qrvry_1{background:linear-gradient(135deg,var(--juneau-color-accent-light) 0%,var(--juneau-color-accent-border) 100%);border:1px solid var(--juneau-color-accent-border);border-radius:var(--juneau-radius-lg);padding:14px 16px;margin:8px 0}._header_qrvry_17{display:flex;align-items:center;gap:8px;margin-bottom:6px}._icon_qrvry_31{flex-shrink:0;width:16px;height:16px;color:var(--juneau-color-accent)}._title_qrvry_45{font-weight:600;font-size:var(--juneau-font-size-md);color:var(--juneau-color-accent-dark)}._description_qrvry_57{font-size:var(--juneau-font-size-base);color:var(--juneau-color-text-secondary);margin:0 0 12px;line-height:1.5}._actions_qrvry_71{display:flex;gap:8px}._confirm_qrvry_81{padding:7px 16px;background-color:var(--juneau-color-accent);color:var(--juneau-color-text-inverse);border:none;border-radius:var(--juneau-radius-sm);font-size:var(--juneau-font-size-base);font-weight:500;cursor:pointer;transition:background-color var(--juneau-transition-fast)}._confirm_qrvry_81:hover{background-color:var(--juneau-color-accent-dark)}._cancel_qrvry_113{padding:7px 16px;background-color:transparent;color:var(--juneau-color-text-muted);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-sm);font-size:var(--juneau-font-size-base);font-weight:500;cursor:pointer;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._cancel_qrvry_113:hover{background-color:var(--juneau-color-surface-hover);color:var(--juneau-color-text-secondary)}._activity_1661l_1{display:flex;align-items:flex-start;gap:8px;padding:7px 10px;margin:4px 0;border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);background:var(--juneau-color-surface-raised);font-size:var(--juneau-font-size-sm)}._indicator_1661l_25{width:7px;height:7px;margin-top:5px;border-radius:var(--juneau-radius-full);background:var(--juneau-color-text-faint);flex-shrink:0;transition:background var(--juneau-transition-fast)}._activity_1661l_1[data-status=running] ._indicator_1661l_25{background:var(--juneau-color-accent);animation:_pulse_1661l_1 1.4s ease-in-out infinite}._activity_1661l_1[data-status=done] ._indicator_1661l_25{background:var(--juneau-color-success-text)}._activity_1661l_1[data-status=failed] ._indicator_1661l_25{background:var(--juneau-color-error-text)}._content_1661l_71{min-width:0}._title_1661l_79{font-weight:500;color:var(--juneau-color-text-secondary)}._description_1661l_89{margin-top:1px;color:var(--juneau-color-text-faint)}@keyframes _pulse_1661l_1{0%,to{opacity:1}50%{opacity:.35}}._markdown_97mdk_1{line-height:1.6;font-size:var(--juneau-font-size-md)}._markdown_97mdk_1 p{margin:0 0 .5em}._markdown_97mdk_1 p:last-child{margin-bottom:0}._markdown_97mdk_1 strong{font-weight:700}._markdown_97mdk_1 em{font-style:italic}._markdown_97mdk_1 code{font-family:ui-monospace,Cascadia Code,Source Code Pro,Menlo,monospace;font-size:.9em;background:var(--juneau-color-surface-raised);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-sm);padding:.1em .35em}._markdown_97mdk_1 pre{background:var(--juneau-color-surface-raised);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);padding:10px 14px;overflow-x:auto;margin:.5em 0}._markdown_97mdk_1 pre code{background:none;border:none;padding:0;font-size:var(--juneau-font-size-sm)}._markdown_97mdk_1 ul,._markdown_97mdk_1 ol{margin:.25em 0 .5em;padding-left:1.4em}._markdown_97mdk_1 li{margin-bottom:.2em}._markdown_97mdk_1 blockquote{margin:.5em 0;padding-left:.75em;border-left:3px solid var(--juneau-color-border);color:var(--juneau-color-text-secondary)}._markdown_97mdk_1 a{color:var(--juneau-color-accent);text-decoration:underline}._markdown_97mdk_1 h1,._markdown_97mdk_1 h2,._markdown_97mdk_1 h3,._markdown_97mdk_1 h4{margin:.6em 0 .3em;font-weight:700;line-height:1.3}._markdown_97mdk_1 h1{font-size:var(--juneau-font-size-xl)}._markdown_97mdk_1 h2{font-size:var(--juneau-font-size-lg)}._markdown_97mdk_1 h3,._markdown_97mdk_1 h4{font-size:var(--juneau-font-size-md)}._errorText_97mdk_165{display:inline-flex;align-items:center;gap:5px;color:var(--juneau-color-error-text);font-size:var(--juneau-font-size-base)}._errorIcon_97mdk_181{width:14px;height:14px;flex-shrink:0}._wrapper_1jkxo_1{display:flex;align-items:flex-start;gap:8px;padding:4px 0}._user_1jkxo_15{flex-direction:row-reverse}._assistant_1jkxo_23{flex-direction:row}._avatar_1jkxo_31{flex-shrink:0;width:30px;height:30px;border-radius:var(--juneau-radius-full);font-size:var(--juneau-font-size-xs);font-weight:700;display:flex;align-items:center;justify-content:center;margin-top:2px}._user_1jkxo_15 ._avatar_1jkxo_31{background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse)}._assistant_1jkxo_23 ._avatar_1jkxo_31{background-color:var(--juneau-color-assistant-avatar);color:var(--juneau-color-text-inverse)}._bubble_1jkxo_77{max-width:85%;padding:10px 14px;border-radius:var(--juneau-radius-lg);font-size:var(--juneau-font-size-md);line-height:1.6;word-break:break-word}._user_1jkxo_15 ._bubble_1jkxo_77{background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);border-bottom-right-radius:3px}._assistant_1jkxo_23 ._bubble_1jkxo_77{background-color:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary);border:1px solid var(--juneau-color-border);border-bottom-left-radius:3px}._empty_1jkxo_121{display:inline-block;width:4px;height:16px}._wrapper_1oco7_1{display:flex;align-items:center;gap:4px;padding:10px 14px}._dot_1oco7_15{width:7px;height:7px;border-radius:var(--juneau-radius-full);background-color:var(--juneau-color-text-faint);animation:_bounce_1oco7_1 1.2s infinite ease-in-out}._dot_1oco7_15:nth-child(2){animation-delay:.2s}._dot_1oco7_15:nth-child(3){animation-delay:.4s}._connectingLabel_1oco7_37{margin-left:4px;font-size:var(--juneau-font-size-sm);color:var(--juneau-color-text-faint)}@keyframes _bounce_1oco7_1{0%,80%,to{transform:translateY(0);opacity:.5}40%{transform:translateY(-5px);opacity:1}}._list_ixto8_1{flex:1;overflow-y:auto;padding:16px 12px;display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth}._empty_ixto8_21{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--juneau-color-text-faint);font-size:var(--juneau-font-size-md);gap:6px;padding:40px 20px}._hint_ixto8_47{font-size:var(--juneau-font-size-sm);color:var(--juneau-color-text-faint)}._typing_ixto8_61{display:flex;align-items:flex-start;gap:8px;padding:2px 0}._wrapper_ehrkb_1{display:flex;flex-direction:column;border-top:1px solid var(--juneau-color-border);background-color:var(--juneau-color-surface);flex-shrink:0}._textarea_ehrkb_21{resize:none;border:none;outline:none;padding:12px 14px 6px;font-size:var(--juneau-font-size-md);font-family:inherit;line-height:1.6;color:var(--juneau-color-text-primary);background-color:var(--juneau-color-surface);width:100%}._textarea_ehrkb_21::placeholder{color:var(--juneau-color-text-faint)}._textarea_ehrkb_21:disabled{opacity:.6;cursor:not-allowed}._toolbar_ehrkb_69{display:flex;align-items:center;justify-content:space-between;padding:6px 10px 10px;gap:8px}._actions_ehrkb_89{display:flex;align-items:center;gap:2px;flex-wrap:wrap}._actionBtn_ehrkb_103{display:flex;align-items:center;gap:5px;padding:5px 8px;border:none;border-radius:var(--juneau-radius-sm);background:transparent;color:var(--juneau-color-text-muted);font-size:var(--juneau-font-size-sm);font-family:inherit;cursor:pointer;white-space:nowrap;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._actionBtn_ehrkb_103 svg{font-size:11px;opacity:.8}._actionBtn_ehrkb_103:hover:not(:disabled){background:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary)}._actionBtn_ehrkb_103:disabled{opacity:.4;cursor:not-allowed}._sendBtn_ehrkb_169{display:flex;align-items:center;gap:7px;padding:7px 14px;border:none;border-radius:var(--juneau-radius-md);background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);font-size:var(--juneau-font-size-base);font-family:inherit;font-weight:600;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background-color var(--juneau-transition-fast),opacity var(--juneau-transition-fast)}._sendBtn_ehrkb_169 svg{font-size:12px}._sendBtn_ehrkb_169:hover:not(:disabled){background-color:var(--juneau-color-primary-dark)}._sendBtn_ehrkb_169:disabled{opacity:.4;cursor:not-allowed}._spinnerIcon_ehrkb_231{width:14px;height:14px;animation:_spin_ehrkb_231 .8s linear infinite}@keyframes _spin_ehrkb_231{to{transform:rotate(360deg)}}._stopBtn_ehrkb_251{display:flex;align-items:center;gap:7px;padding:7px 14px;border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);background-color:var(--juneau-color-surface);color:var(--juneau-color-text-secondary);font-size:var(--juneau-font-size-base);font-family:inherit;font-weight:600;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._stopBtn_ehrkb_251:hover{background-color:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary)}._stopIcon_ehrkb_297{width:14px;height:14px}._wrapper_1e3w5_1{display:flex;align-items:center;gap:8px;padding:10px 14px;background-color:var(--juneau-color-error-bg);border:1px solid var(--juneau-color-error-border);border-radius:var(--juneau-radius-md);margin:4px 12px;font-size:var(--juneau-font-size-base);color:var(--juneau-color-error-text)}._icon_1e3w5_27{flex-shrink:0;width:16px;height:16px}._message_1e3w5_39{flex:1}._dismiss_1e3w5_47{display:flex;align-items:center;justify-content:center;background:none;border:none;cursor:pointer;color:var(--juneau-color-error-text);padding:0 2px;opacity:.7;transition:opacity var(--juneau-transition-fast)}._dismiss_1e3w5_47 svg{width:14px;height:14px}._dismiss_1e3w5_47:hover{opacity:1}._chat_13051_1{display:flex;flex-direction:column;height:100%;overflow:hidden}._header_1saak_1{display:flex;align-items:center;justify-content:space-between;padding:8px 14px;border-bottom:1px solid var(--juneau-color-border);background:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);flex-shrink:0}._left_1saak_23{display:flex;align-items:center;gap:8px}._icon_1saak_35{font-size:14px;opacity:.9}._title_1saak_45{font-size:var(--juneau-font-size-base);font-weight:600;letter-spacing:.02em}._resetBtn_1saak_57{background:transparent;border:none;border-radius:var(--juneau-radius-sm);color:var(--juneau-color-text-inverse);width:26px;height:26px;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:.7;transition:background-color var(--juneau-transition-fast),opacity var(--juneau-transition-fast)}._resetBtn_1saak_57:hover{background:#ffffff26;opacity:1}._actions_1saak_99{display:flex;align-items:center;gap:2px}._sidebar_u9ybt_1{position:fixed;bottom:0;right:0;display:flex;flex-direction:column;width:420px;background-color:var(--juneau-color-surface);border-left:1px solid var(--juneau-color-border);border-top:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-lg) var(--juneau-radius-lg) 0 0;box-shadow:-4px 0 24px #00000014;overflow:hidden;z-index:200;transition:height .25s cubic-bezier(.4,0,.2,1),width .25s cubic-bezier(.4,0,.2,1),box-shadow .25s ease}._minimized_u9ybt_39{height:auto!important;width:280px;box-shadow:0 -2px 16px #0000001a}
1
+ :root{--juneau-color-primary: #000000;--juneau-color-primary-dark: #252528;--juneau-color-primary-light: #ECECEC;--juneau-color-primary-border: #E8E8EC;--juneau-color-accent: #FF49A4;--juneau-color-accent-dark: #FF6BB3;--juneau-color-accent-light: #FFF0F7;--juneau-color-accent-border: #FFBDD9;--juneau-color-surface: #FFFFFF;--juneau-color-surface-raised: #F4F4F6;--juneau-color-surface-hover: #ECECEC;--juneau-color-border: #E8E8EC;--juneau-color-border-subtle: #ECECEC;--juneau-color-text-primary: #000000;--juneau-color-text-secondary: #474747;--juneau-color-text-muted: #474747;--juneau-color-text-faint: #9090A0;--juneau-color-text-inverse: #FFFFFF;--juneau-color-assistant-avatar: #FF49A4;--juneau-color-error-bg: #FFF0F7;--juneau-color-error-border: #E6244A;--juneau-color-error-text: #C41A3B;--juneau-color-success-bg: #F4FDE8;--juneau-color-success-text: #3F7528;--juneau-color-warning-bg: #FFF6E5;--juneau-color-warning-text: #B37400;--juneau-color-danger-bg: #FFF0F7;--juneau-color-danger-text: #C41A3B;--juneau-radius-sm: 6px;--juneau-radius-md: 8px;--juneau-radius-lg: 12px;--juneau-radius-full: 9999px;--juneau-font-size-xs: 11px;--juneau-font-size-sm: 12px;--juneau-font-size-base: 13px;--juneau-font-size-md: 14px;--juneau-font-size-lg: 15px;--juneau-font-size-xl: 16px;--juneau-font-size-2xl: 22px;--juneau-font-size-3xl: 24px;--juneau-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;--juneau-transition-fast: .15s}._root_1etc2_1{display:contents;font-family:var(--juneau-font-family)}._wrapper_izvjy_1{overflow-x:auto;margin:8px 0;border-radius:var(--juneau-radius-md);border:1px solid var(--juneau-color-border)}._table_izvjy_15{width:100%;border-collapse:collapse;font-size:var(--juneau-font-size-base)}._th_izvjy_27{background-color:var(--juneau-color-surface-raised);padding:8px 12px;text-align:left;font-weight:600;color:var(--juneau-color-text-secondary);border-bottom:1px solid var(--juneau-color-border);white-space:nowrap}._tr_izvjy_47:nth-child(2n){background-color:var(--juneau-color-surface-raised)}._tr_izvjy_47:hover{background-color:var(--juneau-color-surface-hover)}._td_izvjy_63{padding:7px 12px;color:var(--juneau-color-text-primary);border-bottom:1px solid var(--juneau-color-border-subtle)}._card_qrvry_1{background:linear-gradient(135deg,var(--juneau-color-accent-light) 0%,var(--juneau-color-accent-border) 100%);border:1px solid var(--juneau-color-accent-border);border-radius:var(--juneau-radius-lg);padding:14px 16px;margin:8px 0}._header_qrvry_17{display:flex;align-items:center;gap:8px;margin-bottom:6px}._icon_qrvry_31{flex-shrink:0;width:16px;height:16px;color:var(--juneau-color-accent)}._title_qrvry_45{font-weight:600;font-size:var(--juneau-font-size-md);color:var(--juneau-color-accent-dark)}._description_qrvry_57{font-size:var(--juneau-font-size-base);color:var(--juneau-color-text-secondary);margin:0 0 12px;line-height:1.5}._actions_qrvry_71{display:flex;gap:8px}._confirm_qrvry_81{padding:7px 16px;background-color:var(--juneau-color-accent);color:var(--juneau-color-text-inverse);border:none;border-radius:var(--juneau-radius-sm);font-size:var(--juneau-font-size-base);font-weight:500;cursor:pointer;transition:background-color var(--juneau-transition-fast)}._confirm_qrvry_81:hover{background-color:var(--juneau-color-accent-dark)}._cancel_qrvry_113{padding:7px 16px;background-color:transparent;color:var(--juneau-color-text-muted);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-sm);font-size:var(--juneau-font-size-base);font-weight:500;cursor:pointer;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._cancel_qrvry_113:hover{background-color:var(--juneau-color-surface-hover);color:var(--juneau-color-text-secondary)}._activity_1661l_1{display:flex;align-items:flex-start;gap:8px;padding:7px 10px;margin:4px 0;border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);background:var(--juneau-color-surface-raised);font-size:var(--juneau-font-size-sm)}._indicator_1661l_25{width:7px;height:7px;margin-top:5px;border-radius:var(--juneau-radius-full);background:var(--juneau-color-text-faint);flex-shrink:0;transition:background var(--juneau-transition-fast)}._activity_1661l_1[data-status=running] ._indicator_1661l_25{background:var(--juneau-color-accent);animation:_pulse_1661l_1 1.4s ease-in-out infinite}._activity_1661l_1[data-status=done] ._indicator_1661l_25{background:var(--juneau-color-success-text)}._activity_1661l_1[data-status=failed] ._indicator_1661l_25{background:var(--juneau-color-error-text)}._content_1661l_71{min-width:0}._title_1661l_79{font-weight:500;color:var(--juneau-color-text-secondary)}._description_1661l_89{margin-top:1px;color:var(--juneau-color-text-faint)}@keyframes _pulse_1661l_1{0%,to{opacity:1}50%{opacity:.35}}._markdown_sznoh_1{line-height:1.6;font-size:var(--juneau-font-size-md)}._markdown_sznoh_1 p{margin:0 0 .5em}._markdown_sznoh_1 p:last-child{margin-bottom:0}._markdown_sznoh_1 strong{font-weight:700}._markdown_sznoh_1 em{font-style:italic}._markdown_sznoh_1 code{font-family:ui-monospace,Cascadia Code,Source Code Pro,Menlo,monospace;font-size:.9em;background:var(--juneau-color-surface-raised);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-sm);padding:.1em .35em}._markdown_sznoh_1 pre{background:var(--juneau-color-surface-raised);border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);padding:10px 14px;overflow-x:auto;margin:.5em 0}._markdown_sznoh_1 pre code{background:none;border:none;padding:0;font-size:var(--juneau-font-size-sm)}._markdown_sznoh_1 ul,._markdown_sznoh_1 ol{margin:.25em 0 .5em;padding-left:1.4em}._markdown_sznoh_1 li{margin-bottom:.2em}._markdown_sznoh_1 blockquote{margin:.5em 0;padding-left:.75em;border-left:3px solid var(--juneau-color-border);color:var(--juneau-color-text-secondary)}._markdown_sznoh_1 a{color:var(--juneau-color-accent);text-decoration:underline}._markdown_sznoh_1 h1,._markdown_sznoh_1 h2,._markdown_sznoh_1 h3,._markdown_sznoh_1 h4{margin:.6em 0 .3em;font-weight:700;line-height:1.3}._markdown_sznoh_1 h1{font-size:var(--juneau-font-size-xl)}._markdown_sznoh_1 h2{font-size:var(--juneau-font-size-lg)}._markdown_sznoh_1 h3,._markdown_sznoh_1 h4{font-size:var(--juneau-font-size-md)}._unknownPart_sznoh_167{border:1px dashed var(--juneau-color-warning-text);background:var(--juneau-color-warning-bg);color:var(--juneau-color-warning-text);border-radius:var(--juneau-radius-sm);padding:6px 10px;font-size:var(--juneau-font-size-sm)}._unknownPart_sznoh_167 code{font-family:ui-monospace,Cascadia Code,Source Code Pro,Menlo,monospace;font-size:.9em}._errorText_sznoh_195{display:inline-flex;align-items:center;gap:5px;color:var(--juneau-color-error-text);font-size:var(--juneau-font-size-base)}._errorIcon_sznoh_211{width:14px;height:14px;flex-shrink:0}._wrapper_1jkxo_1{display:flex;align-items:flex-start;gap:8px;padding:4px 0}._user_1jkxo_15{flex-direction:row-reverse}._assistant_1jkxo_23{flex-direction:row}._avatar_1jkxo_31{flex-shrink:0;width:30px;height:30px;border-radius:var(--juneau-radius-full);font-size:var(--juneau-font-size-xs);font-weight:700;display:flex;align-items:center;justify-content:center;margin-top:2px}._user_1jkxo_15 ._avatar_1jkxo_31{background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse)}._assistant_1jkxo_23 ._avatar_1jkxo_31{background-color:var(--juneau-color-assistant-avatar);color:var(--juneau-color-text-inverse)}._bubble_1jkxo_77{max-width:85%;padding:10px 14px;border-radius:var(--juneau-radius-lg);font-size:var(--juneau-font-size-md);line-height:1.6;word-break:break-word}._user_1jkxo_15 ._bubble_1jkxo_77{background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);border-bottom-right-radius:3px}._assistant_1jkxo_23 ._bubble_1jkxo_77{background-color:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary);border:1px solid var(--juneau-color-border);border-bottom-left-radius:3px}._empty_1jkxo_121{display:inline-block;width:4px;height:16px}._wrapper_1oco7_1{display:flex;align-items:center;gap:4px;padding:10px 14px}._dot_1oco7_15{width:7px;height:7px;border-radius:var(--juneau-radius-full);background-color:var(--juneau-color-text-faint);animation:_bounce_1oco7_1 1.2s infinite ease-in-out}._dot_1oco7_15:nth-child(2){animation-delay:.2s}._dot_1oco7_15:nth-child(3){animation-delay:.4s}._connectingLabel_1oco7_37{margin-left:4px;font-size:var(--juneau-font-size-sm);color:var(--juneau-color-text-faint)}@keyframes _bounce_1oco7_1{0%,80%,to{transform:translateY(0);opacity:.5}40%{transform:translateY(-5px);opacity:1}}._list_ixto8_1{flex:1;overflow-y:auto;padding:16px 12px;display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth}._empty_ixto8_21{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;text-align:center;color:var(--juneau-color-text-faint);font-size:var(--juneau-font-size-md);gap:6px;padding:40px 20px}._hint_ixto8_47{font-size:var(--juneau-font-size-sm);color:var(--juneau-color-text-faint)}._typing_ixto8_61{display:flex;align-items:flex-start;gap:8px;padding:2px 0}._wrapper_ehrkb_1{display:flex;flex-direction:column;border-top:1px solid var(--juneau-color-border);background-color:var(--juneau-color-surface);flex-shrink:0}._textarea_ehrkb_21{resize:none;border:none;outline:none;padding:12px 14px 6px;font-size:var(--juneau-font-size-md);font-family:inherit;line-height:1.6;color:var(--juneau-color-text-primary);background-color:var(--juneau-color-surface);width:100%}._textarea_ehrkb_21::placeholder{color:var(--juneau-color-text-faint)}._textarea_ehrkb_21:disabled{opacity:.6;cursor:not-allowed}._toolbar_ehrkb_69{display:flex;align-items:center;justify-content:space-between;padding:6px 10px 10px;gap:8px}._actions_ehrkb_89{display:flex;align-items:center;gap:2px;flex-wrap:wrap}._actionBtn_ehrkb_103{display:flex;align-items:center;gap:5px;padding:5px 8px;border:none;border-radius:var(--juneau-radius-sm);background:transparent;color:var(--juneau-color-text-muted);font-size:var(--juneau-font-size-sm);font-family:inherit;cursor:pointer;white-space:nowrap;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._actionBtn_ehrkb_103 svg{font-size:11px;opacity:.8}._actionBtn_ehrkb_103:hover:not(:disabled){background:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary)}._actionBtn_ehrkb_103:disabled{opacity:.4;cursor:not-allowed}._sendBtn_ehrkb_169{display:flex;align-items:center;gap:7px;padding:7px 14px;border:none;border-radius:var(--juneau-radius-md);background-color:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);font-size:var(--juneau-font-size-base);font-family:inherit;font-weight:600;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background-color var(--juneau-transition-fast),opacity var(--juneau-transition-fast)}._sendBtn_ehrkb_169 svg{font-size:12px}._sendBtn_ehrkb_169:hover:not(:disabled){background-color:var(--juneau-color-primary-dark)}._sendBtn_ehrkb_169:disabled{opacity:.4;cursor:not-allowed}._spinnerIcon_ehrkb_231{width:14px;height:14px;animation:_spin_ehrkb_231 .8s linear infinite}@keyframes _spin_ehrkb_231{to{transform:rotate(360deg)}}._stopBtn_ehrkb_251{display:flex;align-items:center;gap:7px;padding:7px 14px;border:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-md);background-color:var(--juneau-color-surface);color:var(--juneau-color-text-secondary);font-size:var(--juneau-font-size-base);font-family:inherit;font-weight:600;cursor:pointer;white-space:nowrap;flex-shrink:0;transition:background-color var(--juneau-transition-fast),color var(--juneau-transition-fast)}._stopBtn_ehrkb_251:hover{background-color:var(--juneau-color-surface-raised);color:var(--juneau-color-text-primary)}._stopIcon_ehrkb_297{width:14px;height:14px}._wrapper_1e3w5_1{display:flex;align-items:center;gap:8px;padding:10px 14px;background-color:var(--juneau-color-error-bg);border:1px solid var(--juneau-color-error-border);border-radius:var(--juneau-radius-md);margin:4px 12px;font-size:var(--juneau-font-size-base);color:var(--juneau-color-error-text)}._icon_1e3w5_27{flex-shrink:0;width:16px;height:16px}._message_1e3w5_39{flex:1}._dismiss_1e3w5_47{display:flex;align-items:center;justify-content:center;background:none;border:none;cursor:pointer;color:var(--juneau-color-error-text);padding:0 2px;opacity:.7;transition:opacity var(--juneau-transition-fast)}._dismiss_1e3w5_47 svg{width:14px;height:14px}._dismiss_1e3w5_47:hover{opacity:1}._chat_13051_1{display:flex;flex-direction:column;height:100%;overflow:hidden}._header_1saak_1{display:flex;align-items:center;justify-content:space-between;padding:8px 14px;border-bottom:1px solid var(--juneau-color-border);background:var(--juneau-color-primary);color:var(--juneau-color-text-inverse);flex-shrink:0}._left_1saak_23{display:flex;align-items:center;gap:8px}._icon_1saak_35{font-size:14px;opacity:.9}._title_1saak_45{font-size:var(--juneau-font-size-base);font-weight:600;letter-spacing:.02em}._resetBtn_1saak_57{background:transparent;border:none;border-radius:var(--juneau-radius-sm);color:var(--juneau-color-text-inverse);width:26px;height:26px;font-size:14px;cursor:pointer;display:flex;align-items:center;justify-content:center;opacity:.7;transition:background-color var(--juneau-transition-fast),opacity var(--juneau-transition-fast)}._resetBtn_1saak_57:hover{background:#ffffff26;opacity:1}._actions_1saak_99{display:flex;align-items:center;gap:2px}._sidebar_u9ybt_1{position:fixed;bottom:0;right:0;display:flex;flex-direction:column;width:420px;background-color:var(--juneau-color-surface);border-left:1px solid var(--juneau-color-border);border-top:1px solid var(--juneau-color-border);border-radius:var(--juneau-radius-lg) var(--juneau-radius-lg) 0 0;box-shadow:-4px 0 24px #00000014;overflow:hidden;z-index:200;transition:height .25s cubic-bezier(.4,0,.2,1),width .25s cubic-bezier(.4,0,.2,1),box-shadow .25s ease}._minimized_u9ybt_39{height:auto!important;width:280px;box-shadow:0 -2px 16px #0000001a}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "juneau",
3
- "version": "0.3.4",
3
+ "version": "0.4.1",
4
4
  "description": "Open-source React/TypeScript library for AI chat UI components",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",