@agent-platform/ui 0.0.1 → 0.0.2

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.
@@ -12,4 +12,4 @@ export interface AgentPopupWidgetProps extends AgentProviderConfig {
12
12
  offsetRight?: number | string;
13
13
  zIndex?: number;
14
14
  }
15
- export declare function AgentPopupWidget({ endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, containerProps, defaultOpen, launcherLabel, launcherAriaLabel, closeLabel, className, launcherClassName, offsetBottom, offsetRight, zIndex, }: AgentPopupWidgetProps): import("react/jsx-runtime").JSX.Element;
15
+ export declare function AgentPopupWidget({ agentId, executeClientTool, onError, authToken, getAuthToken, containerProps, defaultOpen, launcherLabel, launcherAriaLabel, closeLabel, className, launcherClassName, offsetBottom, offsetRight, zIndex, }: AgentPopupWidgetProps): import("react/jsx-runtime").JSX.Element;
@@ -14,7 +14,7 @@ function toCssSize(value, fallback) {
14
14
  return value;
15
15
  return fallback;
16
16
  }
17
- export function AgentPopupWidget({ endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, containerProps, defaultOpen = false, launcherLabel = 'AIアシスタント', launcherAriaLabel = 'AIアシスタントを開く', closeLabel = '閉じる', className, launcherClassName, offsetBottom, offsetRight, zIndex = DEFAULT_Z_INDEX, }) {
17
+ export function AgentPopupWidget({ agentId, executeClientTool, onError, authToken, getAuthToken, containerProps, defaultOpen = false, launcherLabel = 'AIアシスタント', launcherAriaLabel = 'AIアシスタントを開く', closeLabel = '閉じる', className, launcherClassName, offsetBottom, offsetRight, zIndex = DEFAULT_Z_INDEX, }) {
18
18
  const [isOpen, setIsOpen] = useState(defaultOpen);
19
19
  const overlayStyle = useMemo(() => ({
20
20
  '--agent-popup-right': toCssSize(offsetRight, DEFAULT_OFFSET),
@@ -41,7 +41,7 @@ export function AgentPopupWidget({ endpoint, agentId, apiBaseUrl, executeClientT
41
41
  document.body.style.overflow = originalOverflow;
42
42
  };
43
43
  }, [isOpen]);
44
- return (_jsx(AgentProvider, { endpoint: endpoint, agentId: agentId, apiBaseUrl: apiBaseUrl, executeClientTool: executeClientTool, onError: onError, authToken: authToken, getAuthToken: getAuthToken, children: _jsxs("div", { "data-slot": "agent-popup-widget", style: overlayStyle, children: [!isOpen && (_jsx(Button, { type: "button", "aria-label": launcherAriaLabel, onClick: () => setIsOpen(true), className: cn('fixed right-[var(--agent-popup-right)] bottom-[var(--agent-popup-bottom)] z-[var(--agent-popup-z-index)] h-12 rounded-full px-5 shadow-lg', launcherClassName), children: launcherLabel })), isOpen && (_jsx("div", { className: "fixed inset-0 z-[var(--agent-popup-z-index)] bg-black/45 animate-in fade-in duration-200", onClick: () => setIsOpen(false), onKeyDown: (event) => {
44
+ return (_jsx(AgentProvider, { agentId: agentId, executeClientTool: executeClientTool, onError: onError, authToken: authToken, getAuthToken: getAuthToken, children: _jsxs("div", { "data-slot": "agent-popup-widget", style: overlayStyle, children: [!isOpen && (_jsx(Button, { type: "button", "aria-label": launcherAriaLabel, onClick: () => setIsOpen(true), className: cn('fixed right-[var(--agent-popup-right)] bottom-[var(--agent-popup-bottom)] z-[var(--agent-popup-z-index)] h-12 rounded-full px-5 shadow-lg', launcherClassName), children: launcherLabel })), isOpen && (_jsx("div", { className: "fixed inset-0 z-[var(--agent-popup-z-index)] bg-black/45 animate-in fade-in duration-200", onClick: () => setIsOpen(false), onKeyDown: (event) => {
45
45
  if (event.key === 'Escape') {
46
46
  setIsOpen(false);
47
47
  }
@@ -2,4 +2,4 @@ import type { AgentProviderConfig } from './provider';
2
2
  import type { AgentContainerProps } from './types';
3
3
  export interface AgentScreenProps extends AgentProviderConfig, AgentContainerProps {
4
4
  }
5
- export declare function AgentScreen({ endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, ...containerProps }: AgentScreenProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function AgentScreen({ agentId, executeClientTool, onError, authToken, getAuthToken, ...containerProps }: AgentScreenProps): import("react/jsx-runtime").JSX.Element;
@@ -2,6 +2,6 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { AgentContainer } from './agent-container';
4
4
  import { AgentProvider } from './provider';
5
- export function AgentScreen({ endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, ...containerProps }) {
6
- return (_jsx(AgentProvider, { endpoint: endpoint, agentId: agentId, apiBaseUrl: apiBaseUrl, executeClientTool: executeClientTool, onError: onError, authToken: authToken, getAuthToken: getAuthToken, children: _jsx(AgentContainer, { ...containerProps }) }));
5
+ export function AgentScreen({ agentId, executeClientTool, onError, authToken, getAuthToken, ...containerProps }) {
6
+ return (_jsx(AgentProvider, { agentId: agentId, executeClientTool: executeClientTool, onError: onError, authToken: authToken, getAuthToken: getAuthToken, children: _jsx(AgentContainer, { ...containerProps }) }));
7
7
  }
@@ -7,4 +7,4 @@ export interface AgentProviderProps extends AgentProviderConfig {
7
7
  * エージェントチャット機能を提供する内部Provider
8
8
  * 公開APIは AgentScreen / AgentPopupWidget を使用する。
9
9
  */
10
- export declare function AgentProvider({ children, endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, }: AgentProviderProps): import("react/jsx-runtime").JSX.Element;
10
+ export declare function AgentProvider({ children, agentId, executeClientTool, onError, authToken, getAuthToken, }: AgentProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,17 +1,19 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { AgentContext } from './agent-context';
4
+ import { resolveAgentRuntimeConfig } from './runtime-config';
4
5
  import { useAgentChatInternal } from './use-agent-chat';
5
6
  /**
6
7
  * エージェントチャット機能を提供する内部Provider
7
8
  * 公開APIは AgentScreen / AgentPopupWidget を使用する。
8
9
  */
9
- export function AgentProvider({ children, endpoint, agentId, apiBaseUrl, executeClientTool, onError, authToken, getAuthToken, }) {
10
+ export function AgentProvider({ children, agentId, executeClientTool, onError, authToken, getAuthToken, }) {
11
+ const runtimeConfig = resolveAgentRuntimeConfig();
10
12
  const value = useAgentChatInternal({
11
13
  config: {
12
- endpoint,
14
+ endpoint: runtimeConfig.endpoint,
13
15
  agentId,
14
- apiBaseUrl,
16
+ apiBaseUrl: runtimeConfig.apiBaseUrl,
15
17
  executeClientTool,
16
18
  onError,
17
19
  authToken,
@@ -0,0 +1,5 @@
1
+ export interface AgentRuntimeConfig {
2
+ endpoint: string;
3
+ apiBaseUrl: string;
4
+ }
5
+ export declare function resolveAgentRuntimeConfig(): AgentRuntimeConfig;
@@ -0,0 +1,8 @@
1
+ const FIXED_AGENT_ENDPOINT = 'https://agent-server-prod--agent-platform-dev-8e3ae.asia-east1.hosted.app/api/agent';
2
+ const FIXED_API_BASE_URL = 'https://demo-scout-api-prod--agent-platform-dev-8e3ae.asia-east1.hosted.app/api';
3
+ export function resolveAgentRuntimeConfig() {
4
+ return {
5
+ endpoint: FIXED_AGENT_ENDPOINT,
6
+ apiBaseUrl: FIXED_API_BASE_URL,
7
+ };
8
+ }
@@ -23,16 +23,9 @@ export type ClientToolExecutor = (toolCall: import('@agent-platform/server').Too
23
23
  * AgentProvider設定
24
24
  */
25
25
  export interface AgentProviderConfig {
26
- endpoint: string;
27
26
  agentId?: string;
28
27
  /**
29
- * クライアント実行ツールが呼び出すAPIのベースURL
30
- * tool-callのapiEndpoint.pathと組み合わせて使用
31
- * 例: apiBaseUrl="http://localhost:3001/api" + path="/candidates/{id}"
32
- */
33
- apiBaseUrl?: string;
34
- /**
35
- * @deprecated apiBaseUrlを使用してください。
28
+ * @deprecated 旧実装との後方互換用。
36
29
  * executeOn: 'client' のツールをブラウザ側で実行するコールバック
37
30
  */
38
31
  executeClientTool?: ClientToolExecutor;
@@ -42,6 +35,13 @@ export interface AgentProviderConfig {
42
35
  /** 動的にトークンを取得する関数(authTokenより優先) */
43
36
  getAuthToken?: () => string | Promise<string>;
44
37
  }
38
+ /**
39
+ * Agent通信先を解決済みの内部設定
40
+ */
41
+ export interface ResolvedAgentRuntimeConfig extends AgentProviderConfig {
42
+ endpoint: string;
43
+ apiBaseUrl: string;
44
+ }
45
45
  /**
46
46
  * AgentContext値
47
47
  */
@@ -54,5 +54,5 @@ export interface AgentContextValue {
54
54
  sendMessage: (message: string) => Promise<void>;
55
55
  loadThread: (threadId: string) => Promise<void>;
56
56
  clearChat: () => void;
57
- config: AgentProviderConfig;
57
+ config: ResolvedAgentRuntimeConfig;
58
58
  }
@@ -1,6 +1,6 @@
1
- import type { AgentContextValue, AgentProviderConfig } from './types';
1
+ import type { AgentContextValue, ResolvedAgentRuntimeConfig } from './types';
2
2
  interface UseAgentChatOptions {
3
- config: AgentProviderConfig;
3
+ config: ResolvedAgentRuntimeConfig;
4
4
  }
5
5
  export declare function useAgentChatInternal(options: UseAgentChatOptions): AgentContextValue;
6
6
  export {};
@@ -251,7 +251,7 @@ export function useAgentChatInternal(options) {
251
251
  }
252
252
  for (const tc of unresolvedCalls) {
253
253
  // apiBaseUrlとapiEndpointがある場合は自動実行
254
- const canAutoExecute = apiBaseUrl && tc.apiEndpoint;
254
+ const canAutoExecute = Boolean(tc.apiEndpoint);
255
255
  // 従来のexecuteClientToolがある場合はそれを使用
256
256
  const canLegacyExecute = executeClientTool;
257
257
  if (!canAutoExecute && !canLegacyExecute) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-platform/ui",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,