@looopy-ai/core 2.1.24 → 2.1.26

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,9 +1,9 @@
1
- import type { MaterializedSkill, Skill } from '../types';
1
+ import type { Skill } from '../types';
2
2
  import type { IterationContext, Plugin, SystemPrompt } from '../types/core';
3
3
  export declare const learnSkillToolName = "learn_skill";
4
4
  export declare const getInstruction: (instruction: string | (() => Promise<string>)) => Promise<string>;
5
5
  export declare const skill: (definition: Skill) => Skill;
6
6
  export type AgentAcademyOptions<AuthContext> = {
7
- learnSkillPrompt?: (skills: MaterializedSkill[], context: IterationContext<AuthContext>) => Promise<string | SystemPrompt>;
7
+ learnSkillPrompt?: (skills: Skill[], context: IterationContext<AuthContext>) => Promise<string | SystemPrompt>;
8
8
  };
9
9
  export declare function agentAcademy<AuthContext>(skills: Skill[], options?: AgentAcademyOptions<AuthContext>): Plugin<AuthContext>;
@@ -12,6 +12,13 @@ export const skill = (definition) => {
12
12
  return { ...definition };
13
13
  };
14
14
  export function agentAcademy(skills, options) {
15
+ const skillMap = new Map();
16
+ for (const skill of skills) {
17
+ if (skillMap.has(skill.name)) {
18
+ throw new Error(`Duplicate skill name: ${skill.name}`);
19
+ }
20
+ skillMap.set(skill.name, skill);
21
+ }
15
22
  const learnSkillToolDefinition = {
16
23
  id: learnSkillToolName,
17
24
  description: 'Learns a new skill from the available agent academy.',
@@ -28,18 +35,13 @@ export function agentAcademy(skills, options) {
28
35
  },
29
36
  };
30
37
  const learnSkillPromptFn = options?.learnSkillPrompt ?? defaultPrompt;
31
- const materializedSkillsPromises = skills.map(async (s) => ({
32
- ...s,
33
- instruction: await getInstruction(s.instruction),
34
- }));
35
- const materializedSkills = Promise.all(materializedSkillsPromises);
36
38
  return {
37
39
  name: 'agent-academy',
38
40
  generateSystemPrompts: async (context) => {
39
41
  if (!learnSkillPromptFn) {
40
42
  return [];
41
43
  }
42
- const prompt = await learnSkillPromptFn(await materializedSkills, context);
44
+ const prompt = await learnSkillPromptFn(skills, context);
43
45
  if (typeof prompt === 'string') {
44
46
  return [
45
47
  {
@@ -80,7 +82,6 @@ export function agentAcademy(skills, options) {
80
82
  name: z.string().describe('The name of the skill to learn.'),
81
83
  });
82
84
  const validatedParams = schema.parse(toolCall.function.arguments);
83
- const skillMap = buildMaterializedSkillMap(await materializedSkills);
84
85
  const foundSkill = skillMap.get(validatedParams.name);
85
86
  if (!foundSkill) {
86
87
  const availableSkills = Array.from(skillMap.values())
@@ -128,14 +129,9 @@ export function agentAcademy(skills, options) {
128
129
  }).pipe(mergeMap((result) => toolResultToEvents(result)), catchError((error) => of(toolErrorEvent(toolCall, error instanceof Error ? error.message : String(error))))),
129
130
  };
130
131
  }
131
- const buildMaterializedSkillMap = (skills) => {
132
- const map = new Map();
133
- skills.forEach((skill) => {
134
- map.set(skill.name, skill);
135
- });
136
- return map;
137
- };
138
132
  const defaultPrompt = (skills) => {
139
- const skillList = skills.map((skill) => `- **${skill.name}**: ${skill.instruction}`).join('\n');
133
+ const skillList = skills
134
+ .map((skill) => `- **${skill.name}**: ${skill.description || 'A useful skill.'}`)
135
+ .join('\n');
140
136
  return `You can learn new skills using the learn_skill tool. The available skills are:\n\n${skillList}\n\nTo learn a skill, call the learn_skill tool with the name of the skill you want to learn.`;
141
137
  };
@@ -79,6 +79,7 @@ export class AgentToolProvider {
79
79
  const logger = this.logger.child({
80
80
  taskId: context.taskId,
81
81
  toolCallId: toolCall.id,
82
+ url: this.card.url,
82
83
  });
83
84
  logger.debug({ toolCallId: toolCall.id }, 'Executing agent tool call');
84
85
  return new Observable((subscriber) => {
@@ -3,11 +3,6 @@ export interface Skill {
3
3
  description: string;
4
4
  instruction: string | (() => Promise<string>);
5
5
  }
6
- export interface MaterializedSkill {
7
- name: string;
8
- description: string;
9
- instruction: string;
10
- }
11
6
  export interface SkillRegistration {
12
7
  [key: string]: Skill;
13
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@looopy-ai/core",
3
- "version": "2.1.24",
3
+ "version": "2.1.26",
4
4
  "description": "RxJS-based AI agent framework",
5
5
  "repository": {
6
6
  "url": "https://github.com/looopy-ai/lib"