@open-mercato/ui 0.6.1-develop.3246.1.dbef9d7392 → 0.6.1-develop.3256.1.fe3dec2464

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.
@@ -70,6 +70,18 @@ export interface UseAiChatInput {
70
70
  * props at any time to reset the conversation.
71
71
  */
72
72
  conversationId?: string
73
+ /**
74
+ * Runtime provider override (4b.2). Forwarded as `?provider=` query param
75
+ * on every POST to the dispatcher. Undefined/null means use the agent's
76
+ * configured default (no override sent).
77
+ */
78
+ providerOverride?: string | null
79
+ /**
80
+ * Runtime model override (4b.2). Forwarded as `?model=` query param
81
+ * on every POST to the dispatcher. Undefined/null means use the agent's
82
+ * configured default (no override sent).
83
+ */
84
+ modelOverride?: string | null
73
85
  }
74
86
 
75
87
  export interface AiChatErrorEnvelope {
@@ -238,7 +250,12 @@ function clearPersistedSession(agent: string, conversationId?: string | null): v
238
250
  }
239
251
  }
240
252
 
241
- function getTransportEndpoint(agent: string, apiPath?: string): string {
253
+ function getTransportEndpoint(
254
+ agent: string,
255
+ apiPath?: string,
256
+ providerOverride?: string | null,
257
+ modelOverride?: string | null,
258
+ ): string {
242
259
  // Reuse the transport factory so UI consumers share the dispatcher URL
243
260
  // convention with server-side callers (e.g. runAiAgentText / Playwright
244
261
  // fixtures). The factory returns a ChatTransport<UI_MESSAGE> whose internal
@@ -252,7 +269,14 @@ function getTransportEndpoint(agent: string, apiPath?: string): string {
252
269
  void transport
253
270
  const base = apiPath && apiPath.length > 0 ? apiPath : '/api/ai_assistant/ai/chat'
254
271
  const separator = base.includes('?') ? '&' : '?'
255
- return `${base}${separator}agent=${encodeURIComponent(agent)}`
272
+ let url = `${base}${separator}agent=${encodeURIComponent(agent)}`
273
+ if (providerOverride) {
274
+ url += `&provider=${encodeURIComponent(providerOverride)}`
275
+ }
276
+ if (modelOverride) {
277
+ url += `&model=${encodeURIComponent(modelOverride)}`
278
+ }
279
+ return url
256
280
  }
257
281
 
258
282
  interface AssistantBuilderState {
@@ -549,7 +573,7 @@ async function readErrorEnvelope(response: Response): Promise<AiChatErrorEnvelop
549
573
  }
550
574
 
551
575
  export function useAiChat(input: UseAiChatInput): UseAiChatResult {
552
- const { agent, apiPath, pageContext, attachmentIds, debug, initialMessages, onError, conversationId: conversationIdInput } = input
576
+ const { agent, apiPath, pageContext, attachmentIds, debug, initialMessages, onError, conversationId: conversationIdInput, providerOverride, modelOverride } = input
553
577
 
554
578
  // Minted once on mount when the caller does not supply a conversationId.
555
579
  // The ref keeps the id stable across re-renders and is reused for every
@@ -763,7 +787,7 @@ export function useAiChat(input: UseAiChatInput): UseAiChatResult {
763
787
  const controller = new AbortController()
764
788
  abortRef.current = controller
765
789
 
766
- const url = getTransportEndpoint(agent, apiPath)
790
+ const url = getTransportEndpoint(agent, apiPath, providerOverride, modelOverride)
767
791
  const body = {
768
792
  messages: outgoingHistory.map((message) => ({
769
793
  role: message.role,
@@ -966,18 +990,7 @@ export function useAiChat(input: UseAiChatInput): UseAiChatResult {
966
990
  setStatus('idle')
967
991
  }
968
992
  },
969
- [
970
- agent,
971
- apiPath,
972
- attachmentIds,
973
- debug,
974
- effectiveConversationId,
975
- emitError,
976
- pageContext,
977
- sessionStorageKey,
978
- setStatus,
979
- updateMessages,
980
- ],
993
+ [agent, apiPath, attachmentIds, debug, effectiveConversationId, emitError, messages, modelOverride, pageContext, providerOverride],
981
994
  )
982
995
 
983
996
  React.useEffect(() => {