illuma-agents 1.0.41 → 1.0.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/graphs/Graph.cjs +20 -1
- package/dist/cjs/graphs/Graph.cjs.map +1 -1
- package/dist/cjs/main.cjs +6 -0
- package/dist/cjs/main.cjs.map +1 -1
- package/dist/cjs/stream.cjs +14 -0
- package/dist/cjs/stream.cjs.map +1 -1
- package/dist/cjs/tools/DesktopTools.cjs +295 -0
- package/dist/cjs/tools/DesktopTools.cjs.map +1 -0
- package/dist/esm/graphs/Graph.mjs +20 -1
- package/dist/esm/graphs/Graph.mjs.map +1 -1
- package/dist/esm/main.mjs +1 -0
- package/dist/esm/main.mjs.map +1 -1
- package/dist/esm/stream.mjs +14 -0
- package/dist/esm/stream.mjs.map +1 -1
- package/dist/esm/tools/DesktopTools.mjs +289 -0
- package/dist/esm/tools/DesktopTools.mjs.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/tools/DesktopTools.d.ts +104 -0
- package/package.json +1 -1
- package/src/graphs/Graph.ts +23 -1
- package/src/index.ts +1 -0
- package/src/stream.ts +17 -0
- package/src/tools/DesktopTools.ts +552 -0
package/dist/esm/stream.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.mjs","sources":["../../src/stream.ts"],"sourcesContent":["// src/stream.ts\nimport type { ChatOpenAIReasoningSummary } from '@langchain/openai';\nimport type { AIMessageChunk } from '@langchain/core/messages';\nimport type { ToolCall } from '@langchain/core/messages/tool';\nimport type { AgentContext } from '@/agents/AgentContext';\nimport type { StandardGraph } from '@/graphs';\nimport type * as t from '@/types';\nimport {\n ToolCallTypes,\n ContentTypes,\n GraphEvents,\n StepTypes,\n Providers,\n} from '@/common';\nimport {\n handleServerToolResult,\n handleToolCallChunks,\n handleToolCalls,\n} from '@/tools/handlers';\nimport { getMessageId } from '@/messages';\n\n/**\n * Parses content to extract thinking sections enclosed in <think> tags using string operations\n * @param content The content to parse\n * @returns An object with separated text and thinking content\n */\nfunction parseThinkingContent(content: string): {\n text: string;\n thinking: string;\n} {\n // If no think tags, return the original content as text\n if (!content.includes('<think>')) {\n return { text: content, thinking: '' };\n }\n\n let textResult = '';\n const thinkingResult: string[] = [];\n let position = 0;\n\n while (position < content.length) {\n const thinkStart = content.indexOf('<think>', position);\n\n if (thinkStart === -1) {\n // No more think tags, add the rest and break\n textResult += content.slice(position);\n break;\n }\n\n // Add text before the think tag\n textResult += content.slice(position, thinkStart);\n\n const thinkEnd = content.indexOf('</think>', thinkStart);\n if (thinkEnd === -1) {\n // Malformed input, no closing tag\n textResult += content.slice(thinkStart);\n break;\n }\n\n // Add the thinking content\n const thinkContent = content.slice(thinkStart + 7, thinkEnd);\n thinkingResult.push(thinkContent);\n\n // Move position to after the think tag\n position = thinkEnd + 8; // 8 is the length of '</think>'\n }\n\n return {\n text: textResult.trim(),\n thinking: thinkingResult.join('\\n').trim(),\n };\n}\n\nfunction getNonEmptyValue(possibleValues: string[]): string | undefined {\n for (const value of possibleValues) {\n if (value && value.trim() !== '') {\n return value;\n }\n }\n return undefined;\n}\n\nexport function getChunkContent({\n chunk,\n provider,\n reasoningKey,\n}: {\n chunk?: Partial<AIMessageChunk>;\n provider?: Providers;\n reasoningKey: 'reasoning_content' | 'reasoning';\n}): string | t.MessageContentComplex[] | undefined {\n if (\n (provider === Providers.OPENAI || provider === Providers.AZURE) &&\n (\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text != null &&\n ((\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text?.length ?? 0) > 0\n ) {\n return (\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text;\n }\n /**\n * For OpenRouter, reasoning is stored in additional_kwargs.reasoning (not reasoning_content).\n * NOTE: We intentionally do NOT extract text from reasoning_details here.\n * The reasoning_details array contains the FULL accumulated reasoning text (set only on final chunk),\n * but individual reasoning tokens are already streamed via additional_kwargs.reasoning.\n * Extracting from reasoning_details would cause duplication.\n * The reasoning_details is only used for:\n * 1. Detecting reasoning mode in handleReasoning()\n * 2. Final message storage (for thought signatures)\n */\n if (provider === Providers.OPENROUTER) {\n // Content presence signals end of reasoning phase - prefer content over reasoning\n // This handles transitional chunks that may have both reasoning and content\n if (typeof chunk?.content === 'string' && chunk.content !== '') {\n return chunk.content;\n }\n const reasoning = chunk?.additional_kwargs?.reasoning as string | undefined;\n if (reasoning != null && reasoning !== '') {\n return reasoning;\n }\n return chunk?.content;\n }\n return (\n ((chunk?.additional_kwargs?.[reasoningKey] as string | undefined) ?? '') ||\n chunk?.content\n );\n}\n\nexport class ChatModelStreamHandler implements t.EventHandler {\n async handle(\n event: string,\n data: t.StreamEventData,\n metadata?: Record<string, unknown>,\n graph?: StandardGraph\n ): Promise<void> {\n if (!graph) {\n throw new Error('Graph not found');\n }\n if (!graph.config) {\n throw new Error('Config not found in graph');\n }\n if (!data.chunk) {\n console.warn(`No chunk found in ${event} event`);\n return;\n }\n\n const agentContext = graph.getAgentContext(metadata);\n\n const chunk = data.chunk as Partial<AIMessageChunk>;\n const content = getChunkContent({\n chunk,\n reasoningKey: agentContext.reasoningKey,\n provider: agentContext.provider,\n });\n const skipHandling = await handleServerToolResult({\n graph,\n content,\n metadata,\n agentContext,\n });\n if (skipHandling) {\n return;\n }\n this.handleReasoning(chunk, agentContext);\n let hasToolCalls = false;\n if (\n chunk.tool_calls &&\n chunk.tool_calls.length > 0 &&\n chunk.tool_calls.every(\n (tc) =>\n tc.id != null &&\n tc.id !== '' &&\n (tc as Partial<ToolCall>).name != null &&\n tc.name !== ''\n )\n ) {\n hasToolCalls = true;\n await handleToolCalls(chunk.tool_calls, metadata, graph);\n }\n\n const hasToolCallChunks =\n (chunk.tool_call_chunks && chunk.tool_call_chunks.length > 0) ?? false;\n const isEmptyContent =\n typeof content === 'undefined' ||\n !content.length ||\n (typeof content === 'string' && !content);\n\n /** Set a preliminary message ID if found in empty chunk */\n const isEmptyChunk = isEmptyContent && !hasToolCallChunks;\n if (\n isEmptyChunk &&\n (chunk.id ?? '') !== '' &&\n !graph.prelimMessageIdsByStepKey.has(chunk.id ?? '')\n ) {\n const stepKey = graph.getStepKey(metadata);\n graph.prelimMessageIdsByStepKey.set(stepKey, chunk.id ?? '');\n } else if (isEmptyChunk) {\n return;\n }\n\n const stepKey = graph.getStepKey(metadata);\n\n if (\n hasToolCallChunks &&\n chunk.tool_call_chunks &&\n chunk.tool_call_chunks.length &&\n typeof chunk.tool_call_chunks[0]?.index === 'number'\n ) {\n await handleToolCallChunks({\n graph,\n stepKey,\n toolCallChunks: chunk.tool_call_chunks,\n metadata,\n });\n }\n\n if (isEmptyContent) {\n return;\n }\n\n const message_id = getMessageId(stepKey, graph) ?? '';\n if (message_id) {\n await graph.dispatchRunStep(\n stepKey,\n {\n type: StepTypes.MESSAGE_CREATION,\n message_creation: {\n message_id,\n },\n },\n metadata\n );\n }\n\n const stepId = graph.getStepIdByKey(stepKey);\n const runStep = graph.getRunStep(stepId);\n if (!runStep) {\n console.warn(`\\n\n==============================================================\n\n\nRun step for ${stepId} does not exist, cannot dispatch delta event.\n\nevent: ${event}\nstepId: ${stepId}\nstepKey: ${stepKey}\nmessage_id: ${message_id}\nhasToolCalls: ${hasToolCalls}\nhasToolCallChunks: ${hasToolCallChunks}\n\n==============================================================\n\\n`);\n return;\n }\n\n /* Note: tool call chunks may have non-empty content that matches the current tool chunk generation */\n if (typeof content === 'string' && runStep.type === StepTypes.TOOL_CALLS) {\n return;\n } else if (\n hasToolCallChunks &&\n (chunk.tool_call_chunks?.some((tc) => tc.args === content) ?? false)\n ) {\n return;\n } else if (typeof content === 'string') {\n if (agentContext.currentTokenType === ContentTypes.TEXT) {\n await graph.dispatchMessageDelta(stepId, {\n content: [\n {\n type: ContentTypes.TEXT,\n text: content,\n },\n ],\n });\n } else if (agentContext.currentTokenType === 'think_and_text') {\n const { text, thinking } = parseThinkingContent(content);\n if (thinking) {\n await graph.dispatchReasoningDelta(stepId, {\n content: [\n {\n type: ContentTypes.THINK,\n think: thinking,\n },\n ],\n });\n }\n if (text) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n const newStepKey = graph.getStepKey(metadata);\n const message_id = getMessageId(newStepKey, graph) ?? '';\n await graph.dispatchRunStep(\n newStepKey,\n {\n type: StepTypes.MESSAGE_CREATION,\n message_creation: {\n message_id,\n },\n },\n metadata\n );\n\n const newStepId = graph.getStepIdByKey(newStepKey);\n await graph.dispatchMessageDelta(newStepId, {\n content: [\n {\n type: ContentTypes.TEXT,\n text: text,\n },\n ],\n });\n }\n } else {\n await graph.dispatchReasoningDelta(stepId, {\n content: [\n {\n type: ContentTypes.THINK,\n think: content,\n },\n ],\n });\n }\n } else if (\n content.every((c) => c.type?.startsWith(ContentTypes.TEXT) ?? false)\n ) {\n await graph.dispatchMessageDelta(stepId, {\n content,\n });\n } else if (\n content.every(\n (c) =>\n (c.type?.startsWith(ContentTypes.THINKING) ?? false) ||\n (c.type?.startsWith(ContentTypes.REASONING) ?? false) ||\n (c.type?.startsWith(ContentTypes.REASONING_CONTENT) ?? false) ||\n c.type === 'redacted_thinking'\n )\n ) {\n await graph.dispatchReasoningDelta(stepId, {\n content: content.map((c) => ({\n type: ContentTypes.THINK,\n think:\n (c as t.ThinkingContentText).thinking ??\n (c as Partial<t.GoogleReasoningContentText>).reasoning ??\n (c as Partial<t.BedrockReasoningContentText>).reasoningText?.text ??\n '',\n })),\n });\n }\n }\n handleReasoning(\n chunk: Partial<AIMessageChunk>,\n agentContext: AgentContext\n ): void {\n let reasoning_content = chunk.additional_kwargs?.[\n agentContext.reasoningKey\n ] as string | Partial<ChatOpenAIReasoningSummary> | undefined;\n if (\n Array.isArray(chunk.content) &&\n (chunk.content[0]?.type === ContentTypes.THINKING ||\n chunk.content[0]?.type === ContentTypes.REASONING ||\n chunk.content[0]?.type === ContentTypes.REASONING_CONTENT ||\n chunk.content[0]?.type === 'redacted_thinking')\n ) {\n reasoning_content = 'valid';\n } else if (\n (agentContext.provider === Providers.OPENAI ||\n agentContext.provider === Providers.AZURE) &&\n reasoning_content != null &&\n typeof reasoning_content !== 'string' &&\n reasoning_content.summary?.[0]?.text != null &&\n reasoning_content.summary[0].text\n ) {\n reasoning_content = 'valid';\n } else if (\n agentContext.provider === Providers.OPENROUTER &&\n // Only set reasoning as valid if content is NOT present (content signals end of reasoning)\n (chunk.content == null || chunk.content === '') &&\n // Check for reasoning_details (final chunk) OR reasoning string (intermediate chunks)\n ((chunk.additional_kwargs?.reasoning_details != null &&\n Array.isArray(chunk.additional_kwargs.reasoning_details) &&\n chunk.additional_kwargs.reasoning_details.length > 0) ||\n (typeof chunk.additional_kwargs?.reasoning === 'string' &&\n chunk.additional_kwargs.reasoning !== ''))\n ) {\n reasoning_content = 'valid';\n }\n if (\n reasoning_content != null &&\n reasoning_content !== '' &&\n (chunk.content == null ||\n chunk.content === '' ||\n reasoning_content === 'valid')\n ) {\n agentContext.currentTokenType = ContentTypes.THINK;\n agentContext.tokenTypeSwitch = 'reasoning';\n return;\n } else if (\n agentContext.tokenTypeSwitch === 'reasoning' &&\n agentContext.currentTokenType !== ContentTypes.TEXT &&\n ((chunk.content != null && chunk.content !== '') ||\n (chunk.tool_calls?.length ?? 0) > 0 ||\n (chunk.tool_call_chunks?.length ?? 0) > 0)\n ) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n chunk.content != null &&\n typeof chunk.content === 'string' &&\n chunk.content.includes('<think>') &&\n chunk.content.includes('</think>')\n ) {\n agentContext.currentTokenType = 'think_and_text';\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n chunk.content != null &&\n typeof chunk.content === 'string' &&\n chunk.content.includes('<think>')\n ) {\n agentContext.currentTokenType = ContentTypes.THINK;\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n agentContext.lastToken != null &&\n agentContext.lastToken.includes('</think>')\n ) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n }\n if (typeof chunk.content !== 'string') {\n return;\n }\n agentContext.lastToken = chunk.content;\n }\n}\n\nexport function createContentAggregator(): t.ContentAggregatorResult {\n const contentParts: Array<t.MessageContentComplex | undefined> = [];\n const stepMap = new Map<string, t.RunStep>();\n const toolCallIdMap = new Map<string, string>();\n // Track agentId and groupId for each content index (applied to content parts)\n const contentMetaMap = new Map<\n number,\n { agentId?: string; groupId?: number }\n >();\n\n const updateContent = (\n index: number,\n contentPart?: t.MessageContentComplex,\n finalUpdate = false\n ): void => {\n if (!contentPart) {\n console.warn('No content part found in \\'updateContent\\'');\n return;\n }\n const partType = contentPart.type ?? '';\n if (!partType) {\n console.warn('No content type found in content part');\n return;\n }\n\n if (!contentParts[index]) {\n contentParts[index] = { type: partType };\n }\n\n if (!partType.startsWith(contentParts[index]?.type ?? '')) {\n console.warn('Content type mismatch');\n return;\n }\n\n if (\n partType.startsWith(ContentTypes.TEXT) &&\n ContentTypes.TEXT in contentPart &&\n typeof contentPart.text === 'string'\n ) {\n // TODO: update this!!\n const currentContent = contentParts[index] as t.MessageDeltaUpdate;\n const update: t.MessageDeltaUpdate = {\n type: ContentTypes.TEXT,\n text: (currentContent.text || '') + contentPart.text,\n };\n\n if (contentPart.tool_call_ids) {\n update.tool_call_ids = contentPart.tool_call_ids;\n }\n contentParts[index] = update;\n } else if (\n partType.startsWith(ContentTypes.THINK) &&\n ContentTypes.THINK in contentPart &&\n typeof contentPart.think === 'string'\n ) {\n const currentContent = contentParts[index] as t.ReasoningDeltaUpdate;\n const update: t.ReasoningDeltaUpdate = {\n type: ContentTypes.THINK,\n think: (currentContent.think || '') + contentPart.think,\n };\n contentParts[index] = update;\n } else if (\n partType.startsWith(ContentTypes.AGENT_UPDATE) &&\n ContentTypes.AGENT_UPDATE in contentPart &&\n contentPart.agent_update != null\n ) {\n const update: t.AgentUpdate = {\n type: ContentTypes.AGENT_UPDATE,\n agent_update: contentPart.agent_update,\n };\n\n contentParts[index] = update;\n } else if (\n partType === ContentTypes.IMAGE_URL &&\n 'image_url' in contentPart\n ) {\n const currentContent = contentParts[index] as {\n type: 'image_url';\n image_url: string;\n };\n contentParts[index] = {\n ...currentContent,\n };\n } else if (\n partType === ContentTypes.TOOL_CALL &&\n 'tool_call' in contentPart\n ) {\n const incomingName = contentPart.tool_call.name;\n const incomingId = contentPart.tool_call.id;\n const toolCallArgs = (contentPart.tool_call as t.ToolCallPart).args;\n\n // When we receive a tool call with a name, it's the complete tool call\n // Consolidate with any previously accumulated args from chunks\n const hasValidName = incomingName != null && incomingName !== '';\n\n // Only process if incoming has a valid name (complete tool call)\n // or if we're doing a final update with complete data\n if (!hasValidName && !finalUpdate) {\n return;\n }\n\n const existingContent = contentParts[index] as\n | (Omit<t.ToolCallContent, 'tool_call'> & {\n tool_call?: t.ToolCallPart;\n })\n | undefined;\n\n /** When args are a valid object, they are likely already invoked */\n let args =\n finalUpdate ||\n typeof existingContent?.tool_call?.args === 'object' ||\n typeof toolCallArgs === 'object'\n ? contentPart.tool_call.args\n : (existingContent?.tool_call?.args ?? '') + (toolCallArgs ?? '');\n if (\n finalUpdate &&\n args == null &&\n existingContent?.tool_call?.args != null\n ) {\n args = existingContent.tool_call.args;\n }\n\n const id =\n getNonEmptyValue([incomingId, existingContent?.tool_call?.id]) ?? '';\n const name =\n getNonEmptyValue([incomingName, existingContent?.tool_call?.name]) ??\n '';\n\n const newToolCall: ToolCall & t.PartMetadata = {\n id,\n name,\n args,\n type: ToolCallTypes.TOOL_CALL,\n };\n\n if (finalUpdate) {\n newToolCall.progress = 1;\n newToolCall.output = contentPart.tool_call.output;\n }\n\n contentParts[index] = {\n type: ContentTypes.TOOL_CALL,\n tool_call: newToolCall,\n };\n }\n\n // Apply agentId (for MultiAgentGraph) and groupId (for parallel execution) to content parts\n // - agentId present → MultiAgentGraph (show agent labels)\n // - groupId present → parallel execution (render columns)\n const meta = contentMetaMap.get(index);\n if (meta?.agentId != null) {\n (contentParts[index] as t.MessageContentComplex).agentId = meta.agentId;\n }\n if (meta?.groupId != null) {\n (contentParts[index] as t.MessageContentComplex).groupId = meta.groupId;\n }\n };\n\n const aggregateContent = ({\n event,\n data,\n }: {\n event: GraphEvents;\n data:\n | t.RunStep\n | t.AgentUpdate\n | t.MessageDeltaEvent\n | t.RunStepDeltaEvent\n | { result: t.ToolEndEvent };\n }): void => {\n if (event === GraphEvents.ON_RUN_STEP) {\n const runStep = data as t.RunStep;\n stepMap.set(runStep.id, runStep);\n\n // Track agentId (MultiAgentGraph) and groupId (parallel execution) separately\n // - agentId: present for all MultiAgentGraph runs (enables agent labels in UI)\n // - groupId: present only for parallel execution (enables column rendering)\n const hasAgentId = runStep.agentId != null && runStep.agentId !== '';\n const hasGroupId = runStep.groupId != null;\n if (hasAgentId || hasGroupId) {\n const existingMeta = contentMetaMap.get(runStep.index) ?? {};\n if (hasAgentId) {\n existingMeta.agentId = runStep.agentId;\n }\n if (hasGroupId) {\n existingMeta.groupId = runStep.groupId;\n }\n contentMetaMap.set(runStep.index, existingMeta);\n }\n\n // Store tool call IDs if present\n if (\n runStep.stepDetails.type === StepTypes.TOOL_CALLS &&\n runStep.stepDetails.tool_calls\n ) {\n (runStep.stepDetails.tool_calls as ToolCall[]).forEach((toolCall) => {\n const toolCallId = toolCall.id ?? '';\n if ('id' in toolCall && toolCallId) {\n toolCallIdMap.set(runStep.id, toolCallId);\n }\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL_CALL,\n tool_call: {\n args: toolCall.args,\n name: toolCall.name,\n id: toolCallId,\n },\n };\n\n updateContent(runStep.index, contentPart);\n });\n }\n } else if (event === GraphEvents.ON_MESSAGE_DELTA) {\n const messageDelta = data as t.MessageDeltaEvent;\n const runStep = stepMap.get(messageDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for message delta event');\n return;\n }\n\n if (messageDelta.delta.content) {\n const contentPart = Array.isArray(messageDelta.delta.content)\n ? messageDelta.delta.content[0]\n : messageDelta.delta.content;\n\n updateContent(runStep.index, contentPart);\n }\n } else if (\n event === GraphEvents.ON_AGENT_UPDATE &&\n (data as t.AgentUpdate | undefined)?.agent_update\n ) {\n const contentPart = data as t.AgentUpdate | undefined;\n if (!contentPart) {\n return;\n }\n updateContent(contentPart.agent_update.index, contentPart);\n } else if (event === GraphEvents.ON_REASONING_DELTA) {\n const reasoningDelta = data as t.ReasoningDeltaEvent;\n const runStep = stepMap.get(reasoningDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for reasoning delta event');\n return;\n }\n\n if (reasoningDelta.delta.content) {\n const contentPart = Array.isArray(reasoningDelta.delta.content)\n ? reasoningDelta.delta.content[0]\n : reasoningDelta.delta.content;\n\n updateContent(runStep.index, contentPart);\n }\n } else if (event === GraphEvents.ON_RUN_STEP_DELTA) {\n const runStepDelta = data as t.RunStepDeltaEvent;\n const runStep = stepMap.get(runStepDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for run step delta event');\n return;\n }\n\n if (\n runStepDelta.delta.type === StepTypes.TOOL_CALLS &&\n runStepDelta.delta.tool_calls\n ) {\n runStepDelta.delta.tool_calls.forEach((toolCallDelta) => {\n const toolCallId = toolCallIdMap.get(runStepDelta.id);\n\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL_CALL,\n tool_call: {\n args: toolCallDelta.args ?? '',\n name: toolCallDelta.name,\n id: toolCallId,\n },\n };\n\n updateContent(runStep.index, contentPart);\n });\n }\n } else if (event === GraphEvents.ON_RUN_STEP_COMPLETED) {\n const { result } = data as unknown as { result: t.ToolEndEvent };\n\n const { id: stepId } = result;\n\n const runStep = stepMap.get(stepId);\n if (!runStep) {\n console.warn(\n 'No run step or runId found for completed tool call event'\n );\n return;\n }\n\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL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CAAC,YAAY,CAAC,EAAE,CAAC;AAErD,oBAAA,MAAM,WAAW,GAA4B;wBAC3C,IAAI,EAAE,YAAY,CAAC,SAAS;AAC5B,wBAAA,SAAS,EAAE;AACT,4BAAA,IAAI,EAAE,aAAa,CAAC,IAAI,IAAI,EAAE;4BAC9B,IAAI,EAAE,aAAa,CAAC,IAAI;AACxB,4BAAA,EAAE,EAAE,UAAU;AACf,yBAAA;qBACF;AAED,oBAAA,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC;AAC3C,iBAAC,CAAC;;;AAEC,aAAA,IAAI,KAAK,KAAK,WAAW,CAAC,qBAAqB,EAAE;AACtD,YAAA,MAAM,EAAE,MAAM,EAAE,GAAG,IAA6C;AAEhE,YAAA,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,MAAM;YAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,OAAO,EAAE;AACZ,gBAAA,OAAO,CAAC,IAAI,CACV,0DAA0D,CAC3D;gBACD;;AAGF,YAAA,MAAM,WAAW,GAA4B;gBAC3C,IAAI,EAAE,YAAY,CAAC,SAAS;gBAC5B,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B;YAED,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC;;AAEnD,KAAC;AAED,IAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE;AACpD;;;;"}
|
|
1
|
+
{"version":3,"file":"stream.mjs","sources":["../../src/stream.ts"],"sourcesContent":["// src/stream.ts\nimport type { ChatOpenAIReasoningSummary } from '@langchain/openai';\nimport type { AIMessageChunk } from '@langchain/core/messages';\nimport type { ToolCall } from '@langchain/core/messages/tool';\nimport type { AgentContext } from '@/agents/AgentContext';\nimport type { StandardGraph } from '@/graphs';\nimport type * as t from '@/types';\nimport {\n ToolCallTypes,\n ContentTypes,\n GraphEvents,\n StepTypes,\n Providers,\n} from '@/common';\nimport {\n handleServerToolResult,\n handleToolCallChunks,\n handleToolCalls,\n} from '@/tools/handlers';\nimport { getMessageId } from '@/messages';\n\n/**\n * Parses content to extract thinking sections enclosed in <think> tags using string operations\n * @param content The content to parse\n * @returns An object with separated text and thinking content\n */\nfunction parseThinkingContent(content: string): {\n text: string;\n thinking: string;\n} {\n // If no think tags, return the original content as text\n if (!content.includes('<think>')) {\n return { text: content, thinking: '' };\n }\n\n let textResult = '';\n const thinkingResult: string[] = [];\n let position = 0;\n\n while (position < content.length) {\n const thinkStart = content.indexOf('<think>', position);\n\n if (thinkStart === -1) {\n // No more think tags, add the rest and break\n textResult += content.slice(position);\n break;\n }\n\n // Add text before the think tag\n textResult += content.slice(position, thinkStart);\n\n const thinkEnd = content.indexOf('</think>', thinkStart);\n if (thinkEnd === -1) {\n // Malformed input, no closing tag\n textResult += content.slice(thinkStart);\n break;\n }\n\n // Add the thinking content\n const thinkContent = content.slice(thinkStart + 7, thinkEnd);\n thinkingResult.push(thinkContent);\n\n // Move position to after the think tag\n position = thinkEnd + 8; // 8 is the length of '</think>'\n }\n\n return {\n text: textResult.trim(),\n thinking: thinkingResult.join('\\n').trim(),\n };\n}\n\nfunction getNonEmptyValue(possibleValues: string[]): string | undefined {\n for (const value of possibleValues) {\n if (value && value.trim() !== '') {\n return value;\n }\n }\n return undefined;\n}\n\nexport function getChunkContent({\n chunk,\n provider,\n reasoningKey,\n}: {\n chunk?: Partial<AIMessageChunk>;\n provider?: Providers;\n reasoningKey: 'reasoning_content' | 'reasoning';\n}): string | t.MessageContentComplex[] | undefined {\n if (\n (provider === Providers.OPENAI || provider === Providers.AZURE) &&\n (\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text != null &&\n ((\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text?.length ?? 0) > 0\n ) {\n return (\n chunk?.additional_kwargs?.reasoning as\n | Partial<ChatOpenAIReasoningSummary>\n | undefined\n )?.summary?.[0]?.text;\n }\n /**\n * For OpenRouter, reasoning is stored in additional_kwargs.reasoning (not reasoning_content).\n * NOTE: We intentionally do NOT extract text from reasoning_details here.\n * The reasoning_details array contains the FULL accumulated reasoning text (set only on final chunk),\n * but individual reasoning tokens are already streamed via additional_kwargs.reasoning.\n * Extracting from reasoning_details would cause duplication.\n * The reasoning_details is only used for:\n * 1. Detecting reasoning mode in handleReasoning()\n * 2. Final message storage (for thought signatures)\n */\n if (provider === Providers.OPENROUTER) {\n // Content presence signals end of reasoning phase - prefer content over reasoning\n // This handles transitional chunks that may have both reasoning and content\n if (typeof chunk?.content === 'string' && chunk.content !== '') {\n return chunk.content;\n }\n const reasoning = chunk?.additional_kwargs?.reasoning as string | undefined;\n if (reasoning != null && reasoning !== '') {\n return reasoning;\n }\n return chunk?.content;\n }\n return (\n ((chunk?.additional_kwargs?.[reasoningKey] as string | undefined) ?? '') ||\n chunk?.content\n );\n}\n\nexport class ChatModelStreamHandler implements t.EventHandler {\n async handle(\n event: string,\n data: t.StreamEventData,\n metadata?: Record<string, unknown>,\n graph?: StandardGraph\n ): Promise<void> {\n if (!graph) {\n throw new Error('Graph not found');\n }\n if (!graph.config) {\n throw new Error('Config not found in graph');\n }\n if (!data.chunk) {\n console.warn(`No chunk found in ${event} event`);\n return;\n }\n\n const agentContext = graph.getAgentContext(metadata);\n\n const chunk = data.chunk as Partial<AIMessageChunk>;\n const content = getChunkContent({\n chunk,\n reasoningKey: agentContext.reasoningKey,\n provider: agentContext.provider,\n });\n const skipHandling = await handleServerToolResult({\n graph,\n content,\n metadata,\n agentContext,\n });\n if (skipHandling) {\n return;\n }\n this.handleReasoning(chunk, agentContext);\n let hasToolCalls = false;\n if (\n chunk.tool_calls &&\n chunk.tool_calls.length > 0 &&\n chunk.tool_calls.every(\n (tc) =>\n tc.id != null &&\n tc.id !== '' &&\n (tc as Partial<ToolCall>).name != null &&\n tc.name !== ''\n )\n ) {\n hasToolCalls = true;\n await handleToolCalls(chunk.tool_calls, metadata, graph);\n }\n\n const hasToolCallChunks =\n (chunk.tool_call_chunks && chunk.tool_call_chunks.length > 0) ?? false;\n const isEmptyContent =\n typeof content === 'undefined' ||\n !content.length ||\n (typeof content === 'string' && !content);\n\n /** Set a preliminary message ID if found in empty chunk */\n const isEmptyChunk = isEmptyContent && !hasToolCallChunks;\n if (\n isEmptyChunk &&\n (chunk.id ?? '') !== '' &&\n !graph.prelimMessageIdsByStepKey.has(chunk.id ?? '')\n ) {\n const stepKey = graph.getStepKey(metadata);\n graph.prelimMessageIdsByStepKey.set(stepKey, chunk.id ?? '');\n } else if (isEmptyChunk) {\n return;\n }\n\n const stepKey = graph.getStepKey(metadata);\n\n if (\n hasToolCallChunks &&\n chunk.tool_call_chunks &&\n chunk.tool_call_chunks.length &&\n typeof chunk.tool_call_chunks[0]?.index === 'number'\n ) {\n await handleToolCallChunks({\n graph,\n stepKey,\n toolCallChunks: chunk.tool_call_chunks,\n metadata,\n });\n }\n\n if (isEmptyContent) {\n return;\n }\n\n const message_id = getMessageId(stepKey, graph) ?? '';\n if (message_id) {\n await graph.dispatchRunStep(\n stepKey,\n {\n type: StepTypes.MESSAGE_CREATION,\n message_creation: {\n message_id,\n },\n },\n metadata\n );\n }\n\n const stepId = graph.getStepIdByKey(stepKey);\n const runStep = graph.getRunStep(stepId);\n if (!runStep) {\n console.warn(`\\n\n==============================================================\n\n\nRun step for ${stepId} does not exist, cannot dispatch delta event.\n\nevent: ${event}\nstepId: ${stepId}\nstepKey: ${stepKey}\nmessage_id: ${message_id}\nhasToolCalls: ${hasToolCalls}\nhasToolCallChunks: ${hasToolCallChunks}\n\n==============================================================\n\\n`);\n return;\n }\n\n /* Note: tool call chunks may have non-empty content that matches the current tool chunk generation */\n if (typeof content === 'string' && runStep.type === StepTypes.TOOL_CALLS) {\n return;\n } else if (\n hasToolCallChunks &&\n (chunk.tool_call_chunks?.some((tc) => tc.args === content) ?? false)\n ) {\n return;\n } else if (typeof content === 'string') {\n if (agentContext.currentTokenType === ContentTypes.TEXT) {\n await graph.dispatchMessageDelta(stepId, {\n content: [\n {\n type: ContentTypes.TEXT,\n text: content,\n },\n ],\n });\n } else if (agentContext.currentTokenType === 'think_and_text') {\n const { text, thinking } = parseThinkingContent(content);\n if (thinking) {\n await graph.dispatchReasoningDelta(stepId, {\n content: [\n {\n type: ContentTypes.THINK,\n think: thinking,\n },\n ],\n });\n }\n if (text) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n const newStepKey = graph.getStepKey(metadata);\n const message_id = getMessageId(newStepKey, graph) ?? '';\n await graph.dispatchRunStep(\n newStepKey,\n {\n type: StepTypes.MESSAGE_CREATION,\n message_creation: {\n message_id,\n },\n },\n metadata\n );\n\n const newStepId = graph.getStepIdByKey(newStepKey);\n await graph.dispatchMessageDelta(newStepId, {\n content: [\n {\n type: ContentTypes.TEXT,\n text: text,\n },\n ],\n });\n }\n } else {\n await graph.dispatchReasoningDelta(stepId, {\n content: [\n {\n type: ContentTypes.THINK,\n think: content,\n },\n ],\n });\n }\n } else if (\n content.every((c) => c.type?.startsWith(ContentTypes.TEXT) ?? false)\n ) {\n await graph.dispatchMessageDelta(stepId, {\n content,\n });\n } else if (\n content.every(\n (c) =>\n (c.type?.startsWith(ContentTypes.THINKING) ?? false) ||\n (c.type?.startsWith(ContentTypes.REASONING) ?? false) ||\n (c.type?.startsWith(ContentTypes.REASONING_CONTENT) ?? false) ||\n c.type === 'redacted_thinking'\n )\n ) {\n await graph.dispatchReasoningDelta(stepId, {\n content: content.map((c) => ({\n type: ContentTypes.THINK,\n think:\n (c as t.ThinkingContentText).thinking ??\n (c as Partial<t.GoogleReasoningContentText>).reasoning ??\n (c as Partial<t.BedrockReasoningContentText>).reasoningText?.text ??\n '',\n })),\n });\n }\n }\n handleReasoning(\n chunk: Partial<AIMessageChunk>,\n agentContext: AgentContext\n ): void {\n let reasoning_content = chunk.additional_kwargs?.[\n agentContext.reasoningKey\n ] as string | Partial<ChatOpenAIReasoningSummary> | undefined;\n if (\n Array.isArray(chunk.content) &&\n (chunk.content[0]?.type === ContentTypes.THINKING ||\n chunk.content[0]?.type === ContentTypes.REASONING ||\n chunk.content[0]?.type === ContentTypes.REASONING_CONTENT ||\n chunk.content[0]?.type === 'redacted_thinking')\n ) {\n reasoning_content = 'valid';\n } else if (\n (agentContext.provider === Providers.OPENAI ||\n agentContext.provider === Providers.AZURE) &&\n reasoning_content != null &&\n typeof reasoning_content !== 'string' &&\n reasoning_content.summary?.[0]?.text != null &&\n reasoning_content.summary[0].text\n ) {\n reasoning_content = 'valid';\n } else if (\n agentContext.provider === Providers.OPENROUTER &&\n // Only set reasoning as valid if content is NOT present (content signals end of reasoning)\n (chunk.content == null || chunk.content === '') &&\n // Check for reasoning_details (final chunk) OR reasoning string (intermediate chunks)\n ((chunk.additional_kwargs?.reasoning_details != null &&\n Array.isArray(chunk.additional_kwargs.reasoning_details) &&\n chunk.additional_kwargs.reasoning_details.length > 0) ||\n (typeof chunk.additional_kwargs?.reasoning === 'string' &&\n chunk.additional_kwargs.reasoning !== ''))\n ) {\n reasoning_content = 'valid';\n }\n if (\n reasoning_content != null &&\n reasoning_content !== '' &&\n (chunk.content == null ||\n chunk.content === '' ||\n reasoning_content === 'valid')\n ) {\n agentContext.currentTokenType = ContentTypes.THINK;\n agentContext.tokenTypeSwitch = 'reasoning';\n return;\n } else if (\n agentContext.tokenTypeSwitch === 'reasoning' &&\n agentContext.currentTokenType !== ContentTypes.TEXT &&\n ((chunk.content != null && chunk.content !== '') ||\n (chunk.tool_calls?.length ?? 0) > 0 ||\n (chunk.tool_call_chunks?.length ?? 0) > 0)\n ) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n chunk.content != null &&\n typeof chunk.content === 'string' &&\n chunk.content.includes('<think>') &&\n chunk.content.includes('</think>')\n ) {\n agentContext.currentTokenType = 'think_and_text';\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n chunk.content != null &&\n typeof chunk.content === 'string' &&\n chunk.content.includes('<think>')\n ) {\n agentContext.currentTokenType = ContentTypes.THINK;\n agentContext.tokenTypeSwitch = 'content';\n } else if (\n agentContext.lastToken != null &&\n agentContext.lastToken.includes('</think>')\n ) {\n agentContext.currentTokenType = ContentTypes.TEXT;\n agentContext.tokenTypeSwitch = 'content';\n }\n if (typeof chunk.content !== 'string') {\n return;\n }\n agentContext.lastToken = chunk.content;\n }\n}\n\nexport function createContentAggregator(): t.ContentAggregatorResult {\n const contentParts: Array<t.MessageContentComplex | undefined> = [];\n const stepMap = new Map<string, t.RunStep>();\n const toolCallIdMap = new Map<string, string>();\n // Track agentId and groupId for each content index (applied to content parts)\n const contentMetaMap = new Map<\n number,\n { agentId?: string; groupId?: number }\n >();\n\n const updateContent = (\n index: number,\n contentPart?: t.MessageContentComplex,\n finalUpdate = false\n ): void => {\n if (!contentPart) {\n console.warn('No content part found in \\'updateContent\\'');\n return;\n }\n const partType = contentPart.type ?? '';\n if (!partType) {\n console.warn('No content type found in content part');\n return;\n }\n\n if (!contentParts[index]) {\n contentParts[index] = { type: partType };\n }\n\n if (!partType.startsWith(contentParts[index]?.type ?? '')) {\n console.warn('Content type mismatch');\n return;\n }\n\n if (\n partType.startsWith(ContentTypes.TEXT) &&\n ContentTypes.TEXT in contentPart &&\n typeof contentPart.text === 'string'\n ) {\n // TODO: update this!!\n const currentContent = contentParts[index] as t.MessageDeltaUpdate;\n const update: t.MessageDeltaUpdate = {\n type: ContentTypes.TEXT,\n text: (currentContent.text || '') + contentPart.text,\n };\n\n if (contentPart.tool_call_ids) {\n update.tool_call_ids = contentPart.tool_call_ids;\n }\n contentParts[index] = update;\n } else if (\n partType.startsWith(ContentTypes.THINK) &&\n ContentTypes.THINK in contentPart &&\n typeof contentPart.think === 'string'\n ) {\n const currentContent = contentParts[index] as t.ReasoningDeltaUpdate;\n const update: t.ReasoningDeltaUpdate = {\n type: ContentTypes.THINK,\n think: (currentContent.think || '') + contentPart.think,\n };\n contentParts[index] = update;\n } else if (\n partType.startsWith(ContentTypes.AGENT_UPDATE) &&\n ContentTypes.AGENT_UPDATE in contentPart &&\n contentPart.agent_update != null\n ) {\n const update: t.AgentUpdate = {\n type: ContentTypes.AGENT_UPDATE,\n agent_update: contentPart.agent_update,\n };\n\n contentParts[index] = update;\n } else if (\n partType === ContentTypes.IMAGE_URL &&\n 'image_url' in contentPart\n ) {\n const currentContent = contentParts[index] as {\n type: 'image_url';\n image_url: string;\n };\n contentParts[index] = {\n ...currentContent,\n };\n } else if (\n partType === ContentTypes.TOOL_CALL &&\n 'tool_call' in contentPart\n ) {\n const incomingName = contentPart.tool_call.name;\n const incomingId = contentPart.tool_call.id;\n const toolCallArgs = (contentPart.tool_call as t.ToolCallPart).args;\n\n // When we receive a tool call with a name, it's the complete tool call\n // Consolidate with any previously accumulated args from chunks\n const hasValidName = incomingName != null && incomingName !== '';\n\n // Only process if incoming has a valid name (complete tool call)\n // or if we're doing a final update with complete data\n if (!hasValidName && !finalUpdate) {\n return;\n }\n\n const existingContent = contentParts[index] as\n | (Omit<t.ToolCallContent, 'tool_call'> & {\n tool_call?: t.ToolCallPart;\n })\n | undefined;\n\n /** When args are a valid object, they are likely already invoked */\n let args =\n finalUpdate ||\n typeof existingContent?.tool_call?.args === 'object' ||\n typeof toolCallArgs === 'object'\n ? contentPart.tool_call.args\n : (existingContent?.tool_call?.args ?? '') + (toolCallArgs ?? '');\n if (\n finalUpdate &&\n args == null &&\n existingContent?.tool_call?.args != null\n ) {\n args = existingContent.tool_call.args;\n }\n\n const id =\n getNonEmptyValue([incomingId, existingContent?.tool_call?.id]) ?? '';\n const name =\n getNonEmptyValue([incomingName, existingContent?.tool_call?.name]) ??\n '';\n\n const newToolCall: ToolCall & t.PartMetadata = {\n id,\n name,\n args,\n type: ToolCallTypes.TOOL_CALL,\n };\n\n if (finalUpdate) {\n newToolCall.progress = 1;\n newToolCall.output = contentPart.tool_call.output;\n }\n\n contentParts[index] = {\n type: ContentTypes.TOOL_CALL,\n tool_call: newToolCall,\n };\n }\n\n // Apply agentId (for MultiAgentGraph) and groupId (for parallel execution) to content parts\n // - agentId present → MultiAgentGraph (show agent labels)\n // - groupId present → parallel execution (render columns)\n const meta = contentMetaMap.get(index);\n if (meta?.agentId != null) {\n (contentParts[index] as t.MessageContentComplex).agentId = meta.agentId;\n }\n if (meta?.groupId != null) {\n (contentParts[index] as t.MessageContentComplex).groupId = meta.groupId;\n }\n };\n\n const aggregateContent = ({\n event,\n data,\n }: {\n event: GraphEvents;\n data:\n | t.RunStep\n | t.AgentUpdate\n | t.MessageDeltaEvent\n | t.RunStepDeltaEvent\n | { result: t.ToolEndEvent };\n }): void => {\n if (event === GraphEvents.ON_RUN_STEP) {\n const runStep = data as t.RunStep;\n stepMap.set(runStep.id, runStep);\n\n // Track agentId (MultiAgentGraph) and groupId (parallel execution) separately\n // - agentId: present for all MultiAgentGraph runs (enables agent labels in UI)\n // - groupId: present only for parallel execution (enables column rendering)\n const hasAgentId = runStep.agentId != null && runStep.agentId !== '';\n const hasGroupId = runStep.groupId != null;\n if (hasAgentId || hasGroupId) {\n const existingMeta = contentMetaMap.get(runStep.index) ?? {};\n if (hasAgentId) {\n existingMeta.agentId = runStep.agentId;\n }\n if (hasGroupId) {\n existingMeta.groupId = runStep.groupId;\n }\n contentMetaMap.set(runStep.index, existingMeta);\n }\n\n // Store tool call IDs if present\n if (\n runStep.stepDetails.type === StepTypes.TOOL_CALLS &&\n runStep.stepDetails.tool_calls\n ) {\n (runStep.stepDetails.tool_calls as ToolCall[]).forEach((toolCall) => {\n const toolCallId = toolCall.id ?? '';\n if ('id' in toolCall && toolCallId) {\n toolCallIdMap.set(runStep.id, toolCallId);\n }\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL_CALL,\n tool_call: {\n args: toolCall.args,\n name: toolCall.name,\n id: toolCallId,\n },\n };\n\n updateContent(runStep.index, contentPart);\n });\n }\n } else if (event === GraphEvents.ON_MESSAGE_DELTA) {\n const messageDelta = data as t.MessageDeltaEvent;\n const runStep = stepMap.get(messageDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for message delta event');\n return;\n }\n\n if (messageDelta.delta.content) {\n const contentPart = Array.isArray(messageDelta.delta.content)\n ? messageDelta.delta.content[0]\n : messageDelta.delta.content;\n\n updateContent(runStep.index, contentPart);\n }\n } else if (\n event === GraphEvents.ON_AGENT_UPDATE &&\n (data as t.AgentUpdate | undefined)?.agent_update\n ) {\n const contentPart = data as t.AgentUpdate | undefined;\n if (!contentPart) {\n return;\n }\n updateContent(contentPart.agent_update.index, contentPart);\n } else if (event === GraphEvents.ON_REASONING_DELTA) {\n const reasoningDelta = data as t.ReasoningDeltaEvent;\n const runStep = stepMap.get(reasoningDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for reasoning delta event');\n return;\n }\n\n if (reasoningDelta.delta.content) {\n const contentPart = Array.isArray(reasoningDelta.delta.content)\n ? reasoningDelta.delta.content[0]\n : reasoningDelta.delta.content;\n\n updateContent(runStep.index, contentPart);\n }\n } else if (event === GraphEvents.ON_RUN_STEP_DELTA) {\n const runStepDelta = data as t.RunStepDeltaEvent;\n const runStep = stepMap.get(runStepDelta.id);\n if (!runStep) {\n console.warn('No run step or runId found for run step delta event');\n return;\n }\n\n if (\n runStepDelta.delta.type === StepTypes.TOOL_CALLS &&\n runStepDelta.delta.tool_calls\n ) {\n runStepDelta.delta.tool_calls.forEach((toolCallDelta) => {\n const toolCallId = toolCallIdMap.get(runStepDelta.id);\n\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL_CALL,\n tool_call: {\n args: toolCallDelta.args ?? '',\n name: toolCallDelta.name,\n id: toolCallId,\n },\n };\n\n updateContent(runStep.index, contentPart);\n });\n }\n } else if (event === GraphEvents.ON_RUN_STEP_COMPLETED) {\n const { result } = data as unknown as { result: t.ToolEndEvent };\n\n const { id: stepId } = result;\n\n const runStep = stepMap.get(stepId);\n if (!runStep) {\n console.warn(\n 'No run step or runId found for completed tool call event'\n );\n return;\n }\n\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TOOL_CALL,\n tool_call: result.tool_call,\n };\n\n updateContent(runStep.index, contentPart, true);\n } else if (event === GraphEvents.ON_STRUCTURED_OUTPUT) {\n // Handle structured output as text content with formatted JSON\n const structuredData = data as unknown as {\n structuredResponse: Record<string, unknown>;\n schema: Record<string, unknown>;\n };\n \n if (structuredData.structuredResponse) {\n const jsonText = JSON.stringify(structuredData.structuredResponse, null, 2);\n const contentPart: t.MessageContentComplex = {\n type: ContentTypes.TEXT,\n text: jsonText,\n };\n // Add at index 0 or next available\n const nextIndex = contentParts.length;\n updateContent(nextIndex, contentPart);\n }\n }\n };\n\n return { contentParts, aggregateContent, stepMap };\n}\n"],"names":[],"mappings":";;;;;;;AAqBA;;;;AAIG;AACH,SAAS,oBAAoB,CAAC,OAAe,EAAA;;IAK3C,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;QAChC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE;;IAGxC,IAAI,UAAU,GAAG,EAAE;IACnB,MAAM,cAAc,GAAa,EAAE;IACnC,IAAI,QAAQ,GAAG,CAAC;AAEhB,IAAA,OAAO,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE;QAChC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,QAAQ,CAAC;AAEvD,QAAA,IAAI,UAAU,KAAK,EAAE,EAAE;;AAErB,YAAA,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC;YACrC;;;QAIF,UAAU,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,UAAU,CAAC;QAEjD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC;AACxD,Q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,aAAa,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,EAAE,IAAI,CAAC;;AAC1C,aAAA,IAAI,KAAK,KAAK,WAAW,CAAC,oBAAoB,EAAE;;YAErD,MAAM,cAAc,GAAG,IAGtB;AAED,YAAA,IAAI,cAAc,CAAC,kBAAkB,EAAE;AACrC,gBAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC;AAC3E,gBAAA,MAAM,WAAW,GAA4B;oBAC3C,IAAI,EAAE,YAAY,CAAC,IAAI;AACvB,oBAAA,IAAI,EAAE,QAAQ;iBACf;;AAED,gBAAA,MAAM,SAAS,GAAG,YAAY,CAAC,MAAM;AACrC,gBAAA,aAAa,CAAC,SAAS,EAAE,WAAW,CAAC;;;AAG3C,KAAC;AAED,IAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,OAAO,EAAE;AACpD;;;;"}
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { tool } from '@langchain/core/tools';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Desktop tool names - keep in sync with Ranger Desktop Electron app
|
|
6
|
+
* These tools execute locally in the Electron app, NOT on the server
|
|
7
|
+
*/
|
|
8
|
+
const EDesktopTools = {
|
|
9
|
+
SCREENSHOT: 'computer_screenshot',
|
|
10
|
+
CLICK: 'computer_click',
|
|
11
|
+
DOUBLE_CLICK: 'computer_double_click',
|
|
12
|
+
RIGHT_CLICK: 'computer_right_click',
|
|
13
|
+
TYPE: 'computer_type',
|
|
14
|
+
KEY: 'computer_key',
|
|
15
|
+
KEY_COMBO: 'computer_key_combo',
|
|
16
|
+
SCROLL: 'computer_scroll',
|
|
17
|
+
DRAG: 'computer_drag',
|
|
18
|
+
GET_ACTIVE_WINDOW: 'computer_get_active_window',
|
|
19
|
+
GET_MOUSE_POSITION: 'computer_get_mouse_position',
|
|
20
|
+
CLIPBOARD_READ: 'clipboard_read',
|
|
21
|
+
CLIPBOARD_WRITE: 'clipboard_write',
|
|
22
|
+
CLIPBOARD_PASTE: 'clipboard_paste',
|
|
23
|
+
WAIT: 'computer_wait',
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Check if desktop capability is available based on request headers or context
|
|
27
|
+
* The Ranger Desktop Electron app sets these headers when connected:
|
|
28
|
+
* - X-Ranger-Desktop: true
|
|
29
|
+
* - X-Ranger-Desktop-Capable: true
|
|
30
|
+
*/
|
|
31
|
+
function hasDesktopCapability(req) {
|
|
32
|
+
if (!req?.headers) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
const desktopApp = req.headers['x-ranger-desktop'];
|
|
36
|
+
const desktopCapable = req.headers['x-ranger-desktop-capable'];
|
|
37
|
+
return desktopApp === 'true' || desktopCapable === 'true';
|
|
38
|
+
}
|
|
39
|
+
// Tool schemas
|
|
40
|
+
const ScreenshotSchema = z.object({});
|
|
41
|
+
const ClickSchema = z.object({
|
|
42
|
+
x: z.number().describe('X coordinate to click'),
|
|
43
|
+
y: z.number().describe('Y coordinate to click'),
|
|
44
|
+
});
|
|
45
|
+
const DoubleClickSchema = z.object({
|
|
46
|
+
x: z.number().describe('X coordinate to double-click'),
|
|
47
|
+
y: z.number().describe('Y coordinate to double-click'),
|
|
48
|
+
});
|
|
49
|
+
const RightClickSchema = z.object({
|
|
50
|
+
x: z.number().describe('X coordinate to right-click'),
|
|
51
|
+
y: z.number().describe('Y coordinate to right-click'),
|
|
52
|
+
});
|
|
53
|
+
const TypeSchema = z.object({
|
|
54
|
+
text: z.string().describe('Text to type'),
|
|
55
|
+
});
|
|
56
|
+
const KeySchema = z.object({
|
|
57
|
+
key: z
|
|
58
|
+
.string()
|
|
59
|
+
.describe('Key to press (e.g., "Enter", "Tab", "Escape", "Backspace", "Delete", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "Home", "End", "PageUp", "PageDown", "F1"-"F12")'),
|
|
60
|
+
});
|
|
61
|
+
const KeyComboSchema = z.object({
|
|
62
|
+
keys: z
|
|
63
|
+
.array(z.string())
|
|
64
|
+
.describe('Array of keys to press together (e.g., ["Control", "c"] for copy, ["Alt", "Tab"] for window switch)'),
|
|
65
|
+
});
|
|
66
|
+
const ScrollSchema = z.object({
|
|
67
|
+
x: z.number().describe('X coordinate to scroll at'),
|
|
68
|
+
y: z.number().describe('Y coordinate to scroll at'),
|
|
69
|
+
deltaX: z.number().optional().describe('Horizontal scroll amount (pixels)'),
|
|
70
|
+
deltaY: z.number().describe('Vertical scroll amount (pixels, negative = up, positive = down)'),
|
|
71
|
+
});
|
|
72
|
+
const DragSchema = z.object({
|
|
73
|
+
startX: z.number().describe('Starting X coordinate'),
|
|
74
|
+
startY: z.number().describe('Starting Y coordinate'),
|
|
75
|
+
endX: z.number().describe('Ending X coordinate'),
|
|
76
|
+
endY: z.number().describe('Ending Y coordinate'),
|
|
77
|
+
});
|
|
78
|
+
const GetActiveWindowSchema = z.object({});
|
|
79
|
+
const GetMousePositionSchema = z.object({});
|
|
80
|
+
const ClipboardReadSchema = z.object({});
|
|
81
|
+
const ClipboardWriteSchema = z.object({
|
|
82
|
+
text: z.string().describe('Text to write to clipboard'),
|
|
83
|
+
});
|
|
84
|
+
const ClipboardPasteSchema = z.object({});
|
|
85
|
+
const WaitSchema = z.object({
|
|
86
|
+
ms: z.number().describe('Milliseconds to wait'),
|
|
87
|
+
});
|
|
88
|
+
/**
|
|
89
|
+
* Format desktop action result for LLM consumption
|
|
90
|
+
*/
|
|
91
|
+
function formatResultForLLM(result, action) {
|
|
92
|
+
if (!result.success && result.error) {
|
|
93
|
+
return `Desktop action "${action}" failed: ${result.error}`;
|
|
94
|
+
}
|
|
95
|
+
const parts = [];
|
|
96
|
+
if (result.screenshot) {
|
|
97
|
+
parts.push(`Screenshot captured (${result.screenshot.width}x${result.screenshot.height})`);
|
|
98
|
+
// The base64 image will be handled separately by the message formatter
|
|
99
|
+
}
|
|
100
|
+
if (result.activeWindow) {
|
|
101
|
+
parts.push(`**Active Window:**`);
|
|
102
|
+
parts.push(` - Title: ${result.activeWindow.title}`);
|
|
103
|
+
parts.push(` - App: ${result.activeWindow.app}`);
|
|
104
|
+
if (result.activeWindow.bounds) {
|
|
105
|
+
const b = result.activeWindow.bounds;
|
|
106
|
+
parts.push(` - Position: (${b.x}, ${b.y})`);
|
|
107
|
+
parts.push(` - Size: ${b.width}x${b.height}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (result.mousePosition) {
|
|
111
|
+
parts.push(`**Mouse Position:** (${result.mousePosition.x}, ${result.mousePosition.y})`);
|
|
112
|
+
}
|
|
113
|
+
if (result.clipboard !== undefined) {
|
|
114
|
+
parts.push(`**Clipboard Content:** ${result.clipboard}`);
|
|
115
|
+
}
|
|
116
|
+
if (parts.length === 0) {
|
|
117
|
+
parts.push(`Desktop action "${action}" completed successfully.`);
|
|
118
|
+
}
|
|
119
|
+
return parts.join('\n');
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a tool result (either wait for callback or return marker)
|
|
123
|
+
*/
|
|
124
|
+
async function createToolResult(action, args, config, waitForResult) {
|
|
125
|
+
const toolCallId = config?.toolCall?.id || `desktop-${Date.now()}`;
|
|
126
|
+
if (waitForResult) {
|
|
127
|
+
// Server context: wait for actual result from Electron app
|
|
128
|
+
try {
|
|
129
|
+
const result = await waitForResult(action, args, toolCallId);
|
|
130
|
+
return formatResultForLLM(result, action);
|
|
131
|
+
}
|
|
132
|
+
catch (error) {
|
|
133
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
134
|
+
return `Desktop action "${action}" failed: ${errorMessage}`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Non-server context: return marker for later processing
|
|
138
|
+
const response = {
|
|
139
|
+
requiresDesktopExecution: true,
|
|
140
|
+
action,
|
|
141
|
+
args,
|
|
142
|
+
toolCallId,
|
|
143
|
+
};
|
|
144
|
+
return JSON.stringify(response);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Create desktop automation tools for the agent
|
|
148
|
+
* These tools allow AI to control the user's desktop when Ranger Desktop is running
|
|
149
|
+
*/
|
|
150
|
+
function createDesktopTools(options = {}) {
|
|
151
|
+
const { waitForResult } = options;
|
|
152
|
+
return [
|
|
153
|
+
// computer_screenshot
|
|
154
|
+
tool(async (_args, config) => {
|
|
155
|
+
return createToolResult(EDesktopTools.SCREENSHOT, {}, config, waitForResult);
|
|
156
|
+
}, {
|
|
157
|
+
name: EDesktopTools.SCREENSHOT,
|
|
158
|
+
description: 'Take a screenshot of the entire screen. Use this to see what is currently displayed on the desktop.',
|
|
159
|
+
schema: ScreenshotSchema,
|
|
160
|
+
}),
|
|
161
|
+
// computer_click
|
|
162
|
+
tool(async (args, config) => {
|
|
163
|
+
return createToolResult(EDesktopTools.CLICK, args, config, waitForResult);
|
|
164
|
+
}, {
|
|
165
|
+
name: EDesktopTools.CLICK,
|
|
166
|
+
description: 'Click the mouse at the specified screen coordinates. Use screenshot first to identify the target location.',
|
|
167
|
+
schema: ClickSchema,
|
|
168
|
+
}),
|
|
169
|
+
// computer_double_click
|
|
170
|
+
tool(async (args, config) => {
|
|
171
|
+
return createToolResult(EDesktopTools.DOUBLE_CLICK, args, config, waitForResult);
|
|
172
|
+
}, {
|
|
173
|
+
name: EDesktopTools.DOUBLE_CLICK,
|
|
174
|
+
description: 'Double-click the mouse at the specified screen coordinates.',
|
|
175
|
+
schema: DoubleClickSchema,
|
|
176
|
+
}),
|
|
177
|
+
// computer_right_click
|
|
178
|
+
tool(async (args, config) => {
|
|
179
|
+
return createToolResult(EDesktopTools.RIGHT_CLICK, args, config, waitForResult);
|
|
180
|
+
}, {
|
|
181
|
+
name: EDesktopTools.RIGHT_CLICK,
|
|
182
|
+
description: 'Right-click the mouse at the specified screen coordinates to open context menus.',
|
|
183
|
+
schema: RightClickSchema,
|
|
184
|
+
}),
|
|
185
|
+
// computer_type
|
|
186
|
+
tool(async (args, config) => {
|
|
187
|
+
return createToolResult(EDesktopTools.TYPE, args, config, waitForResult);
|
|
188
|
+
}, {
|
|
189
|
+
name: EDesktopTools.TYPE,
|
|
190
|
+
description: 'Type text using the keyboard. Make sure the target input field is focused first (use click).',
|
|
191
|
+
schema: TypeSchema,
|
|
192
|
+
}),
|
|
193
|
+
// computer_key
|
|
194
|
+
tool(async (args, config) => {
|
|
195
|
+
return createToolResult(EDesktopTools.KEY, args, config, waitForResult);
|
|
196
|
+
}, {
|
|
197
|
+
name: EDesktopTools.KEY,
|
|
198
|
+
description: 'Press a single key on the keyboard (Enter, Tab, Escape, arrow keys, function keys, etc.).',
|
|
199
|
+
schema: KeySchema,
|
|
200
|
+
}),
|
|
201
|
+
// computer_key_combo
|
|
202
|
+
tool(async (args, config) => {
|
|
203
|
+
return createToolResult(EDesktopTools.KEY_COMBO, args, config, waitForResult);
|
|
204
|
+
}, {
|
|
205
|
+
name: EDesktopTools.KEY_COMBO,
|
|
206
|
+
description: 'Press a key combination (e.g., Ctrl+C to copy, Ctrl+V to paste, Alt+Tab to switch windows).',
|
|
207
|
+
schema: KeyComboSchema,
|
|
208
|
+
}),
|
|
209
|
+
// computer_scroll
|
|
210
|
+
tool(async (args, config) => {
|
|
211
|
+
return createToolResult(EDesktopTools.SCROLL, args, config, waitForResult);
|
|
212
|
+
}, {
|
|
213
|
+
name: EDesktopTools.SCROLL,
|
|
214
|
+
description: 'Scroll at the specified screen coordinates. Use negative deltaY to scroll up, positive to scroll down.',
|
|
215
|
+
schema: ScrollSchema,
|
|
216
|
+
}),
|
|
217
|
+
// computer_drag
|
|
218
|
+
tool(async (args, config) => {
|
|
219
|
+
return createToolResult(EDesktopTools.DRAG, args, config, waitForResult);
|
|
220
|
+
}, {
|
|
221
|
+
name: EDesktopTools.DRAG,
|
|
222
|
+
description: 'Drag the mouse from one position to another (for moving windows, selecting text, etc.).',
|
|
223
|
+
schema: DragSchema,
|
|
224
|
+
}),
|
|
225
|
+
// computer_get_active_window
|
|
226
|
+
tool(async (_args, config) => {
|
|
227
|
+
return createToolResult(EDesktopTools.GET_ACTIVE_WINDOW, {}, config, waitForResult);
|
|
228
|
+
}, {
|
|
229
|
+
name: EDesktopTools.GET_ACTIVE_WINDOW,
|
|
230
|
+
description: 'Get information about the currently active window (title, application name, position, size).',
|
|
231
|
+
schema: GetActiveWindowSchema,
|
|
232
|
+
}),
|
|
233
|
+
// computer_get_mouse_position
|
|
234
|
+
tool(async (_args, config) => {
|
|
235
|
+
return createToolResult(EDesktopTools.GET_MOUSE_POSITION, {}, config, waitForResult);
|
|
236
|
+
}, {
|
|
237
|
+
name: EDesktopTools.GET_MOUSE_POSITION,
|
|
238
|
+
description: 'Get the current mouse cursor position on screen.',
|
|
239
|
+
schema: GetMousePositionSchema,
|
|
240
|
+
}),
|
|
241
|
+
// clipboard_read
|
|
242
|
+
tool(async (_args, config) => {
|
|
243
|
+
return createToolResult(EDesktopTools.CLIPBOARD_READ, {}, config, waitForResult);
|
|
244
|
+
}, {
|
|
245
|
+
name: EDesktopTools.CLIPBOARD_READ,
|
|
246
|
+
description: 'Read the current contents of the system clipboard.',
|
|
247
|
+
schema: ClipboardReadSchema,
|
|
248
|
+
}),
|
|
249
|
+
// clipboard_write
|
|
250
|
+
tool(async (args, config) => {
|
|
251
|
+
return createToolResult(EDesktopTools.CLIPBOARD_WRITE, args, config, waitForResult);
|
|
252
|
+
}, {
|
|
253
|
+
name: EDesktopTools.CLIPBOARD_WRITE,
|
|
254
|
+
description: 'Write text to the system clipboard.',
|
|
255
|
+
schema: ClipboardWriteSchema,
|
|
256
|
+
}),
|
|
257
|
+
// clipboard_paste
|
|
258
|
+
tool(async (_args, config) => {
|
|
259
|
+
return createToolResult(EDesktopTools.CLIPBOARD_PASTE, {}, config, waitForResult);
|
|
260
|
+
}, {
|
|
261
|
+
name: EDesktopTools.CLIPBOARD_PASTE,
|
|
262
|
+
description: 'Paste the clipboard contents (equivalent to Ctrl+V). Use clipboard_write first to set the content.',
|
|
263
|
+
schema: ClipboardPasteSchema,
|
|
264
|
+
}),
|
|
265
|
+
// computer_wait
|
|
266
|
+
tool(async (args, config) => {
|
|
267
|
+
return createToolResult(EDesktopTools.WAIT, args, config, waitForResult);
|
|
268
|
+
}, {
|
|
269
|
+
name: EDesktopTools.WAIT,
|
|
270
|
+
description: 'Wait for the specified number of milliseconds. Use this to wait for UI animations or loading.',
|
|
271
|
+
schema: WaitSchema,
|
|
272
|
+
}),
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Get all desktop tool names
|
|
277
|
+
*/
|
|
278
|
+
function getDesktopToolNames() {
|
|
279
|
+
return Object.values(EDesktopTools);
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Check if a tool name is a desktop tool
|
|
283
|
+
*/
|
|
284
|
+
function isDesktopTool(name) {
|
|
285
|
+
return Object.values(EDesktopTools).includes(name);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export { EDesktopTools, createDesktopTools, getDesktopToolNames, hasDesktopCapability, isDesktopTool };
|
|
289
|
+
//# sourceMappingURL=DesktopTools.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DesktopTools.mjs","sources":["../../../src/tools/DesktopTools.ts"],"sourcesContent":["import { z } from 'zod';\r\nimport { tool, DynamicStructuredTool } from '@langchain/core/tools';\r\n\r\n/**\r\n * Type for tool configuration passed by LangChain runtime\r\n */\r\ntype ToolCallConfig = { toolCall?: { id?: string } };\r\n\r\n/**\r\n * Desktop tool names - keep in sync with Ranger Desktop Electron app\r\n * These tools execute locally in the Electron app, NOT on the server\r\n */\r\nexport const EDesktopTools = {\r\n SCREENSHOT: 'computer_screenshot',\r\n CLICK: 'computer_click',\r\n DOUBLE_CLICK: 'computer_double_click',\r\n RIGHT_CLICK: 'computer_right_click',\r\n TYPE: 'computer_type',\r\n KEY: 'computer_key',\r\n KEY_COMBO: 'computer_key_combo',\r\n SCROLL: 'computer_scroll',\r\n DRAG: 'computer_drag',\r\n GET_ACTIVE_WINDOW: 'computer_get_active_window',\r\n GET_MOUSE_POSITION: 'computer_get_mouse_position',\r\n CLIPBOARD_READ: 'clipboard_read',\r\n CLIPBOARD_WRITE: 'clipboard_write',\r\n CLIPBOARD_PASTE: 'clipboard_paste',\r\n WAIT: 'computer_wait',\r\n} as const;\r\n\r\nexport type DesktopToolName =\r\n (typeof EDesktopTools)[keyof typeof EDesktopTools];\r\n\r\n/**\r\n * Callback function type for waiting on desktop action results\r\n * This allows the server (Ranger) to provide a callback that waits for the Electron app\r\n * to POST results back to the server before returning to the LLM.\r\n *\r\n * @param action - The desktop action (click, type, screenshot, etc.)\r\n * @param args - Arguments for the action\r\n * @param toolCallId - Unique ID for this tool call (from config.toolCall.id)\r\n * @returns Promise that resolves with the actual desktop result\r\n */\r\nexport type DesktopToolCallback = (\r\n action: string,\r\n args: Record<string, unknown>,\r\n toolCallId: string\r\n) => Promise<DesktopActionResult>;\r\n\r\n/**\r\n * Result returned from desktop action execution\r\n */\r\nexport interface DesktopActionResult {\r\n success: boolean;\r\n error?: string;\r\n screenshot?: {\r\n base64: string;\r\n width: number;\r\n height: number;\r\n };\r\n activeWindow?: {\r\n title: string;\r\n app: string;\r\n bounds?: { x: number; y: number; width: number; height: number };\r\n };\r\n mousePosition?: { x: number; y: number };\r\n clipboard?: string;\r\n}\r\n\r\n/**\r\n * Check if desktop capability is available based on request headers or context\r\n * The Ranger Desktop Electron app sets these headers when connected:\r\n * - X-Ranger-Desktop: true\r\n * - X-Ranger-Desktop-Capable: true\r\n */\r\nexport function hasDesktopCapability(req?: {\r\n headers?: Record<string, string | string[] | undefined>;\r\n}): boolean {\r\n if (!req?.headers) {\r\n return false;\r\n }\r\n\r\n const desktopApp = req.headers['x-ranger-desktop'];\r\n const desktopCapable = req.headers['x-ranger-desktop-capable'];\r\n\r\n return desktopApp === 'true' || desktopCapable === 'true';\r\n}\r\n\r\n// Tool schemas\r\nconst ScreenshotSchema = z.object({});\r\n\r\nconst ClickSchema = z.object({\r\n x: z.number().describe('X coordinate to click'),\r\n y: z.number().describe('Y coordinate to click'),\r\n});\r\n\r\nconst DoubleClickSchema = z.object({\r\n x: z.number().describe('X coordinate to double-click'),\r\n y: z.number().describe('Y coordinate to double-click'),\r\n});\r\n\r\nconst RightClickSchema = z.object({\r\n x: z.number().describe('X coordinate to right-click'),\r\n y: z.number().describe('Y coordinate to right-click'),\r\n});\r\n\r\nconst TypeSchema = z.object({\r\n text: z.string().describe('Text to type'),\r\n});\r\n\r\nconst KeySchema = z.object({\r\n key: z\r\n .string()\r\n .describe(\r\n 'Key to press (e.g., \"Enter\", \"Tab\", \"Escape\", \"Backspace\", \"Delete\", \"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\", \"Home\", \"End\", \"PageUp\", \"PageDown\", \"F1\"-\"F12\")'\r\n ),\r\n});\r\n\r\nconst KeyComboSchema = z.object({\r\n keys: z\r\n .array(z.string())\r\n .describe(\r\n 'Array of keys to press together (e.g., [\"Control\", \"c\"] for copy, [\"Alt\", \"Tab\"] for window switch)'\r\n ),\r\n});\r\n\r\nconst ScrollSchema = z.object({\r\n x: z.number().describe('X coordinate to scroll at'),\r\n y: z.number().describe('Y coordinate to scroll at'),\r\n deltaX: z.number().optional().describe('Horizontal scroll amount (pixels)'),\r\n deltaY: z.number().describe('Vertical scroll amount (pixels, negative = up, positive = down)'),\r\n});\r\n\r\nconst DragSchema = z.object({\r\n startX: z.number().describe('Starting X coordinate'),\r\n startY: z.number().describe('Starting Y coordinate'),\r\n endX: z.number().describe('Ending X coordinate'),\r\n endY: z.number().describe('Ending Y coordinate'),\r\n});\r\n\r\nconst GetActiveWindowSchema = z.object({});\r\n\r\nconst GetMousePositionSchema = z.object({});\r\n\r\nconst ClipboardReadSchema = z.object({});\r\n\r\nconst ClipboardWriteSchema = z.object({\r\n text: z.string().describe('Text to write to clipboard'),\r\n});\r\n\r\nconst ClipboardPasteSchema = z.object({});\r\n\r\nconst WaitSchema = z.object({\r\n ms: z.number().describe('Milliseconds to wait'),\r\n});\r\n\r\n/**\r\n * Desktop tool response interface\r\n * This is what the Electron app returns after executing the action\r\n */\r\nexport interface DesktopToolResponse {\r\n requiresDesktopExecution: true;\r\n action: string;\r\n args: Record<string, unknown>;\r\n toolCallId?: string;\r\n}\r\n\r\n/**\r\n * Options for creating desktop tools\r\n */\r\nexport interface CreateDesktopToolsOptions {\r\n /**\r\n * Optional callback that waits for desktop action results.\r\n * When provided, tools will await this callback to get actual results from the Electron app.\r\n * When not provided, tools return markers immediately (for non-server contexts).\r\n */\r\n waitForResult?: DesktopToolCallback;\r\n}\r\n\r\n/**\r\n * Format desktop action result for LLM consumption\r\n */\r\nfunction formatResultForLLM(\r\n result: DesktopActionResult,\r\n action: string\r\n): string {\r\n if (!result.success && result.error) {\r\n return `Desktop action \"${action}\" failed: ${result.error}`;\r\n }\r\n\r\n const parts: string[] = [];\r\n\r\n if (result.screenshot) {\r\n parts.push(\r\n `Screenshot captured (${result.screenshot.width}x${result.screenshot.height})`\r\n );\r\n // The base64 image will be handled separately by the message formatter\r\n }\r\n\r\n if (result.activeWindow) {\r\n parts.push(`**Active Window:**`);\r\n parts.push(` - Title: ${result.activeWindow.title}`);\r\n parts.push(` - App: ${result.activeWindow.app}`);\r\n if (result.activeWindow.bounds) {\r\n const b = result.activeWindow.bounds;\r\n parts.push(` - Position: (${b.x}, ${b.y})`);\r\n parts.push(` - Size: ${b.width}x${b.height}`);\r\n }\r\n }\r\n\r\n if (result.mousePosition) {\r\n parts.push(\r\n `**Mouse Position:** (${result.mousePosition.x}, ${result.mousePosition.y})`\r\n );\r\n }\r\n\r\n if (result.clipboard !== undefined) {\r\n parts.push(`**Clipboard Content:** ${result.clipboard}`);\r\n }\r\n\r\n if (parts.length === 0) {\r\n parts.push(`Desktop action \"${action}\" completed successfully.`);\r\n }\r\n\r\n return parts.join('\\n');\r\n}\r\n\r\n/**\r\n * Create a tool result (either wait for callback or return marker)\r\n */\r\nasync function createToolResult(\r\n action: string,\r\n args: Record<string, unknown>,\r\n config: ToolCallConfig | undefined,\r\n waitForResult?: DesktopToolCallback\r\n): Promise<string> {\r\n const toolCallId = config?.toolCall?.id || `desktop-${Date.now()}`;\r\n\r\n if (waitForResult) {\r\n // Server context: wait for actual result from Electron app\r\n try {\r\n const result = await waitForResult(action, args, toolCallId);\r\n return formatResultForLLM(result, action);\r\n } catch (error) {\r\n const errorMessage =\r\n error instanceof Error ? error.message : String(error);\r\n return `Desktop action \"${action}\" failed: ${errorMessage}`;\r\n }\r\n }\r\n\r\n // Non-server context: return marker for later processing\r\n const response: DesktopToolResponse = {\r\n requiresDesktopExecution: true,\r\n action,\r\n args,\r\n toolCallId,\r\n };\r\n return JSON.stringify(response);\r\n}\r\n\r\n/**\r\n * Create desktop automation tools for the agent\r\n * These tools allow AI to control the user's desktop when Ranger Desktop is running\r\n */\r\nexport function createDesktopTools(\r\n options: CreateDesktopToolsOptions = {}\r\n): DynamicStructuredTool[] {\r\n const { waitForResult } = options;\r\n\r\n return [\r\n // computer_screenshot\r\n tool(\r\n async (_args, config) => {\r\n return createToolResult(\r\n EDesktopTools.SCREENSHOT,\r\n {},\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.SCREENSHOT,\r\n description:\r\n 'Take a screenshot of the entire screen. Use this to see what is currently displayed on the desktop.',\r\n schema: ScreenshotSchema,\r\n }\r\n ),\r\n\r\n // computer_click\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.CLICK,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.CLICK,\r\n description:\r\n 'Click the mouse at the specified screen coordinates. Use screenshot first to identify the target location.',\r\n schema: ClickSchema,\r\n }\r\n ),\r\n\r\n // computer_double_click\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.DOUBLE_CLICK,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.DOUBLE_CLICK,\r\n description:\r\n 'Double-click the mouse at the specified screen coordinates.',\r\n schema: DoubleClickSchema,\r\n }\r\n ),\r\n\r\n // computer_right_click\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.RIGHT_CLICK,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.RIGHT_CLICK,\r\n description:\r\n 'Right-click the mouse at the specified screen coordinates to open context menus.',\r\n schema: RightClickSchema,\r\n }\r\n ),\r\n\r\n // computer_type\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.TYPE,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.TYPE,\r\n description:\r\n 'Type text using the keyboard. Make sure the target input field is focused first (use click).',\r\n schema: TypeSchema,\r\n }\r\n ),\r\n\r\n // computer_key\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.KEY,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.KEY,\r\n description:\r\n 'Press a single key on the keyboard (Enter, Tab, Escape, arrow keys, function keys, etc.).',\r\n schema: KeySchema,\r\n }\r\n ),\r\n\r\n // computer_key_combo\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.KEY_COMBO,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.KEY_COMBO,\r\n description:\r\n 'Press a key combination (e.g., Ctrl+C to copy, Ctrl+V to paste, Alt+Tab to switch windows).',\r\n schema: KeyComboSchema,\r\n }\r\n ),\r\n\r\n // computer_scroll\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.SCROLL,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.SCROLL,\r\n description:\r\n 'Scroll at the specified screen coordinates. Use negative deltaY to scroll up, positive to scroll down.',\r\n schema: ScrollSchema,\r\n }\r\n ),\r\n\r\n // computer_drag\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.DRAG,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.DRAG,\r\n description:\r\n 'Drag the mouse from one position to another (for moving windows, selecting text, etc.).',\r\n schema: DragSchema,\r\n }\r\n ),\r\n\r\n // computer_get_active_window\r\n tool(\r\n async (_args, config) => {\r\n return createToolResult(\r\n EDesktopTools.GET_ACTIVE_WINDOW,\r\n {},\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.GET_ACTIVE_WINDOW,\r\n description:\r\n 'Get information about the currently active window (title, application name, position, size).',\r\n schema: GetActiveWindowSchema,\r\n }\r\n ),\r\n\r\n // computer_get_mouse_position\r\n tool(\r\n async (_args, config) => {\r\n return createToolResult(\r\n EDesktopTools.GET_MOUSE_POSITION,\r\n {},\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.GET_MOUSE_POSITION,\r\n description: 'Get the current mouse cursor position on screen.',\r\n schema: GetMousePositionSchema,\r\n }\r\n ),\r\n\r\n // clipboard_read\r\n tool(\r\n async (_args, config) => {\r\n return createToolResult(\r\n EDesktopTools.CLIPBOARD_READ,\r\n {},\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.CLIPBOARD_READ,\r\n description: 'Read the current contents of the system clipboard.',\r\n schema: ClipboardReadSchema,\r\n }\r\n ),\r\n\r\n // clipboard_write\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.CLIPBOARD_WRITE,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.CLIPBOARD_WRITE,\r\n description: 'Write text to the system clipboard.',\r\n schema: ClipboardWriteSchema,\r\n }\r\n ),\r\n\r\n // clipboard_paste\r\n tool(\r\n async (_args, config) => {\r\n return createToolResult(\r\n EDesktopTools.CLIPBOARD_PASTE,\r\n {},\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.CLIPBOARD_PASTE,\r\n description:\r\n 'Paste the clipboard contents (equivalent to Ctrl+V). Use clipboard_write first to set the content.',\r\n schema: ClipboardPasteSchema,\r\n }\r\n ),\r\n\r\n // computer_wait\r\n tool(\r\n async (args, config) => {\r\n return createToolResult(\r\n EDesktopTools.WAIT,\r\n args,\r\n config as ToolCallConfig,\r\n waitForResult\r\n );\r\n },\r\n {\r\n name: EDesktopTools.WAIT,\r\n description:\r\n 'Wait for the specified number of milliseconds. Use this to wait for UI animations or loading.',\r\n schema: WaitSchema,\r\n }\r\n ),\r\n ];\r\n}\r\n\r\n/**\r\n * Get all desktop tool names\r\n */\r\nexport function getDesktopToolNames(): DesktopToolName[] {\r\n return Object.values(EDesktopTools);\r\n}\r\n\r\n/**\r\n * Check if a tool name is a desktop tool\r\n */\r\nexport function isDesktopTool(name: string): name is DesktopToolName {\r\n return Object.values(EDesktopTools).includes(name as DesktopToolName);\r\n}\r\n"],"names":[],"mappings":";;;AAQA;;;AAGG;AACU,MAAA,aAAa,GAAG;AAC3B,IAAA,UAAU,EAAE,qBAAqB;AACjC,IAAA,KAAK,EAAE,gBAAgB;AACvB,IAAA,YAAY,EAAE,uBAAuB;AACrC,IAAA,WAAW,EAAE,sBAAsB;AACnC,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,GAAG,EAAE,cAAc;AACnB,IAAA,SAAS,EAAE,oBAAoB;AAC/B,IAAA,MAAM,EAAE,iBAAiB;AACzB,IAAA,IAAI,EAAE,eAAe;AACrB,IAAA,iBAAiB,EAAE,4BAA4B;AAC/C,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}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from './graphs';
|
|
|
7
7
|
export * from './tools/Calculator';
|
|
8
8
|
export * from './tools/CodeExecutor';
|
|
9
9
|
export * from './tools/BrowserTools';
|
|
10
|
+
export * from './tools/DesktopTools';
|
|
10
11
|
export * from './tools/ProgrammaticToolCalling';
|
|
11
12
|
export * from './tools/ToolSearch';
|
|
12
13
|
export * from './tools/handlers';
|