@adminforth/agent 1.3.1 → 1.5.0

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.
@@ -6,6 +6,11 @@ import { parse as parseYaml } from "yaml";
6
6
  const PLUGIN_SKILLS_DIRECTORY_PATH = fileURLToPath(
7
7
  new URL("../../custom/skills/", import.meta.url),
8
8
  );
9
+ const USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS = [
10
+ "plugins",
11
+ "adminforth-agent",
12
+ "skills",
13
+ ];
9
14
  const SKILL_MARKDOWN_FILENAME = "SKILL.md";
10
15
  const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
11
16
 
@@ -78,13 +83,31 @@ export function getProjectSkillsDirectoryPath(customComponentsDir: string) {
78
83
  return path.resolve(customComponentsDir, "skills");
79
84
  }
80
85
 
86
+ export function getProjectPluginSkillsDirectoryPath(customComponentsDir: string) {
87
+ return path.resolve(
88
+ customComponentsDir,
89
+ ...USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS,
90
+ );
91
+ }
92
+
93
+ function getProjectSkillDirectoryPaths(customComponentsDir: string) {
94
+ return [
95
+ getProjectSkillsDirectoryPath(customComponentsDir),
96
+ getProjectPluginSkillsDirectoryPath(customComponentsDir),
97
+ ];
98
+ }
99
+
81
100
  export async function listBundledSkillManifests() {
82
101
  return await listDirectorySkillManifests(PLUGIN_SKILLS_DIRECTORY_PATH);
83
102
  }
84
103
 
