@meistrari/chat-nuxt 4.5.0 → 4.5.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
3
  "configKey": "chatNuxt",
4
- "version": "4.5.0-rc.7",
4
+ "version": "4.5.1-rc.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -67,8 +67,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
67
67
  copyLink: () => any;
68
68
  debug: () => any;
69
69
  selectConversation: (id: string) => any;
70
- send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
71
70
  settings: () => any;
71
+ send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
72
72
  tabChange: (tab: TopbarTab) => any;
73
73
  newConversation: (groupId?: string | null | undefined) => any;
74
74
  switchWorkspace: () => any;
@@ -88,8 +88,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
88
88
  onCopyLink?: (() => any) | undefined;
89
89
  onDebug?: (() => any) | undefined;
90
90
  onSelectConversation?: ((id: string) => any) | undefined;
91
- onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
92
91
  onSettings?: (() => any) | undefined;
92
+ onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
93
93
  "onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
94
94
  "onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
95
95
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
@@ -67,8 +67,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
67
67
  copyLink: () => any;
68
68
  debug: () => any;
69
69
  selectConversation: (id: string) => any;
70
- send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
71
70
  settings: () => any;
71
+ send: (content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any;
72
72
  tabChange: (tab: TopbarTab) => any;
73
73
  newConversation: (groupId?: string | null | undefined) => any;
74
74
  switchWorkspace: () => any;
@@ -88,8 +88,8 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
88
88
  onCopyLink?: (() => any) | undefined;
89
89
  onDebug?: (() => any) | undefined;
90
90
  onSelectConversation?: ((id: string) => any) | undefined;
91
- onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
92
91
  onSettings?: (() => any) | undefined;
92
+ onSend?: ((content: string, files: FileUploadInput[], agentInputs?: TelaAgentExecutionInput[] | undefined) => any) | undefined;
93
93
  "onUpdate:selectedModel"?: ((value: string | null) => any) | undefined;
94
94
  "onUpdate:selectedReasoningEffort"?: ((value: any) => any) | undefined;
95
95
  onTabChange?: ((tab: TopbarTab) => any) | undefined;
@@ -2,6 +2,7 @@ import { AGENT_API_V5_CONFIG_KEY, PRE_WAKE_CACHE_CONFIG_KEY, CONVERSATION_V2_CON
2
2
  import { createError, defineEventHandler, getHeader, getRequestURL, getRouterParam, proxyRequest } from "h3";
3
3
  import { useRuntimeConfig } from "nitropack/runtime";
4
4
  import { resolveAuthToken } from "./auth-token.js";
5
+ import { logger } from "./logger.js";
5
6
  const CHAT_COMPAT_HEADERS = [
6
7
  "x-chat-workspace-id",
7
8
  "x-chat-tela-agent-id",
@@ -129,14 +130,63 @@ export function mapWorkspaceProxyPath(path) {
129
130
  export function prefixProxyPath(prefix, path) {
130
131
  return joinProxyPath(prefix, path);
131
132
  }
133
+ const PROXY_NETWORK_ERROR_CODES = /* @__PURE__ */ new Set([
134
+ "ECONNREFUSED",
135
+ "ECONNRESET",
136
+ "ETIMEDOUT",
137
+ "ENOTFOUND",
138
+ "EAI_AGAIN",
139
+ "EHOSTUNREACH",
140
+ "ENETUNREACH",
141
+ "UND_ERR_CONNECT_TIMEOUT",
142
+ "UND_ERR_HEADERS_TIMEOUT",
143
+ "UND_ERR_SOCKET",
144
+ "CERT_HAS_EXPIRED",
145
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
146
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
147
+ "ERR_TLS_CERT_ALTNAME_INVALID"
148
+ ]);
149
+ function networkErrorCodes(error) {
150
+ const codes = /* @__PURE__ */ new Set();
151
+ let current = error;
152
+ for (let depth = 0; depth < 6 && current instanceof Error; depth++) {
153
+ if ("code" in current && typeof current.code === "string" && PROXY_NETWORK_ERROR_CODES.has(current.code)) {
154
+ codes.add(current.code);
155
+ }
156
+ current = current.cause;
157
+ }
158
+ return [...codes];
159
+ }
132
160
  export async function proxyChatApiRequest(event, targetPath, options = {}) {
133
- return proxyRequest(event, buildTargetUrl(event, targetPath, options.apiVersion ?? "v1"), {
134
- fetchOptions: {
135
- redirect: "manual"
136
- },
137
- headers: buildProxyHeaders(event),
138
- streamRequest: true
139
- });
161
+ const targetUrl = buildTargetUrl(event, targetPath, options.apiVersion ?? "v1");
162
+ const headers = buildProxyHeaders(event);
163
+ try {
164
+ return await proxyRequest(event, targetUrl, {
165
+ fetchOptions: {
166
+ redirect: "manual"
167
+ },
168
+ headers,
169
+ streamRequest: true,
170
+ ...process.env.ENVIRONMENT === "staging" ? {
171
+ onResponse: (_event, response) => {
172
+ if (response.status >= 500) {
173
+ logger.error({
174
+ targetOrigin: new URL(targetUrl).origin,
175
+ upstreamStatus: response.status
176
+ }, "Chat API proxy upstream returned a server error");
177
+ }
178
+ }
179
+ } : {}
180
+ });
181
+ } catch (error) {
182
+ if (process.env.ENVIRONMENT === "staging") {
183
+ logger.error({
184
+ targetOrigin: new URL(targetUrl).origin,
185
+ networkErrorCodes: networkErrorCodes(error)
186
+ }, "Chat API proxy upstream request failed");
187
+ }
188
+ throw error;
189
+ }
140
190
  }
141
191
  export function defineChatApiProxyHandler(resolveTargetPath, options = {}) {
142
192
  return defineEventHandler((event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meistrari/chat-nuxt",
3
- "version": "4.5.0",
3
+ "version": "4.5.1-rc.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {