@c8y/ngx-components 1023.68.6 → 1023.70.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ai/agent-chat/index.d.ts +235 -75
- package/ai/agent-chat/index.d.ts.map +1 -1
- package/ai/ai-chat/index.d.ts +176 -26
- package/ai/ai-chat/index.d.ts.map +1 -1
- package/ai/index.d.ts +309 -75
- package/ai/index.d.ts.map +1 -1
- package/asset-properties/index.d.ts.map +1 -1
- package/echart/index.d.ts +4 -0
- package/echart/index.d.ts.map +1 -1
- package/echart/models/index.d.ts +2 -0
- package/echart/models/index.d.ts.map +1 -1
- package/fesm2022/c8y-ngx-components-ai-agent-chat.mjs +680 -242
- package/fesm2022/c8y-ngx-components-ai-agent-chat.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-ai-ai-chat.mjs +343 -44
- package/fesm2022/c8y-ngx-components-ai-ai-chat.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-ai.mjs +187 -75
- package/fesm2022/c8y-ngx-components-ai.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-asset-properties.mjs +11 -5
- package/fesm2022/c8y-ngx-components-asset-properties.mjs.map +1 -1
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-alarm-count-config.component-B2cy8gI7.mjs → c8y-ngx-components-computed-asset-properties-alarm-count-config.component-CPLDClTp.mjs} +3 -3
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-alarm-count-config.component-B2cy8gI7.mjs.map → c8y-ngx-components-computed-asset-properties-alarm-count-config.component-CPLDClTp.mjs.map} +1 -1
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-BYHnA-5R.mjs → c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-9be_iMQg.mjs} +30 -13
- package/fesm2022/c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-9be_iMQg.mjs.map +1 -0
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-configuration-snapshot-config.component-C4oL39m8.mjs → c8y-ngx-components-computed-asset-properties-configuration-snapshot-config.component-B2em01_W.mjs} +3 -3
- package/fesm2022/c8y-ngx-components-computed-asset-properties-configuration-snapshot-config.component-B2em01_W.mjs.map +1 -0
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-event-count-config.component-DGwm6_C9.mjs → c8y-ngx-components-computed-asset-properties-event-count-config.component-CQuGa1RI.mjs} +3 -3
- package/fesm2022/c8y-ngx-components-computed-asset-properties-event-count-config.component-CQuGa1RI.mjs.map +1 -0
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-BxfCjbYY.mjs → c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-CkmurxJv.mjs} +5 -5
- package/fesm2022/{c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-BxfCjbYY.mjs.map → c8y-ngx-components-computed-asset-properties-fieldbus-item-status-config.component-CkmurxJv.mjs.map} +1 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties-last-measurement-config.component-CTK9zNUh.mjs +86 -0
- package/fesm2022/c8y-ngx-components-computed-asset-properties-last-measurement-config.component-CTK9zNUh.mjs.map +1 -0
- package/fesm2022/c8y-ngx-components-computed-asset-properties.mjs +1 -1
- package/fesm2022/c8y-ngx-components-echart-models.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-echart.mjs +39 -18
- package/fesm2022/c8y-ngx-components-echart.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-definitions-html-widget-ai-config.mjs +106 -4
- package/fesm2022/c8y-ngx-components-widgets-definitions-html-widget-ai-config.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components-widgets-implementations-html-widget.mjs +14 -122
- package/fesm2022/c8y-ngx-components-widgets-implementations-html-widget.mjs.map +1 -1
- package/fesm2022/c8y-ngx-components.mjs +15 -13
- package/fesm2022/c8y-ngx-components.mjs.map +1 -1
- package/index.d.ts.map +1 -1
- package/locales/de.po +3 -0
- package/locales/es.po +3 -0
- package/locales/fr.po +3 -0
- package/locales/ja_JP.po +3 -0
- package/locales/ko.po +3 -0
- package/locales/locales.pot +83 -30
- package/locales/nl.po +3 -0
- package/locales/pl.po +3 -0
- package/locales/pt_BR.po +3 -0
- package/locales/zh_CN.po +3 -0
- package/locales/zh_TW.po +3 -0
- package/package.json +1 -1
- package/widgets/implementations/html-widget/index.d.ts +11 -50
- package/widgets/implementations/html-widget/index.d.ts.map +1 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties-c8y-ngx-components-computed-asset-properties-BYHnA-5R.mjs.map +0 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties-configuration-snapshot-config.component-C4oL39m8.mjs.map +0 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties-event-count-config.component-DGwm6_C9.mjs.map +0 -1
- package/fesm2022/c8y-ngx-components-computed-asset-properties-last-measurement-config.component-C1cuxN3L.mjs +0 -92
- package/fesm2022/c8y-ngx-components-computed-asset-properties-last-measurement-config.component-C1cuxN3L.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c8y-ngx-components-ai.mjs","sources":["../../ai/ai.model.ts","../../ai/ai.service.ts","../../ai/c8y-ngx-components-ai.ts"],"sourcesContent":["import { Type } from '@angular/core';\nimport { Observable } from 'rxjs';\n\nexport interface AIMessageStreamSteps extends AIMessage {\n componentSteps$?: Observable<{ content: Type<any> | string; origin: AgentStep }[]>;\n}\n\nexport interface AIMessage {\n role: 'user' | 'assistant';\n content: string;\n options?: AIMessageOptions;\n steps?: Array<AgentStep>;\n finishReason?: 'stop' | 'error' | 'tool_use';\n timestamp?: string;\n}\n\nexport interface AIMessageOptions {\n skipToLLM?: boolean;\n hiddenContent?: string;\n variables?: { [key: string]: any };\n}\n\nexport enum DataStreamType {\n TEXT_DELTA = 'text-delta',\n TOOL_CALL = 'tool-call',\n TOOL_INPUT_START = 'tool-input-start',\n TOOL_INPUT_DELTA = 'tool-input-delta',\n TOOL_CALL_STREAMING = 'tool-call-streaming',\n TOOL_CALL_DELTA = 'tool-call-delta',\n TOOL_RESULT = 'tool-result',\n REASONING = 'reasoning',\n REASONING_DELTA = 'reasoning-delta',\n REDACTED_REASONING = 'redacted-reasoning',\n REASONING_SIGNATURE = 'reasoning-signature',\n FINISH_REASONING = 'finish-reasoning',\n FINISH = 'finish',\n FINISH_STEP = 'finish-step',\n ERROR = 'error',\n DATA = 'data',\n MESSAGE_ANNOTATIONS = 'message-annotations',\n SOURCE = 'source',\n FILE = 'file',\n STEP_START = 'start-step',\n STEP_FINISH = 'finish-step',\n STEP_START_V4 = 'step-start',\n STEP_FINISH_V4 = 'step-finish'\n}\n\nexport type AgentStep = {\n type: 'text' | 'reasoning' | string;\n text: string;\n reasoning?: string;\n textDelta?: string;\n toolCalls?: Array<ToolCall>;\n toolResults?: Array<ToolResult>;\n aborted?: boolean;\n};\n\nexport interface Tool {\n toolName: string;\n toolCallId: string;\n type: 'tool-call' | 'tool-result';\n}\n\nexport interface ToolCall extends Tool {\n arguments: { [key: string]: any };\n}\n\nexport interface ToolResult extends Tool {\n input: any;\n output: {\n content: {\n text: string;\n type: string;\n }[];\n };\n}\n\nexport interface ClientAgentDefinition {\n /**\n * If set to true, the agent will use the test endpoint to generate responses.\n * This is useful for development and testing purposes, but requires agent admin\n * privileges.\n */\n snapshot: boolean;\n /**\n * The label of the agent that is shown to the user.\n */\n label: string;\n /**\n * The definition of the agent to use\n */\n definition: AgentDefinition;\n}\n\nexport interface AgentDefinition {\n name: string;\n type: 'object' | 'text';\n agent: {\n system: string;\n [key: string]: any;\n };\n mcp: Array<{ serverName: string; tools: string[] }>;\n}\n\nexport interface ChatConfig {\n title: string;\n headline: string;\n welcomeText: string;\n placeholder: string;\n placeholderAfterFirstMessage: string;\n sendButtonText: string;\n cancelButtonText: string;\n disclaimerText: string;\n userInterfaceIcons: { send: string; cancel: string };\n}\n\nexport interface AgentHealthCheckResponse {\n /**\n * Indicates if the agent exists and can be used.\n * If false, the agent was not found.\n */\n exists: boolean;\n /**\n * Indicates if the user can create the agent, and if a global provider is configured.\n */\n canCreate: boolean;\n /**\n * Indicates if the provider is configured.\n * If false, the agent cannot be created as the provider is not configured.\n */\n isProviderConfigured: boolean;\n /**\n * If canCreate or exist is false, this array contains messages\n * that explain why the agent cannot be used or created.\n */\n messages?: string[];\n}\n","import { inject, Injectable } from '@angular/core';\nimport { FetchClient } from '@c8y/client';\nimport { Observable } from 'rxjs';\nimport {\n AgentDefinition,\n AgentHealthCheckResponse,\n AIMessage,\n ClientAgentDefinition,\n DataStreamType\n} from './ai.model';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AIService {\n private baseUrl = '/service/ai';\n\n private client = inject(FetchClient);\n\n /**\n * Creates or updates an agent.\n * @param def The agent definition\n */\n async createOrUpdateAgent(def: AgentDefinition): Promise<void> {\n const health = await this.getAgentHealth(def.name);\n let resource = `${this.baseUrl}/agent/${def.type}`;\n let method = 'POST';\n if (health.exists) {\n resource = `${this.baseUrl}/agent/${def.type}/${def.name}`;\n method = 'PUT';\n }\n const response = await this.client.fetch(resource, {\n body: JSON.stringify(def),\n method,\n headers: { 'Content-Type': 'application/json' }\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create agent: ${response.statusText}`);\n }\n }\n\n /**\n * Check if an agent exists.\n * @param name Agent name (optional)\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns Agent health check response.\n */\n async getAgentHealth(name = '', fromApp?: string): Promise<AgentHealthCheckResponse> {\n const response = await this.client.fetch(\n `${this.baseUrl}/agent/test/${name || crypto.randomUUID()}${fromApp ? `?fromApp=${fromApp}` : ''}`,\n {\n method: 'GET',\n headers: { 'Content-Type': 'application/json' }\n }\n );\n\n if (!response.ok) {\n return {\n exists: false,\n canCreate: false,\n isProviderConfigured: false\n };\n }\n const json = await response.json();\n return json;\n }\n\n /**\n * Send a text message to the agent.\n * @param name Agent name\n * @param messages Messages to send\n * @param variables Variables to include\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns Text response from the agent.\n */\n async text(\n name: string,\n messages: AIMessage[],\n variables: { [key: string]: any },\n fromApp?: string\n ): Promise<string> {\n const parsedMessages = this.parseMessages(messages);\n\n const data = this.client.fetch(\n `${this.baseUrl}/agent/text/${name}${fromApp ? `?fromApp=${fromApp}` : ''}`,\n {\n body: JSON.stringify({ messages: parsedMessages, variables }),\n method: 'POST',\n headers: { 'Content-Type': 'application/json' }\n }\n );\n\n const response = await data;\n if (!response.ok) {\n throw new Error(`Failed to talk with agent: ${response.statusText}`);\n }\n const text = await response.text();\n return text;\n }\n\n /**\n * Stream a text message to the agent.\n * @param agent Agent name or an agent definition.\n * @param messages Messages to send\n * @param variables Variables to include\n * @param abortController An AbortController to cancel the request.\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns An observable that emits partial AIMessage objects as they are received. The observable can be cancelled using the provided AbortController.\n * The observable will emit an error if the request fails or is aborted.\n * The observable will complete when the stream is finished.\n *\n * The messages sent to the agent can include special options:\n * - `hiddenContent`: If set, this content will be sent to the agent instead of the `content` field.\n * - `skipToLLM`: If set to true, this message will be skipped when sending to the agent.\n *\n * Example usage:\n * ```typescript\n * const abortController = new AbortController();\n * const messages: AIMessage[] = [\n * { role: 'user', content: 'Hello' },\n * { role: 'assistant', content: 'Hi there!' },\n * { role: 'user', content: 'Tell me a joke.', options: { hiddenContent: 'Tell me a joke about cats.' } }\n * ];\n * const observable = aiService.stream$('my-agent', messages, {}, abortController);\n * const subscription = observable.subscribe({\n * next: (message) => console.log('Received message part:', message),\n * error: (err) => console.error('Error:', err),\n * complete: () => console.log('Stream complete')\n * });\n *\n * // To cancel the request:\n * abortController.abort();\n * subscription.unsubscribe();\n * ```\n */\n async stream$(\n agent: string | ClientAgentDefinition,\n messages: AIMessage[],\n variables: { [key: string]: any },\n abortController: AbortController,\n fromApp?: string\n ): Promise<Observable<AIMessage>> {\n const parsedMessages = this.parseMessages(messages);\n const agentName = typeof agent === 'string' ? agent : agent.definition.name;\n const useTest = typeof agent !== 'string' && agent.snapshot;\n const baseUrl = useTest\n ? `${this.baseUrl}/agent/test/text`\n : `${this.baseUrl}/agent/text/${agentName}`;\n let body = JSON.stringify({ messages: parsedMessages, variables });\n if (useTest) {\n const agentCopy = {\n ...agent.definition\n };\n agentCopy.agent.messages = parsedMessages;\n agentCopy.agent.variables = variables;\n body = JSON.stringify(agentCopy);\n }\n\n const response = await this.client.fetch(\n `${baseUrl}?fullResponse=true${fromApp ? `&fromApp=${fromApp}` : ''}`,\n {\n method: 'POST',\n body,\n headers: {\n ...this.client.defaultHeaders,\n 'content-type': 'application/json',\n accept: 'text/event-stream'\n },\n signal: abortController.signal\n }\n );\n\n if (response.status > 300) {\n const data = await response.json();\n throw new Error(JSON.stringify(data, null, 2));\n }\n\n const stream = response.body;\n const decoder = new TextDecoder();\n\n return new Observable<AIMessage>(observer => {\n if (!stream) {\n observer.error('No response body');\n throw 'No response body';\n }\n\n const reader = stream.getReader();\n const message: AIMessage = {\n role: 'assistant',\n content: '',\n steps: []\n };\n\n const abortHandler = () => {\n reader.cancel();\n observer.error(new DOMException('Aborted', 'AbortError'));\n };\n\n abortController.signal.addEventListener('abort', abortHandler);\n\n let buffer = '';\n\n const read = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n if (buffer.trim()) this.processLine(buffer, observer, message); // process any remaining data\n observer.complete();\n return;\n }\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n\\n');\n buffer = lines.pop() || '';\n for (const line of lines) {\n if (line.trim()) this.processLine(line, observer, message);\n }\n read();\n });\n };\n\n read();\n return () => {\n abortController.signal.removeEventListener('abort', abortHandler);\n reader.cancel();\n };\n });\n }\n\n private parseMessages(messages: AIMessage[]) {\n return messages\n .filter(message => !message.options?.skipToLLM)\n .map(message => {\n if (message.options?.hiddenContent) {\n return {\n role: message.role,\n content: message.options.hiddenContent\n };\n }\n return {\n role: message.role,\n content: message.content\n };\n });\n }\n\n private processLine(line: string, observer: any, message: AIMessage) {\n if (!line.trim()) {\n return;\n }\n const lastStep = message.steps?.[message.steps.length - 1] || {\n type: 'text',\n toolCalls: [],\n toolResults: [],\n text: ''\n };\n try {\n let data: any = {};\n let type = '';\n try {\n data = JSON.parse(line.replace('data: ', ''));\n type = data.type;\n } catch (e) {\n console.error('Error parsing line', line, e);\n return;\n }\n\n switch (type) {\n case DataStreamType.STEP_START || DataStreamType.STEP_START_V4:\n message.steps = message.steps || [];\n message.steps.push({\n type: 'text',\n toolCalls: [],\n toolResults: [],\n text: ''\n });\n return;\n\n case DataStreamType.REASONING:\n if (lastStep!.reasoning === undefined) {\n lastStep!.reasoning = '';\n }\n lastStep!.reasoning += data.text || data.textDelta;\n observer.next(message);\n return;\n\n case DataStreamType.TEXT_DELTA:\n lastStep!.text += data.text || data.textDelta;\n message.content += data.text || data.textDelta;\n observer.next(message);\n return;\n\n case DataStreamType.TOOL_INPUT_START:\n lastStep!.toolCalls = [data];\n observer.next(message);\n return;\n\n case DataStreamType.TOOL_CALL:\n lastStep!.toolCalls = [data];\n observer.next(message);\n return;\n\n case DataStreamType.TOOL_RESULT:\n lastStep!.toolResults = [data];\n observer.next(message);\n return;\n\n case DataStreamType.FINISH:\n message.finishReason = data.finishReason;\n observer.next(message);\n observer.complete();\n return;\n\n case DataStreamType.ERROR:\n message.finishReason = 'error';\n const errorMessage = `<div\n class=\"alert alert-danger\"\n role=\"alert\"\n >\n <strong>Error</strong>\n ${data.message || 'An unknown error occurred'}\n </div>`;\n message.content += errorMessage;\n lastStep!.text += errorMessage;\n observer.next(message);\n observer.error(data);\n observer.complete();\n return;\n }\n } catch (e) {\n observer.error(e);\n }\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;IAsBY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,YAAA,CAAA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CAAC,EAAE;AACV,YAAA,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;QACnB;IACF;+GA7TW,SAAS,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,UAAA,EAAA,CAAA,CAAA;AAAT,IAAA,SAAA,IAAA,CAAA,KAAA,GAAA,EAAA,CAAA,qBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,SAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,SAAS,cAFR,MAAM,EAAA,CAAA,CAAA;;4FAEP,SAAS,EAAA,UAAA,EAAA,CAAA;kBAHrB,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE;AACb,iBAAA;;;ACbD;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"c8y-ngx-components-ai.mjs","sources":["../../ai/ai.service.ts","../../ai/c8y-ngx-components-ai.ts"],"sourcesContent":["import { inject, Injectable } from '@angular/core';\nimport { FetchClient } from '@c8y/client';\nimport { Observable, Subscriber } from 'rxjs';\nimport {\n AgentDefinition,\n AgentHealthCheckResponse,\n AgentStep,\n AIMessage,\n AIStreamResponse,\n ClientAgentDefinition,\n ToolCallPart\n} from './ai.model';\n\n// Internal implementation detail; maybe we don't even need this enum since\nexport enum DataStreamType {\n TEXT_DELTA = 'text-delta',\n TOOL_CALL = 'tool-call',\n TOOL_INPUT_START = 'tool-input-start',\n TOOL_INPUT_DELTA = 'tool-input-delta',\n TOOL_CALL_STREAMING = 'tool-call-streaming',\n TOOL_CALL_DELTA = 'tool-call-delta',\n TOOL_RESULT = 'tool-result',\n REASONING = 'reasoning',\n REASONING_DELTA = 'reasoning-delta',\n REDACTED_REASONING = 'redacted-reasoning',\n REASONING_SIGNATURE = 'reasoning-signature',\n FINISH_REASONING = 'finish-reasoning',\n FINISH = 'finish',\n FINISH_STEP = 'finish-step',\n ERROR = 'error',\n DATA = 'data',\n MESSAGE_ANNOTATIONS = 'message-annotations',\n SOURCE = 'source',\n FILE = 'file',\n STEP_START = 'start-step',\n STEP_FINISH = 'finish-step'\n}\n\n/** This service manages communication with the AI Agent Manager microservice, supporting\n * management of agents, and sending requests to the agents.\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class AIService {\n private baseUrl = '/service/ai';\n private client: FetchClient;\n\n // nb: allowing the client to be passed in the constructor allows efficient unit testing without setting up the Angular TestBed\n constructor(client?: FetchClient) {\n this.client = client ?? inject(FetchClient);\n }\n\n /**\n * Creates or updates an agent.\n * @param def The agent definition\n */\n async createOrUpdateAgent(def: AgentDefinition): Promise<void> {\n const health = await this.getAgentHealth(def.name);\n let resource = `${this.baseUrl}/agent/${def.type}`;\n let method = 'POST';\n if (health.exists) {\n resource = `${this.baseUrl}/agent/${def.type}/${def.name}`;\n method = 'PUT';\n }\n const response = await this.client.fetch(resource, {\n body: JSON.stringify(def),\n method,\n headers: { 'Content-Type': 'application/json' }\n });\n\n if (!response.ok) {\n throw new Error(`Failed to create agent: ${response.statusText}`);\n }\n }\n\n /**\n * Check if an agent exists and is ready for use.\n * @param name Agent name (optional)\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns Agent health check response.\n */\n async getAgentHealth(name = '', fromApp?: string): Promise<AgentHealthCheckResponse> {\n const response = await this.client.fetch(\n `${this.baseUrl}/agent/test/${name || crypto.randomUUID()}${fromApp ? `?fromApp=${fromApp}` : ''}`,\n {\n method: 'GET',\n headers: { 'Content-Type': 'application/json' }\n }\n );\n\n if (!response.ok) {\n return {\n status: response.status === 403 ? 'missing-permissions' : 'missing-microservice',\n exists: false,\n canCreate: false,\n isProviderConfigured: false,\n messages: response.status === 403 ? [] : [response.statusText]\n };\n }\n const json: AgentHealthCheckResponse = await response.json();\n if (!json.isProviderConfigured) {\n json.status = 'missing-provider';\n } else if (!json.exists) {\n json.status = 'missing-agent';\n } else {\n json.status = 'ready';\n }\n return json;\n }\n\n /**\n * Send a text message to the agent.\n * @param name Agent name\n * @param messages The message to send, including any previous message history.\n * Typically you should use `defaultPruneMessagesForAgent` or a custom function to prepare the message history\n * by removing unnecessary content such as large/old tool inputs/outputs.\n * @param variables Variables to include\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns Text response from the agent.\n */\n async text(\n name: string,\n messages: AIMessage[],\n variables: { [key: string]: any },\n fromApp?: string\n ): Promise<string> {\n const parsedMessages = this.convertToAgentMessageFormat(messages);\n\n const data = this.client.fetch(\n `${this.baseUrl}/agent/text/${name}${fromApp ? `?fromApp=${fromApp}` : ''}`,\n {\n body: JSON.stringify({ messages: parsedMessages, variables }),\n method: 'POST',\n headers: { 'Content-Type': 'application/json' }\n }\n );\n\n const response = await data;\n if (!response.ok) {\n throw new Error(`Failed to talk with agent: ${response.statusText}`);\n }\n const text = await response.text();\n return text;\n }\n\n /**\n * Stream a text message to the agent.\n * @param agent Agent name or an agent definition.\n * @param messages The message to send, including any previous message history.\n * Typically you should use `defaultPruneMessagesForAgent` or a custom function to prepare the message history\n * by removing unnecessary content such as large/old tool inputs/outputs.\n * @param variables Variables to include\n * @param abortController An AbortController to cancel the request.\n * @param fromApp The app context path to check for an agent. This can be used, if the agent should get distributed by the plugin (optional).\n * @returns An observable that emits AIStreamResponse including partial `AIMessage` objects as they are received.\n * When additional useful metadata is available, this will be streamed with type indicating it is metadata.\n * The observable can be cancelled using the provided AbortController.\n * The observable will emit an error if the request fails or is aborted.\n * The observable will complete when the stream is finished.\n *\n * The messages sent to the agent can include special options:\n * - `hiddenContent`: If set, this content will be sent to the agent instead of the `content` field.\n * - `skipToLLM`: If set to true, this message will be skipped when sending to the agent.\n *\n * Example usage:\n * ```typescript\n * const abortController = new AbortController();\n * const messages: AIMessage[] = [\n * { role: 'user', content: 'Hello' },\n * { role: 'assistant', content: 'Hi there!' },\n * { role: 'user', content: 'Tell me a joke.', options: { hiddenContent: 'Tell me a joke about cats.' } }\n * ];\n * const observable = aiService.stream$('my-agent', messages, {}, abortController);\n * const subscription = observable.subscribe({\n * next: (response) => { console.log('Received message update:', response.message); },\n * error: (err) => console.error('Error:', err),\n * complete: () => console.log('Stream complete')\n * });\n *\n * // To cancel the request:\n * abortController.abort();\n * subscription.unsubscribe();\n * ```\n */\n async stream$(\n agent: string | ClientAgentDefinition,\n messages: AIMessage[],\n variables: { [key: string]: any },\n abortController: AbortController,\n fromApp?: string\n ): Promise<Observable<AIStreamResponse>> {\n const parsedMessages = this.convertToAgentMessageFormat(messages);\n\n const agentName = typeof agent === 'string' ? agent : agent.definition.name;\n const useTest = typeof agent !== 'string' && agent.snapshot;\n const baseUrl = useTest\n ? `${this.baseUrl}/agent/test/text`\n : `${this.baseUrl}/agent/text/${agentName}`;\n let body = JSON.stringify({ messages: parsedMessages, variables });\n if (useTest) {\n const agentCopy = {\n ...agent.definition\n };\n agentCopy.agent['messages'] = parsedMessages;\n agentCopy.agent['variables'] = variables;\n body = JSON.stringify(agentCopy);\n }\n\n const response = await this.client.fetch(\n `${baseUrl}?fullResponse=true${fromApp ? `&fromApp=${fromApp}` : ''}`,\n {\n method: 'POST',\n body,\n headers: {\n ...this.client.defaultHeaders,\n 'content-type': 'application/json',\n accept: 'text/event-stream'\n },\n signal: abortController.signal\n }\n );\n\n const stream = response.body;\n const decoder = new TextDecoder();\n\n return new Observable<AIStreamResponse>(observer => {\n if (response.status > 300) {\n response\n .json()\n .then(data => {\n observer.error(`Error communicating with server: ${JSON.stringify(data, null, 2)}`);\n })\n .catch(err => {\n observer.error(\n `Error communicating with server: HTTP ${response.status}: ${response.statusText}; ${err}`\n );\n });\n return;\n }\n\n if (!stream) {\n observer.error('Server error - no response body');\n return;\n }\n\n const reader = stream.getReader();\n const message: AIMessage = {\n role: 'assistant',\n content: '',\n steps: []\n };\n\n const abortHandler = () => {\n reader.cancel();\n observer.error(new DOMException('Aborted', 'AbortError'));\n };\n\n abortController.signal.addEventListener('abort', abortHandler);\n\n let buffer = '';\n\n const read = () => {\n reader.read().then(({ done, value }) => {\n if (done) {\n if (buffer.trim()) this.processLine(buffer, observer, message); // process any remaining data\n observer.complete();\n return;\n }\n buffer += decoder.decode(value, { stream: true });\n const lines = buffer.split('\\n\\n');\n buffer = lines.pop() || '';\n for (const line of lines) {\n if (line.trim()) this.processLine(line, observer, message);\n }\n read();\n });\n };\n\n read();\n return () => {\n abortController.signal.removeEventListener('abort', abortHandler);\n reader.cancel();\n };\n });\n }\n\n protected convertToAgentMessageFormat(messages: AIMessage[]): object[] {\n // We will need to rewrite this to include tool outputs soon (effectively this means targetting LanguageModelV*ToolResultOutput).\n // Once we have more fields than just role and content, we will need to convert between our format and\n // the Vercel format expected by the agent manager (e.g. steps->content parts)\n return messages\n .filter(m => m)\n .map(m => ({\n role: m.role,\n content: m.content\n }));\n }\n\n /**\n * Convert a tool output from the wire format (which is different/more compact than LanguageModelV3ToolResultOutput)\n * into our own standard representation.\n */\n protected convertStreamingToolOutputToToolCallPart(output: any, target: ToolCallPart) {\n // So far we just pass the data through unchanged from the streaming API but that's pretty hard to work with since it's neither\n // in the format returned by the tool nor in the LanguageModelV3ToolResultOutput format that we have to use\n // when passing it back for the next request\n target.output = output;\n\n if (output?.type?.startsWith('error-') || output?.isError) target.error = true;\n }\n\n /** Add the specified tool call info to the current step. If this toolCallId is already known,\n * updates it rather than adding a new one, since for UI rendering and compactness of data it's\n * easiest to just have one item per tool call.\n */\n private addToolCallInfo(\n type: ToolCallPart['type'],\n rawInfo: any,\n addTo: AgentStep\n ): ToolCallPart {\n // Vercel v4 seems to set this to \"id\" not \"toolCallId\" in some places despite doc to the contrary, so normalize it here\n if (!rawInfo.toolCallId) rawInfo.toolCallId = rawInfo.id;\n\n // We can simplify this logic once we have AIMessage as a list of parts instead of separate lists for these\n let existing: ToolCallPart | undefined = addTo.toolCalls?.find(\n tc => tc.toolCallId === rawInfo.toolCallId\n );\n if (!existing) existing = addTo.toolResults?.find(tc => tc.toolCallId === rawInfo.toolCallId);\n\n // Move from toolCalls to toolResults when transitioning to tool-result\n if (existing && type === 'tool-result' && existing.type !== 'tool-result') {\n addTo.toolCalls = addTo.toolCalls?.filter(tc => tc.toolCallId !== existing?.toolCallId);\n existing.type = type;\n addTo.toolResults = [...(addTo.toolResults || []), existing];\n } else if (existing && existing.type !== type) {\n // Just update the type in place for other transitions\n existing.type = type;\n }\n\n if (!existing) {\n existing = { type: type, toolName: rawInfo.toolName, toolCallId: rawInfo.toolCallId };\n if (type !== 'tool-result') addTo.toolCalls = [...(addTo.toolCalls || []), existing];\n else addTo.toolResults = [...(addTo.toolResults || []), existing];\n }\n if (rawInfo?.input) existing.input = rawInfo.input;\n if (rawInfo?.output) this.convertStreamingToolOutputToToolCallPart(rawInfo.output, existing);\n\n return existing;\n }\n\n /** Unpacks data from the Vercel Data Stream Protocol (sent by the Agent Manager over SSE) to update the message\n *\n * See streamText().fullStream() from https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol#data-stream-protocol\n *\n * This is similar to what the Vercel `toUIMessageStreamResponse` API does (though it'd need the agent manager to publish the\n * UIMessageStream which has a bit more - useful - data than what is included here).\n *\n * We always use the same steps (or in future, parts) object, to make it easier for consumers (eg. agent-chat)\n * to add items to the list and have them still there on the next update from this service.\n */\n private processLine(line: string, observer: Subscriber<AIStreamResponse>, message: AIMessage) {\n if (!line.trim()) {\n return;\n }\n\n try {\n let data: any = {};\n let type = '';\n try {\n data = JSON.parse(line.replace('data: ', ''));\n type = data.type;\n } catch (e) {\n console.error('Error parsing line from AI response: ', line, e);\n return;\n }\n\n // Ensure there's a step into which we can store everything\n if (!message.steps || message.steps.length === 0) {\n message.steps = [{ type: 'text', text: '' }];\n }\n const lastStep = message.steps[message.steps.length - 1];\n\n switch (type) {\n case DataStreamType.STEP_START:\n if (data.request && data.request.body) {\n observer.next({\n message: message,\n changedPart: {\n type: 'response-metadata',\n model: data.request.body.model,\n systemPrompt: data.request.body.systemPrompt\n }\n });\n }\n\n // Create a step, unless we already have an empty one from the initialization section above\n if (lastStep.text || lastStep.reasoning || lastStep.toolCalls || lastStep.toolResults) {\n message.steps.push({\n type: 'text',\n text: ''\n });\n }\n return;\n\n case DataStreamType.REASONING:\n if (lastStep.reasoning === undefined) {\n lastStep!.reasoning = '';\n }\n lastStep.reasoning += data.text || data.textDelta;\n observer.next({ message, changedPart: undefined });\n return;\n\n case DataStreamType.TEXT_DELTA:\n lastStep.text += data.text || data.textDelta;\n\n // FUTURE: this setting the same value to message.content is probably not correct;\n // duplicating the same text wastes space so not necessary given it's already in steps, and\n // the Vercel SDK sets message.content to the text of the LAST step only (the summarizing step)\n message.content += data.text || data.textDelta;\n\n observer.next({ message, changedPart: undefined });\n return;\n\n case DataStreamType.TOOL_INPUT_START:\n observer.next({\n message,\n changedPart: this.addToolCallInfo('tool-input-streaming', data, lastStep)\n });\n return;\n\n case DataStreamType.TOOL_CALL:\n observer.next({\n message,\n changedPart: this.addToolCallInfo('tool-executing', data, lastStep)\n });\n return;\n\n case DataStreamType.TOOL_RESULT:\n observer.next({\n message,\n changedPart: this.addToolCallInfo('tool-result', data, lastStep)\n });\n return;\n\n case DataStreamType.FINISH:\n message.finishReason = data.finishReason; // FUTURE could be anything, may not match the options in AIMessage\n observer.next({ message, changedPart: undefined });\n observer.complete();\n return;\n\n case DataStreamType.ERROR:\n message.finishReason = 'error';\n observer.next({ message, changedPart: undefined });\n observer.error(data?.message || data?.errorText || data);\n // Error is instead of completing the stream\n return;\n\n // Should we also handle other types such as \"abort\"?\n }\n } catch (e) {\n observer.error(e);\n }\n }\n}\n\n/**\n * The default method for reducing the size of the message history so it is ready to be sent to the LLM agent.\n *\n * This is important since old tool inputs and outputs can be very large and fill up the agent's context window.\n *\n * When sending an AI request you can provide your own function instead of using this one,\n * or you can write your own function that calls this and adds extra logic,\n * for example to suppress specific tools from the AIMessage, or\n * retain only the final step text in multi-step responses, etc.\n *\n * The current default implementation preserves text content, but does not include any tool calls.\n * This may change in future releases.\n */\nexport function defaultPruneMessagesForAgent(messages: AIMessage[]): AIMessage[] {\n // When we change this to include tool calls, we should remove large inputs and truncate large and/or old outputs\n // to avoid too many tokens and context window consumption.\n // Some applications will want to entirely remove specific tool calls that have only transient use,\n // which can be done by providing their own pruneMessagesForAgent function.\n return messages.map(m => ({\n role: m.role,\n content: m.content\n }));\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;AAaA;IACY;AAAZ,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,YAAA,CAAA,GAAA,YAAyB;AACzB,IAAA,cAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,cAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,cAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,cAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,cAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,WAAA,CAAA,GAAA,WAAuB;AACvB,IAAA,cAAA,CAAA,iBAAA,CAAA,GAAA,iBAAmC;AACnC,IAAA,cAAA,CAAA,oBAAA,CAAA,GAAA,oBAAyC;AACzC,IAAA,cAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,cAAA,CAAA,kBAAA,CAAA,GAAA,kBAAqC;AACrC,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,cAAA,CAAA,aAAA,CAAA,GAAA,aAA2B;AAC3B,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACf,IAAA,cAAA,CAAA,MAAA,CAAA,GAAA,MAAa;AACb,IAAA,cAAA,CAAA,qBAAA,CAAA,GAAA,qBAA2C;AAC3C,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB;AACjB,IAAA,cAAA,CAAA,MAAA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AO,QAAQ,CAAC,GAAG,CAAC,CAAC,KAAK;QACxB,IAAI,EAAE,CAAC,CAAC,IAAI;QACZ,OAAO,EAAE,CAAC,CAAC;AACZ,KAAA,CAAC,CAAC;AACL;;ACxeA;;AAEG;;;;"}
|
|
@@ -2813,7 +2813,7 @@ class AssetPropertyTabsComponent {
|
|
|
2813
2813
|
if (changes['asset'] && !changes['asset'].firstChange && this.showAsset) {
|
|
2814
2814
|
await this.loadAssetProperties();
|
|
2815
2815
|
await this.loadComputedProperties();
|
|
2816
|
-
this.updateProperties();
|
|
2816
|
+
await this.updateProperties();
|
|
2817
2817
|
this.categorizeSelectedProperties();
|
|
2818
2818
|
this.updateDisplayedProperties();
|
|
2819
2819
|
}
|
|
@@ -2904,10 +2904,16 @@ class AssetPropertyTabsComponent {
|
|
|
2904
2904
|
let propertiesFromLibrary = [];
|
|
2905
2905
|
let filteredDefaultProperties = [];
|
|
2906
2906
|
if (this.showRegular) {
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2907
|
+
// requires asset selection before selecting regular properties
|
|
2908
|
+
if (this.asset) {
|
|
2909
|
+
const result = await this.assetPropertiesService.getPropertiesFromPropertiesLibrary(this.inputText);
|
|
2910
|
+
propertiesFromLibrary = result.propertiesFromLibrary;
|
|
2911
|
+
this.paging = result.paging;
|
|
2912
|
+
filteredDefaultProperties = defaultAssetProperties.filter(prop => prop.label.toLowerCase().includes(this.inputText?.trim().toLowerCase() || ''));
|
|
2913
|
+
}
|
|
2914
|
+
else {
|
|
2915
|
+
this.paging = undefined;
|
|
2916
|
+
}
|
|
2911
2917
|
}
|
|
2912
2918
|
let filteredComputedProperties = [];
|
|
2913
2919
|
if (this.showComputed) {
|