85
104
  export async function listProjectSkillManifests(customComponentsDir: string) {
86
- return await listDirectorySkillManifests(
87
- getProjectSkillsDirectoryPath(customComponentsDir),
105
+ return mergeSkillManifests(
106
+ await Promise.all(
107
+ getProjectSkillDirectoryPaths(customComponentsDir).map(
108
+ listDirectorySkillManifests,
109
+ ),
110
+ ),
88
111
  );
89
112
  }
90
113
 
@@ -114,7 +137,7 @@ export async function loadSkillMarkdown(skillName: string, customComponentsDir:
114
137
  }
115
138
 
116
139
  const directories = [
117
- getProjectSkillsDirectoryPath(customComponentsDir),
140
+ ...getProjectSkillDirectoryPaths(customComponentsDir),
118
141
  PLUGIN_SKILLS_DIRECTORY_PATH,
119
142
  ];
120
143
 
package/build.log CHANGED
@@ -29,5 +29,5 @@ custom/skills/fetch_data/SKILL.md
29
29
  custom/skills/mutate_data/
30
30
  custom/skills/mutate_data/SKILL.md
31
31
 
32
- sent 169,707 bytes received 413 bytes 340,240.00 bytes/sec
33
- total size is 168,033 speedup is 0.99
32
+ sent 170,096 bytes received 413 bytes 341,018.00 bytes/sec
33
+ total size is 168,447 speedup is 0.99
@@ -25,7 +25,7 @@
25
25
  :key="session.sessionId"
26
26
  class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200 overflow-hidden text-nowrap"
27
27
  :class="{'bg-lightPrimary/20 hover:bg-lightPrimary/20 dark:bg-darkPrimary/20 dark:hover:bg-darkPrimary/20': agentStore.activeSessionId === session.sessionId, 'cursor-default opacity-50 pointer-events-none': agentStore.isResponseInProgress}"
28
- @click="agentStore.setActiveSession(session.sessionId)"
28
+ @click="agentStore.setActiveSession(session.sessionId); agentStore.setSessionHistoryOpen(false);"
29
29
  :disabled="agentStore.isResponseInProgress"
30
30
  >
31
31
  {{ session.title || session.sessionId }}
@@ -26,6 +26,7 @@ export const useAgentStore = defineStore('agent', () => {
26
26
  const coreStore = useCoreStore();
27
27
  const appRoot = ref<HTMLElement | null>(null);
28
28
  const header = ref<HTMLElement | null>(null);
29
+ const lastSessionId = ref<string | null>(null);
29
30
  const chatWidth = ref(600);
30
31
  function setLocalStorageItem(key: string, value: string) {
31
32
  window.localStorage.setItem(`${coreStore.config.brandName || 'adminforth'}-${key}`, value);
@@ -42,9 +43,18 @@ export const useAgentStore = defineStore('agent', () => {
42
43
  watch(chatWidth, (newVal: number) => {
43
44
  setLocalStorageItem('chatWidth', newVal.toString());
44
45
  })
46
+ watch(activeSessionId, (newVal: string | null) => {
47
+ if (newVal) {
48
+ setLocalStorageItem('lastSessionId', newVal);
49
+ }
50
+ })
45
51
  onMounted(() => {
46
52
  chatWidth.value = parseInt(getLocalStorageItem('chatWidth') || '600', 10);
47
53
  isTeleportedToBody.value = getLocalStorageItem('isTeleportedToBody') === 'true';
54
+ lastSessionId.value = getLocalStorageItem('lastSessionId');
55
+ if (lastSessionId.value && lastSessionId.value !== 'pre-session') {
56
+ setActiveSession(lastSessionId.value);
57
+ }
48
58
  if (isTeleportedToBody.value) {
49
59
  isChatOpen.value = getLocalStorageItem('isChatOpen') === 'true';
50
60
  }
@@ -12,6 +12,11 @@ import path from "path";
12
12
  import { fileURLToPath } from "url";
13
13
  import { parse as parseYaml } from "yaml";
14
14
  const PLUGIN_SKILLS_DIRECTORY_PATH = fileURLToPath(new URL("../../custom/skills/", import.meta.url));
15
+ const USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS = [
16
+ "plugins",
17
+ "adminforth-agent",
18
+ "skills",
19
+ ];
15
20
  const SKILL_MARKDOWN_FILENAME = "SKILL.md";
16
21
  const SKILL_FRONTMATTER_SEPARATOR = "\n---\n";
17
22
  function parseSkillManifest(directoryName, markdown) {
@@ -58,6 +63,15 @@ function mergeSkillManifests(skillGroups) {
58
63
  export function getProjectSkillsDirectoryPath(customComponentsDir) {
59
64
  return path.resolve(customComponentsDir, "skills");
60
65
  }
66
+ export function getProjectPluginSkillsDirectoryPath(customComponentsDir) {
67
+ return path.resolve(customComponentsDir, ...USER_PLUGIN_SKILLS_DIRECTORY_PATH_SEGMENTS);
68
+ }
69
+ function getProjectSkillDirectoryPaths(customComponentsDir) {
70
+ return [
71
+ getProjectSkillsDirectoryPath(customComponentsDir),
72
+ getProjectPluginSkillsDirectoryPath(customComponentsDir),
73
+ ];
74
+ }
61
75
  export function listBundledSkillManifests() {
62
76
  return __awaiter(this, void 0, void 0, function* () {
63
77
  return yield listDirectorySkillManifests(PLUGIN_SKILLS_DIRECTORY_PATH);
@@ -65,7 +79,7 @@ export function listBundledSkillManifests() {
65
79
  }
66
80
  export function listProjectSkillManifests(customComponentsDir) {
67
81
  return __awaiter(this, void 0, void 0, function* () {
68
- return yield listDirectorySkillManifests(getProjectSkillsDirectoryPath(customComponentsDir));
82
+ return mergeSkillManifests(yield Promise.all(getProjectSkillDirectoryPaths(customComponentsDir).map(listDirectorySkillManifests)));
69
83
  });
70
84
  }
71
85
  export function listSkillManifests(customComponentsDir) {
@@ -90,7 +104,7 @@ export function loadSkillMarkdown(skillName, customComponentsDir) {
90
104
  return null;
91
105
  }
92
106
  const directories = [
93
- getProjectSkillsDirectoryPath(customComponentsDir),
107
+ ...getProjectSkillDirectoryPaths(customComponentsDir),
94
108
  PLUGIN_SKILLS_DIRECTORY_PATH,
95
109
  ];
96
110
  for (const skillsDirectoryPath of directories) {
@@ -25,7 +25,7 @@
25
25
  :key="session.sessionId"
26
26
  class="flex items-center justify-between w-full px-4 py-2 cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors duration-200 ease-in-out text-gray-800 dark:text-gray-200 overflow-hidden text-nowrap"
27
27
  :class="{'bg-lightPrimary/20 hover:bg-lightPrimary/20 dark:bg-darkPrimary/20 dark:hover:bg-darkPrimary/20': agentStore.activeSessionId === session.sessionId, 'cursor-default opacity-50 pointer-events-none': agentStore.isResponseInProgress}"
28
- @click="agentStore.setActiveSession(session.sessionId)"
28
+ @click="agentStore.setActiveSession(session.sessionId); agentStore.setSessionHistoryOpen(false);"
29
29
  :disabled="agentStore.isResponseInProgress"
30
30
  >
31
31
  {{ session.title || session.sessionId }}
@@ -26,6 +26,7 @@ export const useAgentStore = defineStore('agent', () => {
26
26
  const coreStore = useCoreStore();
27
27
  const appRoot = ref<HTMLElement | null>(null);
28
28
  const header = ref<HTMLElement | null>(null);
29
+ const lastSessionId = ref<string | null>(null);
29
30
  const chatWidth = ref(600);
30
31
  function setLocalStorageItem(key: string, value: string) {
31
32
  window.localStorage.setItem(`${coreStore.config.brandName || 'adminforth'}-${key}`, value);
@@ -42,9 +43,18 @@ export const useAgentStore = defineStore('agent', () => {
42
43
  watch(chatWidth, (newVal: number) => {
43
44
  setLocalStorageItem('chatWidth', newVal.toString());
44
45
  })
46
+ watch(activeSessionId, (newVal: string | null) => {
47
+ if (newVal) {
48
+ setLocalStorageItem('lastSessionId', newVal);
49
+ }
50
+ })
45
51
  onMounted(() => {
46
52
  chatWidth.value = parseInt(getLocalStorageItem('chatWidth') || '600', 10);
47
53
  isTeleportedToBody.value = getLocalStorageItem('isTeleportedToBody') === 'true';
54
+ lastSessionId.value = getLocalStorageItem('lastSessionId');
55
+ if (lastSessionId.value && lastSessionId.value !== 'pre-session') {
56
+ setActiveSession(lastSessionId.value);
57
+ }
48
58
  if (isTeleportedToBody.value) {
49
59
  isChatOpen.value = getLocalStorageItem('isChatOpen') === 'true';
50
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adminforth/agent",
3
- "version": "1.3.1",
3
+ "version": "1.5.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",