@chat-lab/ui 0.1.0-beta.50 → 0.1.0-beta.51

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useADKChat.cjs","sources":["../../src/hooks/useADKChat.ts"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n createThreadManagerStateWithDefault,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport { option } from 'framer-motion/dist/m';\nimport dayjs from 'dayjs';\n\nexport const useADKChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const runtimeType = useRef<'a2a' | 'adk' | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n const runtimeStore = useRef<Map<string, ThreadMessageManager> | null>(null);\n if (!runtimeStore.current) {\n runtimeStore.current = new Map();\n }\n if (!controllerRef.current) {\n const state = createThreadManagerStateWithDefault();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n const switchRuntime = (\n runtime: string,\n options: { type: 'a2a' } | { type: 'adk'; appName: string },\n ) => {\n // adkPluginRef.current?.switchRuntime(runtime);\n const storeManager = runtimeStore.current?.get(runtime);\n if (storeManager) {\n controllerRef.current?.setStore(storeManager);\n } else {\n const state = createThreadManagerState();\n\n const storeManager = new ThreadMessageManager(state);\n runtimeStore.current?.set(runtime, storeManager);\n controllerRef.current?.setStore(storeManager);\n }\n if (options.type === runtimeType.current) {\n if (options.type === 'adk') {\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n }\n } else {\n const prevRequestOptions =\n controllerRef.current?.getRequestOptions() as RequestOptions;\n if (options.type === 'adk' && adkPluginRef.current) {\n controllerRef.current?.pluginManager.addPlugin(adkPluginRef.current);\n controllerRef.current?.setProtocolOptions({ protocol: 'ADK' });\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: AdkCompletion,\n });\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n } else {\n if (adkPluginRef.current) {\n controllerRef.current?.pluginManager.removePlugin(\n adkPluginRef.current,\n );\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: A2ACompletion,\n });\n controllerRef.current?.setProtocolOptions({ protocol: 'A2A' });\n if (!controllerRef.current?.getCurrentThread()) {\n const _id = uuid();\n controllerRef.current\n ?.addThread({\n id: _id,\n name: _id,\n metadata: {},\n sending: false,\n createdAt: dayjs().unix(),\n messages: [],\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n }\n }\n }\n }\n runtimeType.current = options.type;\n };\n return {\n controllerRef,\n switchRuntime,\n };\n};\n"],"names":["useRef","createThreadManagerStateWithDefault","ThreadMessageManager","AdkPlugin","uuid","ChatController","createThreadManagerState","AdkCompletion","A2ACompletion","dayjs"],"mappings":";;;;;;;AAgBO,MAAM,UAAU,GAAG,CAAC,EACzB,aAAa,EACb,OAAO,EACP,UAAU,GAWX,KAAI;AACH,IAAA,MAAM,aAAa,GAAGA,YAAM,CAAwB,IAAI,CAAC,CAAC;AAC1D,IAAA,MAAM,WAAW,GAAGA,YAAM,CAAuB,IAAI,CAAC,CAAC;AACvD,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAmB,IAAI,CAAC,CAAC;AACpD,IAAA,MAAM,YAAY,GAAGA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AAC,OAAO,EAAE,gBAAgB,EAAE,EAAE;AAC9C,wBAAA,MAAM,GAAG,GAAGJ,EAAI,EAAE,CAAC;AACnB,wBAAA,aAAa,CAAC,OAAO;AACnB,8BAAE,SAAS,CAAC;AACV,4BAAA,EAAE,EAAE,GAAG;AACP,4BAAA,IAAI,EAAE,GAAG;AACT,4BAAA,QAAQ,EAAE,EAAE;AACZ,4BAAA,OAAO,EAAE,KAAK;AACd,4BAAA,SAAS,EAAEK,iBAAK,EAAE,CAAC,IAAI,EAAE;AACzB,4BAAA,QAAQ,EAAE,EAAE;yBACb,CAAC;AACD,6BAAA,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;AACf,4BAAA,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9C,yBAAC,CAAC,CAAC;qBACN;iBACF;aACF;SACF;AACD,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;AACrC,KAAC,CAAC;IACF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useADKChat.cjs","sources":["../../src/hooks/useADKChat.ts"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n createThreadManagerStateWithDefault,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport dayjs from 'dayjs';\n\nexport const useADKChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const runtimeType = useRef<'a2a' | 'adk' | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n const runtimeStore = useRef<Map<string, ThreadMessageManager> | null>(null);\n if (!runtimeStore.current) {\n runtimeStore.current = new Map();\n }\n if (!controllerRef.current) {\n const state = createThreadManagerStateWithDefault();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n const switchRuntime = (\n runtime: string,\n options: { type: 'a2a' } | { type: 'adk'; appName: string },\n ) => {\n // adkPluginRef.current?.switchRuntime(runtime);\n const storeManager = runtimeStore.current?.get(runtime);\n if (storeManager) {\n controllerRef.current?.setStore(storeManager);\n } else {\n const state = createThreadManagerState();\n\n const storeManager = new ThreadMessageManager(state);\n runtimeStore.current?.set(runtime, storeManager);\n controllerRef.current?.setStore(storeManager);\n }\n if (options.type === runtimeType.current) {\n if (options.type === 'adk') {\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n }\n } else {\n const prevRequestOptions =\n controllerRef.current?.getRequestOptions() as RequestOptions;\n if (options.type === 'adk' && adkPluginRef.current) {\n controllerRef.current?.pluginManager.addPlugin(adkPluginRef.current);\n controllerRef.current?.setProtocolOptions({ protocol: 'ADK' });\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: AdkCompletion,\n });\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n } else {\n if (adkPluginRef.current) {\n controllerRef.current?.pluginManager.removePlugin(\n adkPluginRef.current,\n );\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: A2ACompletion,\n });\n controllerRef.current?.setProtocolOptions({ protocol: 'A2A' });\n if (!controllerRef.current?.getCurrentThread()) {\n const _id = uuid();\n controllerRef.current\n ?.addThread({\n id: _id,\n name: _id,\n metadata: {},\n sending: false,\n createdAt: dayjs().unix(),\n messages: [],\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n }\n }\n }\n }\n runtimeType.current = options.type;\n };\n return {\n controllerRef,\n switchRuntime,\n };\n};\n"],"names":["useRef","createThreadManagerStateWithDefault","ThreadMessageManager","AdkPlugin","uuid","ChatController","createThreadManagerState","AdkCompletion","A2ACompletion","dayjs"],"mappings":";;;;;;;AAeO,MAAM,UAAU,GAAG,CAAC,EACzB,aAAa,EACb,OAAO,EACP,UAAU,GAWX,KAAI;AACH,IAAA,MAAM,aAAa,GAAGA,YAAM,CAAwB,IAAI,CAAC,CAAC;AAC1D,IAAA,MAAM,WAAW,GAAGA,YAAM,CAAuB,IAAI,CAAC,CAAC;AACvD,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAmB,IAAI,CAAC,CAAC;AACpD,IAAA,MAAM,YAAY,GAAGA,YAAM,CAA2C,IAAI,CAAC,CAAC;AAC5E,IAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AACzB,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;KAClC;AACD,IAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC1B,QAAA,MAAM,KAAK,GAAGC,yCAAmC,EAAE,CAAC;AACpD,QAAA,MAAM,YAAY,GAAG,IAAIC,0BAAoB,CAAC,KAAK,CAAC,CAAC;AACrD,QAAA,MAAM,SAAS,GAAG,IAAIC,eAAS,CAAC;AAC9B,YAAA,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,OAAO;AACvC,YAAA,MAAM,EAAE,UAAU,EAAE,MAAM,IAAIC,EAAI,EAAE;AACrC,SAAA,CAAC,CAAC;AACH,QAAA,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;AACjC,QAAA,aAAa,CAAC,OAAO,GAAG,IAAIC,oBAAc,CAAC;YACzC,cAAc,EAAE,aAAa,CAAC,cAAc;YAC5C,eAAe,EAAE,aAAa,CAAC,eAAe;YAC9C,OAAO,EAAE,CAAC,SAAS,CAAC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ceRoot":"","sources":["../../src/hooks/useADKChat.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAGd,eAAe,EAEf,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,UAAU,GAAI,yCAIxB;IACD,aAAa,EAAE;QACb,cAAc,EAAE,cAAc,CAAC;QAC/B,eAAe,EAAE,eAAe,CAAC;KAClC,CAAC;IACF,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;;6BAyBY,MAAM,WACN;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CA8D9D,CAAC"}
1
+ {"version":3,"file":"useADKChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useADKChat.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAGd,eAAe,EAEf,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAIxB,eAAO,MAAM,UAAU,GAAI,yCAIxB;IACD,aAAa,EAAE;QACb,cAAc,EAAE,cAAc,CAAC;QAC/B,eAAe,EAAE,eAAe,CAAC;KAClC,CAAC;IACF,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;;6BAyBY,MAAM,WACN;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,GAAG;QAAE,IAAI,EAAE,KAAK,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE;CA8D9D,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useADKChat.js","sources":["../../src/hooks/useADKChat.ts"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n createThreadManagerStateWithDefault,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport { option } from 'framer-motion/dist/m';\nimport dayjs from 'dayjs';\n\nexport const useADKChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const runtimeType = useRef<'a2a' | 'adk' | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n const runtimeStore = useRef<Map<string, ThreadMessageManager> | null>(null);\n if (!runtimeStore.current) {\n runtimeStore.current = new Map();\n }\n if (!controllerRef.current) {\n const state = createThreadManagerStateWithDefault();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n const switchRuntime = (\n runtime: string,\n options: { type: 'a2a' } | { type: 'adk'; appName: string },\n ) => {\n // adkPluginRef.current?.switchRuntime(runtime);\n const storeManager = runtimeStore.current?.get(runtime);\n if (storeManager) {\n controllerRef.current?.setStore(storeManager);\n } else {\n const state = createThreadManagerState();\n\n const storeManager = new ThreadMessageManager(state);\n runtimeStore.current?.set(runtime, storeManager);\n controllerRef.current?.setStore(storeManager);\n }\n if (options.type === runtimeType.current) {\n if (options.type === 'adk') {\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n }\n } else {\n const prevRequestOptions =\n controllerRef.current?.getRequestOptions() as RequestOptions;\n if (options.type === 'adk' && adkPluginRef.current) {\n controllerRef.current?.pluginManager.addPlugin(adkPluginRef.current);\n controllerRef.current?.setProtocolOptions({ protocol: 'ADK' });\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: AdkCompletion,\n });\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n } else {\n if (adkPluginRef.current) {\n controllerRef.current?.pluginManager.removePlugin(\n adkPluginRef.current,\n );\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: A2ACompletion,\n });\n controllerRef.current?.setProtocolOptions({ protocol: 'A2A' });\n if (!controllerRef.current?.getCurrentThread()) {\n const _id = uuid();\n controllerRef.current\n ?.addThread({\n id: _id,\n name: _id,\n metadata: {},\n sending: false,\n createdAt: dayjs().unix(),\n messages: [],\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n }\n }\n }\n }\n runtimeType.current = options.type;\n };\n return {\n controllerRef,\n switchRuntime,\n };\n};\n"],"names":["uuid"],"mappings":";;;;;AAgBO,MAAM,UAAU,GAAG,CAAC,EACzB,aAAa,EACb,OAAO,EACP,UAAU,GAWX,KAAI;AACH,IAAA,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;AAC1D,IAAA,MAAM,WAAW,GAAG,MAAM,CAAuB,IAAI,CAAC,CAAC;AACvD,IAAA,MAAM,YAAY,GAAG,MAAM,CAAmB,IAAI,CAAC,CAAC;AACpD,IAAA,MAAM,YAAY,GAAG,MAAM,CAA2C,IAAI,CAAC,CAAC;AAC5E,IAAA,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;AACzB,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;KAClC;AACD,IAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC1B,QAAA,MAAM,KAAK,GAAG,mCAAmC,EAAE,CAAC;AACpD,QAAA,MAAM,YAAY,GAAG,IAAI,o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EAAE,CAAC,IAAI,EAAE;AACzB,4BAAA,QAAQ,EAAE,EAAE;yBACb,CAAC;AACD,6BAAA,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;AACf,4BAAA,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9C,yBAAC,CAAC,CAAC;qBACN;iBACF;aACF;SACF;AACD,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;AACrC,KAAC,CAAC;IACF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"useADKChat.js","sources":["../../src/hooks/useADKChat.ts"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n createThreadManagerStateWithDefault,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport dayjs from 'dayjs';\n\nexport const useADKChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const runtimeType = useRef<'a2a' | 'adk' | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n const runtimeStore = useRef<Map<string, ThreadMessageManager> | null>(null);\n if (!runtimeStore.current) {\n runtimeStore.current = new Map();\n }\n if (!controllerRef.current) {\n const state = createThreadManagerStateWithDefault();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n const switchRuntime = (\n runtime: string,\n options: { type: 'a2a' } | { type: 'adk'; appName: string },\n ) => {\n // adkPluginRef.current?.switchRuntime(runtime);\n const storeManager = runtimeStore.current?.get(runtime);\n if (storeManager) {\n controllerRef.current?.setStore(storeManager);\n } else {\n const state = createThreadManagerState();\n\n const storeManager = new ThreadMessageManager(state);\n runtimeStore.current?.set(runtime, storeManager);\n controllerRef.current?.setStore(storeManager);\n }\n if (options.type === runtimeType.current) {\n if (options.type === 'adk') {\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n }\n } else {\n const prevRequestOptions =\n controllerRef.current?.getRequestOptions() as RequestOptions;\n if (options.type === 'adk' && adkPluginRef.current) {\n controllerRef.current?.pluginManager.addPlugin(adkPluginRef.current);\n controllerRef.current?.setProtocolOptions({ protocol: 'ADK' });\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: AdkCompletion,\n });\n adkPluginRef.current?.switchRuntime(runtime, options.appName);\n } else {\n if (adkPluginRef.current) {\n controllerRef.current?.pluginManager.removePlugin(\n adkPluginRef.current,\n );\n controllerRef.current?.setRequestOptions({\n ...prevRequestOptions,\n completions: A2ACompletion,\n });\n controllerRef.current?.setProtocolOptions({ protocol: 'A2A' });\n if (!controllerRef.current?.getCurrentThread()) {\n const _id = uuid();\n controllerRef.current\n ?.addThread({\n id: _id,\n name: _id,\n metadata: {},\n sending: false,\n createdAt: dayjs().unix(),\n messages: [],\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n }\n }\n }\n }\n runtimeType.current = options.type;\n };\n return {\n controllerRef,\n switchRuntime,\n };\n};\n"],"names":["uuid"],"mappings":";;;;;AAeO,MAAM,UAAU,GAAG,CAAC,EACzB,aAAa,EACb,OAAO,EACP,UAAU,GAWX,KAAI;AACH,IAAA,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;AAC1D,IAAA,MAAM,WAAW,GAAG,MAAM,CA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,OAAO,EAAE,kBAAkB,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;oBAC/D,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE;AAC9C,wBAAA,MAAM,GAAG,GAAGA,EAAI,EAAE,CAAC;AACnB,wBAAA,aAAa,CAAC,OAAO;AACnB,8BAAE,SAAS,CAAC;AACV,4BAAA,EAAE,EAAE,GAAG;AACP,4BAAA,IAAI,EAAE,GAAG;AACT,4BAAA,QAAQ,EAAE,EAAE;AACZ,4BAAA,OAAO,EAAE,KAAK;AACd,4BAAA,SAAS,EAAE,KAAK,EAAE,CAAC,IAAI,EAAE;AACzB,4BAAA,QAAQ,EAAE,EAAE;yBACb,CAAC;AACD,6BAAA,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;AACf,4BAAA,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9C,yBAAC,CAAC,CAAC;qBACN;iBACF;aACF;SACF;AACD,QAAA,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;AACrC,KAAC,CAAC;IACF,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAC;AACJ;;;;"}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var index = require('../packages/core/dist/index.cjs');
5
+ var dayjs_min = require('../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.cjs');
6
+ var index$1 = require('../node_modules/.pnpm/ahooks@3.9.6_react-dom@17.0.2_react@17.0.2__react@17.0.2/node_modules/ahooks/es/useMemoizedFn/index.cjs');
7
+ var v4 = require('../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.cjs');
8
+
9
+ const useDebugChat = ({ initialConfig, onError, adkOptions, }) => {
10
+ const controllerRef = React.useRef(null);
11
+ const adkPluginRef = React.useRef(null);
12
+ if (!controllerRef.current) {
13
+ const state = index.createThreadManagerState();
14
+ const storeManager = new index.ThreadMessageManager(state);
15
+ const adkPlugin = new index.AdkPlugin({
16
+ appName: adkOptions?.appName || 'veadk',
17
+ userId: adkOptions?.userID || v4(),
18
+ });
19
+ adkPluginRef.current = adkPlugin;
20
+ controllerRef.current = new index.ChatController({
21
+ requestOptions: initialConfig.requestOptions,
22
+ protocolOptions: initialConfig.protocolOptions,
23
+ plugins: [adkPlugin],
24
+ onError: onError,
25
+ storeManager,
26
+ });
27
+ }
28
+ const ready = index$1(({ sessionId }) => {
29
+ controllerRef.current
30
+ ?.addThread({
31
+ id: sessionId,
32
+ name: sessionId,
33
+ sending: false,
34
+ metadata: {},
35
+ messages: [],
36
+ createdAt: dayjs_min.default().unix(),
37
+ })
38
+ .then(({ id }) => {
39
+ controllerRef.current?.setCurrentThread(id);
40
+ });
41
+ });
42
+ return {
43
+ controllerRef,
44
+ ready,
45
+ };
46
+ };
47
+
48
+ exports.useDebugChat = useDebugChat;
49
+ //# sourceMappingURL=useDebugChat.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebugChat.cjs","sources":["../../src/hooks/useDebugChat.tsx"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport dayjs from 'dayjs';\nimport { useMemoizedFn } from 'ahooks';\n\nexport const useDebugChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n\n if (!controllerRef.current) {\n const state = createThreadManagerState();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n\n const ready = useMemoizedFn(({ sessionId }: { sessionId: string }) => {\n controllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n sending: false,\n metadata: {},\n messages: [],\n createdAt: dayjs().unix(),\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n });\n\n return {\n controllerRef,\n ready,\n };\n};\n"],"names":["useRef","createThreadManagerState","ThreadMessageManager","AdkPlugin","uuid","ChatController","useMemoizedFn","dayjs"],"mappings":";;;;;;;;AAeO,MAAM,YAAY,GAAG,CAAC,EAC3B,aAAa,EACb,OAAO,EACP,UAAU,GAWX,KAAI;AACH,IAAA,MAAM,aAAa,GAAGA,YAAM,CAAwB,IAAI,CAAC,CAAC;AAC1D,IAAA,MAAM,YAAY,GAAGA,YAAM,CAAmB,IAAI,CAAC,CAAC;AAEpD,IAAA,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;AAC1B,QAAA,MAAM,KAAK,GAAGC,8BAAwB,EAAE,CAAC;AACzC,QAAA,MAAM,YAAY,GAAG,IAAIC,0BAAoB,CAAC,KAAK,CAAC,CAAC;AACrD,QAAA,MAAM,SAAS,GAAG,IAAIC,eAAS,CAAC;AAC9B,YAAA,OAAO,EAAE,UAAU,EAAE,OAAO,IAAI,OAAO;AACvC,YAAA,MAAM,EAAE,UAAU,EAAE,MAAM,IAAIC,EAAI,EAAE;AACrC,SAAA,CAAC,CAAC;AACH,QAAA,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC;AACjC,QAAA,aAAa,CAAC,OAAO,GAAG,IAAIC,oBAAc,CAAC;YACzC,cAAc,EAAE,aAAa,CAAC,cAAc;YAC5C,eAAe,EAAE,aAAa,CAAC,eAAe;YAC9C,OAAO,EAAE,CAAC,SAAS,CAAC;AACpB,YAAA,OAAO,EAAE,OAAO;YAChB,YAAY;AACb,SAAA,CAAC,CAAC;KACJ;IAED,MAAM,KAAK,GAAGC,OAAa,CAAC,CAAC,EAAE,SAAS,EAAyB,KAAI;AACnE,QAAA,aAAa,CAAC,OAAO;AACnB,cAAE,SAAS,CAAC;AACV,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,SAAS,EAAEC,iBAAK,EAAE,CAAC,IAAI,EAAE;SAC1B,CAAC;AACD,aAAA,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,KAAI;AACf,YAAA,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9C,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IAEH,OAAO;QACL,aAAa;QACb,KAAK;KACN,CAAC;AACJ;;;;"}
@@ -0,0 +1,18 @@
1
+ import { ChatController, ProtocolOptions, type RequestOptions } from '@chat-lab/core';
2
+ export declare const useDebugChat: ({ initialConfig, onError, adkOptions, }: {
3
+ initialConfig: {
4
+ requestOptions: RequestOptions;
5
+ protocolOptions: ProtocolOptions;
6
+ };
7
+ adkOptions?: {
8
+ appName: string;
9
+ userID: string;
10
+ };
11
+ onError?: (error: Error) => void;
12
+ }) => {
13
+ controllerRef: import("react").MutableRefObject<ChatController<import("@chat-lab/core").ChatMessage<import("@chat-lab/core").BaseMessage>> | null>;
14
+ ready: (this: unknown, args_0: {
15
+ sessionId: string;
16
+ }) => void;
17
+ };
18
+ //# sourceMappingURL=useDebugChat.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebugChat.d.ts","sourceRoot":"","sources":["../../src/hooks/useDebugChat.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,cAAc,EAEd,eAAe,EAEf,KAAK,cAAc,EAGpB,MAAM,gBAAgB,CAAC;AAKxB,eAAO,MAAM,YAAY,GAAI,yCAI1B;IACD,aAAa,EAAE;QACb,cAAc,EAAE,cAAc,CAAC;QAC/B,eAAe,EAAE,eAAe,CAAC;KAClC,CAAC;IACF,UAAU,CAAC,EAAE;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CAClC;;;mBAqB0D,MAAM;;CAmBhE,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { useRef } from 'react';
2
+ import { createThreadManagerState, AdkPlugin, ChatController, ThreadMessageManager } from '../packages/core/dist/index.js';
3
+ import dayjs from '../node_modules/.pnpm/dayjs@1.11.18/node_modules/dayjs/dayjs.min.js';
4
+ import useMemoizedFn from '../node_modules/.pnpm/ahooks@3.9.6_react-dom@17.0.2_react@17.0.2__react@17.0.2/node_modules/ahooks/es/useMemoizedFn/index.js';
5
+ import v4 from '../node_modules/.pnpm/uuid@13.0.0/node_modules/uuid/dist/v4.js';
6
+
7
+ const useDebugChat = ({ initialConfig, onError, adkOptions, }) => {
8
+ const controllerRef = useRef(null);
9
+ const adkPluginRef = useRef(null);
10
+ if (!controllerRef.current) {
11
+ const state = createThreadManagerState();
12
+ const storeManager = new ThreadMessageManager(state);
13
+ const adkPlugin = new AdkPlugin({
14
+ appName: adkOptions?.appName || 'veadk',
15
+ userId: adkOptions?.userID || v4(),
16
+ });
17
+ adkPluginRef.current = adkPlugin;
18
+ controllerRef.current = new ChatController({
19
+ requestOptions: initialConfig.requestOptions,
20
+ protocolOptions: initialConfig.protocolOptions,
21
+ plugins: [adkPlugin],
22
+ onError: onError,
23
+ storeManager,
24
+ });
25
+ }
26
+ const ready = useMemoizedFn(({ sessionId }) => {
27
+ controllerRef.current
28
+ ?.addThread({
29
+ id: sessionId,
30
+ name: sessionId,
31
+ sending: false,
32
+ metadata: {},
33
+ messages: [],
34
+ createdAt: dayjs().unix(),
35
+ })
36
+ .then(({ id }) => {
37
+ controllerRef.current?.setCurrentThread(id);
38
+ });
39
+ });
40
+ return {
41
+ controllerRef,
42
+ ready,
43
+ };
44
+ };
45
+
46
+ export { useDebugChat };
47
+ //# sourceMappingURL=useDebugChat.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDebugChat.js","sources":["../../src/hooks/useDebugChat.tsx"],"sourcesContent":["import { useState, Ref, useRef } from 'react';\nimport {\n AdkPlugin,\n ChatController,\n createThreadManagerState,\n ProtocolOptions,\n ThreadMessageManager,\n type RequestOptions,\n A2ACompletion,\n AdkCompletion,\n} from '@chat-lab/core';\nimport { v4 as uuid } from 'uuid';\nimport dayjs from 'dayjs';\nimport { useMemoizedFn } from 'ahooks';\n\nexport const useDebugChat = ({\n initialConfig,\n onError,\n adkOptions,\n}: {\n initialConfig: {\n requestOptions: RequestOptions;\n protocolOptions: ProtocolOptions;\n };\n adkOptions?: {\n appName: string;\n userID: string;\n };\n onError?: (error: Error) => void;\n}) => {\n const controllerRef = useRef<ChatController | null>(null);\n const adkPluginRef = useRef<AdkPlugin | null>(null);\n\n if (!controllerRef.current) {\n const state = createThreadManagerState();\n const storeManager = new ThreadMessageManager(state);\n const adkPlugin = new AdkPlugin({\n appName: adkOptions?.appName || 'veadk',\n userId: adkOptions?.userID || uuid(),\n });\n adkPluginRef.current = adkPlugin;\n controllerRef.current = new ChatController({\n requestOptions: initialConfig.requestOptions,\n protocolOptions: initialConfig.protocolOptions,\n plugins: [adkPlugin],\n onError: onError,\n storeManager,\n });\n }\n\n const ready = useMemoizedFn(({ sessionId }: { sessionId: string }) => {\n controllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n sending: false,\n metadata: {},\n messages: [],\n createdAt: dayjs().unix(),\n })\n .then(({ id }) => {\n controllerRef.current?.setCurrentThread(id);\n });\n });\n\n return {\n controllerRef,\n ready,\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C,CAAC,EAAE,EAAE,EAAE,KAAI;AACf,YAAA,aAAa,CAAC,OAAO,EAAE,gBAAgB,CAAC,EAAE,CAAC,CAAC;AAC9C,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IAEH,OAAO;QACL,aAAa;QACb,KAAK;KACN,CAAC;AACJ;;;;"}
@@ -34,7 +34,17 @@ const useSkillAgent = (options) => {
34
34
  plugins: [plugin, adlPlugin],
35
35
  });
36
36
  }
37
- const sendMessage = index$1(({ message, sessionId }) => {
37
+ const sendMessage = index$1(({ message }) => {
38
+ chatControllerRef.current?.sendMessage({
39
+ content: [
40
+ {
41
+ type: 'text',
42
+ text: message,
43
+ },
44
+ ],
45
+ });
46
+ });
47
+ const ready = index$1(({ sessionId }) => {
38
48
  chatControllerRef.current
39
49
  ?.addThread({
40
50
  id: sessionId,
@@ -45,19 +55,12 @@ const useSkillAgent = (options) => {
45
55
  })
46
56
  .then(() => {
47
57
  chatControllerRef.current?.setCurrentThread(sessionId);
48
- chatControllerRef.current?.sendMessage({
49
- content: [
50
- {
51
- type: 'text',
52
- text: message,
53
- },
54
- ],
55
- });
56
58
  });
57
59
  });
58
60
  return {
59
61
  controllerRef: chatControllerRef,
60
62
  sendMessage,
63
+ ready,
61
64
  };
62
65
  };
63
66
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../../../src/hooks/useSkillAgent/index.tsx"],"sourcesContent":["import {\n ChatController,\n createThreadManagerState,\n ThreadMessageManager,\n AdkPlugin,\n} from '@chat-lab/core';\nimport { useRef } from 'react';\nimport { v4 as uuid } from 'uuid';\nimport SkillAgentPlugin from './SkillAgentPlugin';\nimport { useMemoizedFn } from 'ahooks';\n\nexport interface SkillAgentOptions {\n api: string;\n sessionId?: string;\n adkOptions: {\n appName: string;\n userID: string;\n };\n query?: Record<string, string>;\n onError?: (error: Error) => void;\n onStateChange?: (state: string) => void;\n}\n\nconst useSkillAgent = (options: SkillAgentOptions) => {\n const chatControllerRef = useRef<ChatController>();\n if (!chatControllerRef.current) {\n const store = new ThreadMessageManager(createThreadManagerState());\n const plugin = new SkillAgentPlugin({\n onStateChange: options.onStateChange,\n });\n const adlPlugin = new AdkPlugin({\n appName: options.adkOptions.appName,\n userId: options.adkOptions.userID,\n });\n chatControllerRef.current = new ChatController({\n requestOptions: {\n api: options.api,\n meta: options.query,\n headers: {\n Authorization: 'Bearer',\n },\n defaultParams: {\n streaming: true,\n },\n },\n protocolOptions: {\n protocol: 'ADK',\n },\n storeManager: store,\n plugins: [plugin, adlPlugin],\n });\n }\n\n const sendMessage = useMemoizedFn(\n ({ message, sessionId }: { message: string; sessionId: string }) => {\n chatControllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n metadata: {},\n sending: false,\n messages: [],\n })\n .then(() => {\n chatControllerRef.current?.setCurrentThread(sessionId);\n chatControllerRef.current?.sendMessage({\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n });\n });\n },\n );\n\n return {\n controllerRef: chatControllerRef,\n sendMessage,\n };\n};\n\nexport { useSkillAgent };\n"],"names":["useRef","ThreadMessageManager","createThreadManagerState","AdkPlugin","ChatController","useMemoizedFn"],"mappings":";;;;;;;AAuBA,MAAM,aAAa,GAAG,CAAC,OAA0B,KAAI;AACnD,IAAA,MAAM,iBAAiB,GAAGA,YAAM,EAAkB,CAAC;AACnD,IAAA,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE;QAC9B,MAAM,KAAK,GAAG,IAAIC,0BAAoB,CAACC,8BAAwB,EAAE,CAAC,CAAC;AACnE,QAAA,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;YAClC,aAAa,EAAE,OAAO,CAAC,aAAa;AACrC,SAAA,CAAC,CAAC;AACH,QAAA,MAAM,SAAS,GAAG,IAAIC,eAAS,CAAC;AAC9B,YAAA,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO;AACnC,YAAA,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;AAClC,SAAA,C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":["../../../src/hooks/useSkillAgent/index.tsx"],"sourcesContent":["import {\n ChatController,\n createThreadManagerState,\n ThreadMessageManager,\n AdkPlugin,\n} from '@chat-lab/core';\nimport { useRef } from 'react';\nimport { v4 as uuid } from 'uuid';\nimport SkillAgentPlugin from './SkillAgentPlugin';\nimport { useMemoizedFn } from 'ahooks';\n\nexport interface SkillAgentOptions {\n api: string;\n sessionId?: string;\n adkOptions: {\n appName: string;\n userID: string;\n };\n query?: Record<string, string>;\n onError?: (error: Error) => void;\n onStateChange?: (state: string) => void;\n}\n\nconst useSkillAgent = (options: SkillAgentOptions) => {\n const chatControllerRef = useRef<ChatController>();\n if (!chatControllerRef.current) {\n const store = new ThreadMessageManager(createThreadManagerState());\n const plugin = new SkillAgentPlugin({\n onStateChange: options.onStateChange,\n });\n const adlPlugin = new AdkPlugin({\n appName: options.adkOptions.appName,\n userId: options.adkOptions.userID,\n });\n chatControllerRef.current = new ChatController({\n requestOptions: {\n api: options.api,\n meta: options.query,\n headers: {\n Authorization: 'Bearer',\n },\n defaultParams: {\n streaming: true,\n },\n },\n protocolOptions: {\n protocol: 'ADK',\n },\n storeManager: store,\n plugins: [plugin, adlPlugin],\n });\n }\n\n const sendMessage = useMemoizedFn(({ message }: { message: string }) => {\n chatControllerRef.current?.sendMessage({\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n });\n });\n const ready = useMemoizedFn(({ sessionId }: { sessionId: string }) => {\n chatControllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n metadata: {},\n sending: false,\n messages: [],\n })\n .then(() => {\n chatControllerRef.current?.setCurrentThread(sessionId);\n });\n });\n return {\n controllerRef: chatControllerRef,\n sendMessage,\n ready,\n };\n};\n\nexport { useSkillAgent };\n"],"names":["useRef","ThreadMessageManager","createThreadManagerState","AdkPlugin","ChatController","useMemoizedFn"],"mappings":";;;;;;;AAuBA,MAAM,aAAa,GAAG,CAAC,OAA0B,KAAI;AACnD,IAAA,MAAM,iBAAiB,GAAGA,YA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CAAC,CAAC,EAAE,SAAS,EAAyB,KAAI;AACnE,QAAA,iBAAiB,CAAC,OAAO;AACvB,cAAE,SAAS,CAAC;AACV,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;aACD,IAAI,CAAC,MAAK;AACT,YAAA,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACzD,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IACH,OAAO;AACL,QAAA,aAAa,EAAE,iBAAiB;QAChC,WAAW;QACX,KAAK;KACN,CAAC;AACJ;;;;"}
@@ -14,6 +14,8 @@ declare const useSkillAgent: (options: SkillAgentOptions) => {
14
14
  controllerRef: import("react").MutableRefObject<ChatController<import("@chat-lab/core").ChatMessage<import("@chat-lab/core").BaseMessage>> | undefined>;
15
15
  sendMessage: (this: unknown, args_0: {
16
16
  message: string;
17
+ }) => void;
18
+ ready: (this: unknown, args_0: {
17
19
  sessionId: string;
18
20
  }) => void;
19
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSkillAgent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,QAAA,MAAM,aAAa,GAAI,SAAS,iBAAiB;;;iBA+BT,MAAM;mBAAa,MAAM;;CA2BhE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/useSkillAgent/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAIf,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE;QACV,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IACF,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,QAAA,MAAM,aAAa,GAAI,SAAS,iBAAiB;;;iBA8BY,MAAM;;;mBAUR,MAAM;;CAkBhE,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,CAAC"}
@@ -32,7 +32,17 @@ const useSkillAgent = (options) => {
32
32
  plugins: [plugin, adlPlugin],
33
33
  });
34
34
  }
35
- const sendMessage = useMemoizedFn(({ message, sessionId }) => {
35
+ const sendMessage = useMemoizedFn(({ message }) => {
36
+ chatControllerRef.current?.sendMessage({
37
+ content: [
38
+ {
39
+ type: 'text',
40
+ text: message,
41
+ },
42
+ ],
43
+ });
44
+ });
45
+ const ready = useMemoizedFn(({ sessionId }) => {
36
46
  chatControllerRef.current
37
47
  ?.addThread({
38
48
  id: sessionId,
@@ -43,19 +53,12 @@ const useSkillAgent = (options) => {
43
53
  })
44
54
  .then(() => {
45
55
  chatControllerRef.current?.setCurrentThread(sessionId);
46
- chatControllerRef.current?.sendMessage({
47
- content: [
48
- {
49
- type: 'text',
50
- text: message,
51
- },
52
- ],
53
- });
54
56
  });
55
57
  });
56
58
  return {
57
59
  controllerRef: chatControllerRef,
58
60
  sendMessage,
61
+ ready,
59
62
  };
60
63
  };
61
64
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/hooks/useSkillAgent/index.tsx"],"sourcesContent":["import {\n ChatController,\n createThreadManagerState,\n ThreadMessageManager,\n AdkPlugin,\n} from '@chat-lab/core';\nimport { useRef } from 'react';\nimport { v4 as uuid } from 'uuid';\nimport SkillAgentPlugin from './SkillAgentPlugin';\nimport { useMemoizedFn } from 'ahooks';\n\nexport interface SkillAgentOptions {\n api: string;\n sessionId?: string;\n adkOptions: {\n appName: string;\n userID: string;\n };\n query?: Record<string, string>;\n onError?: (error: Error) => void;\n onStateChange?: (state: string) => void;\n}\n\nconst useSkillAgent = (options: SkillAgentOptions) => {\n const chatControllerRef = useRef<ChatController>();\n if (!chatControllerRef.current) {\n const store = new ThreadMessageManager(createThreadManagerState());\n const plugin = new SkillAgentPlugin({\n onStateChange: options.onStateChange,\n });\n const adlPlugin = new AdkPlugin({\n appName: options.adkOptions.appName,\n userId: options.adkOptions.userID,\n });\n chatControllerRef.current = new ChatController({\n requestOptions: {\n api: options.api,\n meta: options.query,\n headers: {\n Authorization: 'Bearer',\n },\n defaultParams: {\n streaming: true,\n },\n },\n protocolOptions: {\n protocol: 'ADK',\n },\n storeManager: store,\n plugins: [plugin, adlPlugin],\n });\n }\n\n const sendMessage = useMemoizedFn(\n ({ message, sessionId }: { message: string; sessionId: string }) => {\n chatControllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n metadata: {},\n sending: false,\n messages: [],\n })\n .then(() => {\n chatControllerRef.current?.setCurrentThread(sessionId);\n chatControllerRef.current?.sendMessage({\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n });\n });\n },\n );\n\n return {\n controllerRef: chatControll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AAI,EAAE,SAAS;AACf,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;aACD,IAAI,CAAC,MAAK;AACT,YAAA,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACvD,YAAA,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;AACrC,gBAAA,OAAO,EAAE;AACP,oBAAA;AACE,wBAAA,IAAI,EAAE,MAAM;AACZ,wBAAA,IAAI,EAAE,OAAO;AACd,qBAAA;AACF,iBAAA;AACF,aAAA,CAAC,CAAC;AACL,SAAC,CAAC,CAAC;AACP,KAAC,CACF,CAAC;IAEF,OAAO;AACL,QAAA,aAAa,EAAE,iBAAiB;QAChC,WAAW;KACZ,CAAC;AACJ;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/hooks/useSkillAgent/index.tsx"],"sourcesContent":["import {\n ChatController,\n createThreadManagerState,\n ThreadMessageManager,\n AdkPlugin,\n} from '@chat-lab/core';\nimport { useRef } from 'react';\nimport { v4 as uuid } from 'uuid';\nimport SkillAgentPlugin from './SkillAgentPlugin';\nimport { useMemoizedFn } from 'ahooks';\n\nexport interface SkillAgentOptions {\n api: string;\n sessionId?: string;\n adkOptions: {\n appName: string;\n userID: string;\n };\n query?: Record<string, string>;\n onError?: (error: Error) => void;\n onStateChange?: (state: string) => void;\n}\n\nconst useSkillAgent = (options: SkillAgentOptions) => {\n const chatControllerRef = useRef<ChatController>();\n if (!chatControllerRef.current) {\n const store = new ThreadMessageManager(createThreadManagerState());\n const plugin = new SkillAgentPlugin({\n onStateChange: options.onStateChange,\n });\n const adlPlugin = new AdkPlugin({\n appName: options.adkOptions.appName,\n userId: options.adkOptions.userID,\n });\n chatControllerRef.current = new ChatController({\n requestOptions: {\n api: options.api,\n meta: options.query,\n headers: {\n Authorization: 'Bearer',\n },\n defaultParams: {\n streaming: true,\n },\n },\n protocolOptions: {\n protocol: 'ADK',\n },\n storeManager: store,\n plugins: [plugin, adlPlugin],\n });\n }\n\n const sendMessage = useMemoizedFn(({ message }: { message: string }) => {\n chatControllerRef.current?.sendMessage({\n content: [\n {\n type: 'text',\n text: message,\n },\n ],\n });\n });\n const ready = useMemoizedFn(({ sessionId }: { sessionId: string }) => {\n chatControllerRef.current\n ?.addThread({\n id: sessionId,\n name: sessionId,\n metadata: {},\n sending: false,\n messages: [],\n })\n .then(() => {\n chatControllerRef.current?.setCurrentThread(sessionId);\n });\n });\n return {\n controllerRef: chatControllerRef,\n sendMessage,\n ready,\n };\n};\n\nexport { useSkillAgent };\n"],"names":[],"mappings":";;;;;AAuBA,MAAM,aAAa,GAAG,CAAC,OAA0B,KAAI;AACnD,IAAA,MAAM,iBAAiB,GAAG,MAAM,EAAkB,CAAC;AACnD,IAAA,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE;QAC9B,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,wBAAwB,EAAE,CAAC,CAAC;AACnE,QAAA,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC;YAClC,aAAa,EAAE,OAAO,CAAC,aAAa;AACrC,SAAA,CAAC,CAAC;AACH,QAAA,MAAM,SAAS,GAAG,IAAI,SAAS,CAAC;AAC9B,YAAA,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO;AACnC,YAAA,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM;AAClC,SAAA,CAAC,CAAC;AACH,QAAA,iBAAiB,CAAC,OAAO,GAAG,IAAI,cAAc,CAAC;AAC7C,YAAA,cAAc,EAAE;gBACd,GAAG,EAAE,OAAO,CAAC,GAAG;gBAChB,IAAI,EAAE,OAAO,CAAC,KAAK;AACnB,gBAAA,OAAO,EAAE;AACP,oBAAA,aAAa,EAAE,QAAQ;AACxB,iBAAA;AACD,gBAAA,aAAa,EAAE;AACb,oBAAA,SAAS,EAAE,IAAI;AAChB,iBAAA;AACF,aAAA;AACD,YAAA,eAAe,EAAE;AACf,gBAAA,QAAQ,EAAE,KAAK;AAChB,aAAA;AACD,YAAA,YAAY,EAAE,KAAK;AACnB,YAAA,OAAO,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;AAC7B,SAAA,CAAC,CAAC;KACJ;IAED,MAAM,WAAW,GAAG,aAAa,CAAC,CAAC,EAAE,OAAO,EAAuB,KAAI;AACrE,QAAA,iBAAiB,CAAC,OAAO,EAAE,WAAW,CAAC;AACrC,YAAA,OAAO,EAAE;AACP,gBAAA;AACE,oBAAA,IAAI,EAAE,MAAM;AACZ,oBAAA,IAAI,EAAE,OAAO;AACd,iBAAA;AACF,aAAA;AACF,SAAA,CAAC,CAAC;AACL,KAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,aAAa,CAAC,CAAC,EAAE,SAAS,EAAyB,KAAI;AACnE,QAAA,iBAAiB,CAAC,OAAO;AACvB,cAAE,SAAS,CAAC;AACV,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,IAAI,EAAE,SAAS;AACf,YAAA,QAAQ,EAAE,EAAE;AACZ,YAAA,OAAO,EAAE,KAAK;AACd,YAAA,QAAQ,EAAE,EAAE;SACb,CAAC;aACD,IAAI,CAAC,MAAK;AACT,YAAA,iBAAiB,CAAC,OAAO,EAAE,gBAAgB,CAAC,SAAS,CAAC,CAAC;AACzD,SAAC,CAAC,CAAC;AACP,KAAC,CAAC,CAAC;IACH,OAAO;AACL,QAAA,aAAa,EAAE,iBAAiB;QAChC,WAAW;QACX,KAAK;KACN,CAAC;AACJ;;;;"}
package/dist/index.cjs CHANGED
@@ -8,6 +8,7 @@ var useADKChat = require('./hooks/useADKChat.cjs');
8
8
  var useChat = require('./hooks/useChat.cjs');
9
9
  require('./packages/core/dist/index.cjs');
10
10
  var index$3 = require('./hooks/useSkillAgent/index.cjs');
11
+ var useDebugChat = require('./hooks/useDebugChat.cjs');
11
12
  var chatCompletion = require('./utils/chatCompletion.cjs');
12
13
  var download = require('./utils/download.cjs');
13
14
  var multimodal = require('./utils/multimodal.cjs');
@@ -30,6 +31,7 @@ exports.VoiceInput = index$2;
30
31
  exports.useADKChat = useADKChat.useADKChat;
31
32
  exports.useChat = useChat.useChat;
32
33
  exports.useSkillAgent = index$3.useSkillAgent;
34
+ exports.useDebugChat = useDebugChat.useDebugChat;
33
35
  exports.fetchChatCompletion = chatCompletion.fetchChatCompletion;
34
36
  exports.saveMultipleStringsToMarkdown = download.saveMultipleStringsToMarkdown;
35
37
  exports.saveObjectToMarkdown = download.saveObjectToMarkdown;
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -9,6 +9,7 @@ export { useADKChat } from './hooks/useADKChat';
9
9
  export { useChat } from './hooks/useChat';
10
10
  export { useSnapshot } from '@chat-lab/core';
11
11
  export { useSkillAgent } from './hooks/useSkillAgent';
12
+ export { useDebugChat } from './hooks/useDebugChat';
12
13
  export * from './utils/chatCompletion';
13
14
  export * from './utils/download';
14
15
  export * from './utils/multimodal';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,cAAc,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Ac,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AAEvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,sDAAsD,CAAC;AAEzF,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC"}
package/dist/index.js CHANGED
@@ -6,6 +6,7 @@ export { useADKChat } from './hooks/useADKChat.js';
6
6
  export { useChat } from './hooks/useChat.js';
7
7
  import './packages/core/dist/index.js';
8
8
  export { useSkillAgent } from './hooks/useSkillAgent/index.js';
9
+ export { useDebugChat } from './hooks/useDebugChat.js';
9
10
  export { fetchChatCompletion } from './utils/chatCompletion.js';
10
11
  export { saveMultipleStringsToMarkdown, saveObjectToMarkdown, saveStringToMarkdown } from './utils/download.js';
11
12
  export { FILE_TYPE_CONFIGS, MULTIMODAL_MODELS, getAllModelMultimodalSupport, getAllSupportedModelPatterns, getFileInfoFromUrl, getFileTypeByExtension, getFileTypeByMimeType, getFileTypeConfig, getModelAcceptPattern, getModelFileTypeConfig, getModelMultimodalSupport, getSupportedFileTypeConfigs, isFileSizeValid, isFileTypeSupported, isMimeTypeSupported, isModelMultimodalSupported, testModelIdMatch } from './utils/multimodal.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chat-lab/ui",
3
- "version": "0.1.0-beta.50",
3
+ "version": "0.1.0-beta.51",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",