@blocklet/pages-kit 0.2.362 → 0.2.363

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,8 +1,8 @@
1
1
  import { RuntimeOutputVariable } from '@blocklet/ai-runtime/types';
2
2
  import { useMemo } from 'react';
3
- import { joinURL } from 'ufo';
3
+ import { joinURL, withQuery } from 'ufo';
4
4
  import { getComponentMountPoint } from '../../../utils';
5
- import { AI_STUDIO_DID, DEFAULT_INPUT_COMPONENT_ID, DEFAULT_OUTPUT_COMPONENT_ID, DEFAULT_PAGE_COMPONENT_ID, } from '../constants';
5
+ import { AI_RUNTIME_DID, DEFAULT_INPUT_COMPONENT_ID, DEFAULT_OUTPUT_COMPONENT_ID, DEFAULT_PAGE_COMPONENT_ID, } from '../constants';
6
6
  import { useCurrentAgent } from '../contexts/CurrentAgent';
7
7
  import { useRuntimeState } from '../state/runtime';
8
8
  import { getOutputVariableInitialValue } from '../utils/runtime-output-schema';
@@ -47,17 +47,17 @@ export default function useAppearances(args) {
47
47
  }, [agent, runtimeAgent]);
48
48
  return { appearancePage, appearanceInput, appearanceOutput };
49
49
  }
50
- function getProjectIconUrl(projectId) {
51
- return joinURL(window.location.origin, getComponentMountPoint(AI_STUDIO_DID), '/api/projects', projectId, '/logo.png');
50
+ function getProjectIconUrl({ blockletDid, aid }) {
51
+ return withQuery(joinURL(window.location.origin, getComponentMountPoint(AI_RUNTIME_DID), '/api/agents', aid, '/logo'), { blockletDid });
52
52
  }
53
53
  export function useProfile(args) {
54
- const { agent: runtimeAgent } = useRuntimeState();
54
+ const { blockletDid, aid, agent: runtimeAgent } = useRuntimeState();
55
55
  const { agent } = useCurrentAgent(args);
56
56
  return useMemo(() => {
57
57
  const profile = getOutputVariableInitialValue(agent, RuntimeOutputVariable.profile);
58
58
  const runtimeProfile = getOutputVariableInitialValue(runtimeAgent, RuntimeOutputVariable.profile);
59
59
  return {
60
- avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl(agent.project.id),
60
+ avatar: (profile === null || profile === void 0 ? void 0 : profile.avatar) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.avatar) || getProjectIconUrl({ blockletDid, aid }),
61
61
  name: (profile === null || profile === void 0 ? void 0 : profile.name) || (runtimeProfile === null || runtimeProfile === void 0 ? void 0 : runtimeProfile.name) || agent.name,
62
62
  };
63
63
  }, [agent, runtimeAgent]);