@memberjunction/ai-agents 5.43.0 → 5.45.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.
- package/README.md +8 -0
- package/dist/AgentRunner.d.ts +20 -0
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +62 -0
- package/dist/AgentRunner.js.map +1 -1
- package/dist/DuplicateReasoningAgentProvider.d.ts +35 -0
- package/dist/DuplicateReasoningAgentProvider.d.ts.map +1 -0
- package/dist/DuplicateReasoningAgentProvider.js +95 -0
- package/dist/DuplicateReasoningAgentProvider.js.map +1 -0
- package/dist/MJAIAgentRequestEntityServer.d.ts +7 -0
- package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
- package/dist/MJAIAgentRequestEntityServer.js +28 -1
- package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
- package/dist/SkillImportExportService.d.ts +63 -0
- package/dist/SkillImportExportService.d.ts.map +1 -0
- package/dist/SkillImportExportService.js +148 -0
- package/dist/SkillImportExportService.js.map +1 -0
- package/dist/SkillMarkdownConverter.d.ts +82 -0
- package/dist/SkillMarkdownConverter.d.ts.map +1 -0
- package/dist/SkillMarkdownConverter.js +145 -0
- package/dist/SkillMarkdownConverter.js.map +1 -0
- package/dist/agent-types/loop-agent-response-type.d.ts +23 -2
- package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-response-type.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +34 -1
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/base-agent.d.ts +434 -12
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +1215 -89
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +39 -0
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +118 -5
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/operations/AISkillMarkdownOperations.d.ts +11 -0
- package/dist/operations/AISkillMarkdownOperations.d.ts.map +1 -0
- package/dist/operations/AISkillMarkdownOperations.js +57 -0
- package/dist/operations/AISkillMarkdownOperations.js.map +1 -0
- package/dist/prompt-component-resolver.d.ts +73 -0
- package/dist/prompt-component-resolver.d.ts.map +1 -0
- package/dist/prompt-component-resolver.js +166 -0
- package/dist/prompt-component-resolver.js.map +1 -0
- package/dist/realtime/agent-media-library.d.ts +65 -0
- package/dist/realtime/agent-media-library.d.ts.map +1 -0
- package/dist/realtime/agent-media-library.js +160 -0
- package/dist/realtime/agent-media-library.js.map +1 -0
- package/dist/realtime/client-context-channel-server.d.ts +59 -0
- package/dist/realtime/client-context-channel-server.d.ts.map +1 -0
- package/dist/realtime/client-context-channel-server.js +78 -0
- package/dist/realtime/client-context-channel-server.js.map +1 -0
- package/dist/realtime/media-channel-server.d.ts +73 -0
- package/dist/realtime/media-channel-server.d.ts.map +1 -0
- package/dist/realtime/media-channel-server.js +145 -0
- package/dist/realtime/media-channel-server.js.map +1 -0
- package/dist/realtime/realtime-channel-server-data-context.d.ts +42 -0
- package/dist/realtime/realtime-channel-server-data-context.d.ts.map +1 -0
- package/dist/realtime/realtime-channel-server-data-context.js +29 -0
- package/dist/realtime/realtime-channel-server-data-context.js.map +1 -0
- package/dist/realtime/realtime-channel-server-host.d.ts.map +1 -1
- package/dist/realtime/realtime-channel-server-host.js +8 -2
- package/dist/realtime/realtime-channel-server-host.js.map +1 -1
- package/dist/realtime/realtime-client-session-service.d.ts +114 -6
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
- package/dist/realtime/realtime-client-session-service.js +289 -30
- package/dist/realtime/realtime-client-session-service.js.map +1 -1
- package/dist/realtime/realtime-coagent-config.d.ts +82 -3
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
- package/dist/realtime/realtime-coagent-config.js +147 -6
- package/dist/realtime/realtime-coagent-config.js.map +1 -1
- package/dist/realtime/realtime-recording-capture.d.ts +125 -0
- package/dist/realtime/realtime-recording-capture.d.ts.map +1 -0
- package/dist/realtime/realtime-recording-capture.js +317 -0
- package/dist/realtime/realtime-recording-capture.js.map +1 -0
- package/dist/realtime/realtime-recording-store.d.ts +105 -0
- package/dist/realtime/realtime-recording-store.d.ts.map +1 -0
- package/dist/realtime/realtime-recording-store.js +216 -0
- package/dist/realtime/realtime-recording-store.js.map +1 -0
- package/dist/realtime/realtime-session-runner.d.ts +33 -2
- package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
- package/dist/realtime/realtime-session-runner.js +45 -2
- package/dist/realtime/realtime-session-runner.js.map +1 -1
- package/dist/realtime/realtime-tool-broker.d.ts +41 -3
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
- package/dist/realtime/realtime-tool-broker.js +67 -3
- package/dist/realtime/realtime-tool-broker.js.map +1 -1
- package/package.json +18 -17
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Orchestrates SKILL.md export/import against the database: resolves Action/Agent
|
|
3
|
+
* names to IDs (import) and IDs back to names (export), and creates/updates the MJ: AI Skills +
|
|
4
|
+
* junction entities. Builds on the pure {@link SkillMarkdownConverter} for the text<->data
|
|
5
|
+
* transformation itself.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/ai-agents
|
|
8
|
+
*/
|
|
9
|
+
import { IMetadataProvider, UserInfo } from '@memberjunction/core';
|
|
10
|
+
import { MJAISkillEntity } from '@memberjunction/core-entities';
|
|
11
|
+
/**
|
|
12
|
+
* Options for {@link SkillImportExportService.ImportSkill}.
|
|
13
|
+
*/
|
|
14
|
+
export interface ImportSkillOptions {
|
|
15
|
+
/**
|
|
16
|
+
* When provided, updates this existing skill (and resyncs its Action/sub-agent bundling)
|
|
17
|
+
* instead of creating a new one. The caller is responsible for confirming the current user is
|
|
18
|
+
* allowed to edit this skill (e.g. it's their own, per the "own skills" RLS filter).
|
|
19
|
+
*/
|
|
20
|
+
updateSkillId?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Result of {@link SkillImportExportService.ImportSkill}.
|
|
24
|
+
*/
|
|
25
|
+
export interface ImportSkillResult {
|
|
26
|
+
skill: MJAISkillEntity;
|
|
27
|
+
/** Action/sub-agent names from the SKILL.md that couldn't be resolved — the skill is still
|
|
28
|
+
* created/updated with whatever DID resolve, so the caller can surface these as non-fatal
|
|
29
|
+
* warnings rather than failing the whole import. */
|
|
30
|
+
warnings: string[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Result of {@link SkillImportExportService.ExportSkill}.
|
|
34
|
+
*/
|
|
35
|
+
export interface ExportSkillResult {
|
|
36
|
+
markdown: string;
|
|
37
|
+
/** The skill's Name — returned alongside the markdown so callers don't need a second load. */
|
|
38
|
+
skillName: string;
|
|
39
|
+
}
|
|
40
|
+
export declare class SkillImportExportService {
|
|
41
|
+
/**
|
|
42
|
+
* Exports a skill to a portable SKILL.md string: Action/sub-agent IDs are resolved to their
|
|
43
|
+
* current Names (not IDs, for cross-instance portability) via the AI/Action engine caches.
|
|
44
|
+
*/
|
|
45
|
+
static ExportSkill(skillId: string, contextUser: UserInfo, provider?: IMetadataProvider): Promise<ExportSkillResult>;
|
|
46
|
+
/**
|
|
47
|
+
* Imports a SKILL.md document, resolving Action/sub-agent names against the current instance's
|
|
48
|
+
* catalog (unresolvable names are dropped and reported as warnings, not fatal errors — a skill
|
|
49
|
+
* authored against a different MJ instance may reference actions that don't exist here yet).
|
|
50
|
+
*/
|
|
51
|
+
static ImportSkill(markdownText: string, contextUser: UserInfo, options?: ImportSkillOptions, provider?: IMetadataProvider): Promise<ImportSkillResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Loads the AI + Action engine caches that name/ID resolution depends on. Both `Config()` calls
|
|
54
|
+
* are idempotent — a no-op when the engine is already loaded (the common server case) — so this
|
|
55
|
+
* is cheap insurance against a cold caller producing empty resolutions.
|
|
56
|
+
*/
|
|
57
|
+
private static ensureEnginesConfigured;
|
|
58
|
+
/** Resolves a list of names against a cached entity array (by ID+Name), collecting a warning for each miss. */
|
|
59
|
+
private static resolveNames;
|
|
60
|
+
/** Deletes existing junction rows for the skill and recreates them from the resolved ID set — the simplest correct resync for a small bounded set of rows. */
|
|
61
|
+
private static resyncJunction;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=SkillImportExportService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillImportExportService.d.ts","sourceRoot":"","sources":["../src/SkillImportExportService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,iBAAiB,EAAqB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEtF,OAAO,EAAE,eAAe,EAAkD,MAAM,+BAA+B,CAAC;AAKhH;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,KAAK,EAAE,eAAe,CAAC;IACvB;;yDAEqD;IACrD,QAAQ,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,8FAA8F;IAC9F,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,wBAAwB;IACjC;;;OAGG;WACiB,WAAW,CAC3B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,QAAQ,EACrB,QAAQ,CAAC,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IA6C7B;;;;OAIG;WACiB,WAAW,CAC3B,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,QAAQ,EACrB,OAAO,CAAC,EAAE,kBAAkB,EAC5B,QAAQ,CAAC,EAAE,iBAAiB,GAC7B,OAAO,CAAC,iBAAiB,CAAC;IAiD7B;;;;OAIG;mBACkB,uBAAuB;IAK5C,+GAA+G;IAC/G,OAAO,CAAC,MAAM,CAAC,YAAY;IAkB3B,8JAA8J;mBACzI,cAAc;CAmCtC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Orchestrates SKILL.md export/import against the database: resolves Action/Agent
|
|
3
|
+
* names to IDs (import) and IDs back to names (export), and creates/updates the MJ: AI Skills +
|
|
4
|
+
* junction entities. Builds on the pure {@link SkillMarkdownConverter} for the text<->data
|
|
5
|
+
* transformation itself.
|
|
6
|
+
*
|
|
7
|
+
* @module @memberjunction/ai-agents
|
|
8
|
+
*/
|
|
9
|
+
import { Metadata, RunView } from '@memberjunction/core';
|
|
10
|
+
import { UUIDsEqual } from '@memberjunction/global';
|
|
11
|
+
import { AIEngine } from '@memberjunction/aiengine';
|
|
12
|
+
import { ActionEngineServer } from '@memberjunction/actions';
|
|
13
|
+
import { SkillMarkdownConverter } from './SkillMarkdownConverter.js';
|
|
14
|
+
export class SkillImportExportService {
|
|
15
|
+
/**
|
|
16
|
+
* Exports a skill to a portable SKILL.md string: Action/sub-agent IDs are resolved to their
|
|
17
|
+
* current Names (not IDs, for cross-instance portability) via the AI/Action engine caches.
|
|
18
|
+
*/
|
|
19
|
+
static async ExportSkill(skillId, contextUser, provider) {
|
|
20
|
+
const md = provider ?? Metadata.Provider;
|
|
21
|
+
// Name resolution below reads the AI/Action engine caches — ensure they're loaded (idempotent
|
|
22
|
+
// no-op when already configured). Without this, a cold caller resolves every ID to no name.
|
|
23
|
+
await this.ensureEnginesConfigured(contextUser, md);
|
|
24
|
+
const skill = await md.GetEntityObject('MJ: AI Skills', contextUser);
|
|
25
|
+
const loaded = await skill.Load(skillId);
|
|
26
|
+
if (!loaded) {
|
|
27
|
+
throw new Error(`Skill ${skillId} not found`);
|
|
28
|
+
}
|
|
29
|
+
const rv = new RunView();
|
|
30
|
+
const [actionRows, subAgentRows] = await rv.RunViews([
|
|
31
|
+
{
|
|
32
|
+
EntityName: 'MJ: AI Skill Actions',
|
|
33
|
+
ExtraFilter: `SkillID='${skillId}'`,
|
|
34
|
+
ResultType: 'simple'
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
EntityName: 'MJ: AI Skill Sub Agents',
|
|
38
|
+
ExtraFilter: `SkillID='${skillId}'`,
|
|
39
|
+
ResultType: 'simple'
|
|
40
|
+
}
|
|
41
|
+
], contextUser);
|
|
42
|
+
const actionNames = (actionRows.Success ? actionRows.Results : [])
|
|
43
|
+
.map(row => ActionEngineServer.Instance.Actions.find(a => UUIDsEqual(a.ID, row.ActionID))?.Name)
|
|
44
|
+
.filter((name) => !!name);
|
|
45
|
+
const subAgentNames = (subAgentRows.Success ? subAgentRows.Results : [])
|
|
46
|
+
.map(row => AIEngine.Instance.Agents.find(a => UUIDsEqual(a.ID, row.SubAgentID))?.Name)
|
|
47
|
+
.filter((name) => !!name);
|
|
48
|
+
const markdown = SkillMarkdownConverter.Serialize({
|
|
49
|
+
name: skill.Name,
|
|
50
|
+
description: skill.Description ?? undefined,
|
|
51
|
+
category: skill.Category ?? undefined,
|
|
52
|
+
actionNames,
|
|
53
|
+
subAgentNames,
|
|
54
|
+
instructions: skill.Instructions
|
|
55
|
+
});
|
|
56
|
+
return { markdown, skillName: skill.Name };
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Imports a SKILL.md document, resolving Action/sub-agent names against the current instance's
|
|
60
|
+
* catalog (unresolvable names are dropped and reported as warnings, not fatal errors — a skill
|
|
61
|
+
* authored against a different MJ instance may reference actions that don't exist here yet).
|
|
62
|
+
*/
|
|
63
|
+
static async ImportSkill(markdownText, contextUser, options, provider) {
|
|
64
|
+
const parsed = SkillMarkdownConverter.Parse(markdownText);
|
|
65
|
+
const warnings = [];
|
|
66
|
+
const md = provider ?? Metadata.Provider;
|
|
67
|
+
// Name→ID resolution below reads the AI/Action engine caches — ensure they're loaded
|
|
68
|
+
// (idempotent). Without this, every bundled Action/sub-agent name would falsely resolve to a
|
|
69
|
+
// "not found" warning on a cold server.
|
|
70
|
+
await this.ensureEnginesConfigured(contextUser, md);
|
|
71
|
+
const resolvedActionIDs = this.resolveNames(parsed.frontmatter.actions ?? [], ActionEngineServer.Instance.Actions, warnings, 'Action');
|
|
72
|
+
const resolvedSubAgentIDs = this.resolveNames(parsed.frontmatter.subAgents ?? [], AIEngine.Instance.Agents, warnings, 'Sub-agent');
|
|
73
|
+
const skill = await md.GetEntityObject('MJ: AI Skills', contextUser);
|
|
74
|
+
if (options?.updateSkillId) {
|
|
75
|
+
const loaded = await skill.Load(options.updateSkillId);
|
|
76
|
+
if (!loaded) {
|
|
77
|
+
throw new Error(`Skill ${options.updateSkillId} not found for update`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
skill.NewRecord();
|
|
82
|
+
skill.CreatedByUserID = contextUser.ID;
|
|
83
|
+
skill.Status = 'Active';
|
|
84
|
+
}
|
|
85
|
+
skill.Name = parsed.frontmatter.name;
|
|
86
|
+
skill.Description = parsed.frontmatter.description ?? null;
|
|
87
|
+
skill.Category = parsed.frontmatter.category ?? null;
|
|
88
|
+
skill.Instructions = parsed.instructions;
|
|
89
|
+
const saved = await skill.Save();
|
|
90
|
+
if (!saved) {
|
|
91
|
+
throw new Error(`Failed to save imported skill: ${skill.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
92
|
+
}
|
|
93
|
+
await this.resyncJunction(skill.ID, 'MJ: AI Skill Actions', resolvedActionIDs, 'ActionID', contextUser, md);
|
|
94
|
+
await this.resyncJunction(skill.ID, 'MJ: AI Skill Sub Agents', resolvedSubAgentIDs, 'SubAgentID', contextUser, md);
|
|
95
|
+
return { skill, warnings };
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Loads the AI + Action engine caches that name/ID resolution depends on. Both `Config()` calls
|
|
99
|
+
* are idempotent — a no-op when the engine is already loaded (the common server case) — so this
|
|
100
|
+
* is cheap insurance against a cold caller producing empty resolutions.
|
|
101
|
+
*/
|
|
102
|
+
static async ensureEnginesConfigured(contextUser, provider) {
|
|
103
|
+
await AIEngine.Instance.Config(false, contextUser, provider);
|
|
104
|
+
await ActionEngineServer.Instance.Config(false, contextUser, provider);
|
|
105
|
+
}
|
|
106
|
+
/** Resolves a list of names against a cached entity array (by ID+Name), collecting a warning for each miss. */
|
|
107
|
+
static resolveNames(names, catalog, warnings, kindLabel) {
|
|
108
|
+
const resolved = [];
|
|
109
|
+
for (const name of names) {
|
|
110
|
+
const match = catalog.find(c => c.Name.trim().toLowerCase() === name.trim().toLowerCase());
|
|
111
|
+
if (match) {
|
|
112
|
+
resolved.push(match.ID);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
warnings.push(`${kindLabel} '${name}' not found in this instance — skipped`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return resolved;
|
|
119
|
+
}
|
|
120
|
+
/** Deletes existing junction rows for the skill and recreates them from the resolved ID set — the simplest correct resync for a small bounded set of rows. */
|
|
121
|
+
static async resyncJunction(skillId, entityName, resolvedIDs, idFieldName, contextUser, provider) {
|
|
122
|
+
const rv = new RunView();
|
|
123
|
+
const existing = await rv.RunView({
|
|
124
|
+
EntityName: entityName,
|
|
125
|
+
ExtraFilter: `SkillID='${skillId}'`,
|
|
126
|
+
ResultType: 'entity_object'
|
|
127
|
+
}, contextUser);
|
|
128
|
+
if (existing.Success) {
|
|
129
|
+
for (const row of existing.Results) {
|
|
130
|
+
const deleted = await row.Delete();
|
|
131
|
+
if (!deleted) {
|
|
132
|
+
throw new Error(`Failed to remove existing ${entityName} row during skill re-sync: ${row.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
for (const id of resolvedIDs) {
|
|
137
|
+
const junctionRow = await provider.GetEntityObject(entityName, contextUser);
|
|
138
|
+
junctionRow.NewRecord();
|
|
139
|
+
junctionRow.SkillID = skillId;
|
|
140
|
+
junctionRow[idFieldName] = id;
|
|
141
|
+
const saved = await junctionRow.Save();
|
|
142
|
+
if (!saved) {
|
|
143
|
+
throw new Error(`Failed to create ${entityName} row during skill re-sync: ${junctionRow.LatestResult?.CompleteMessage ?? 'unknown error'}`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# sourceMappingURL=SkillImportExportService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillImportExportService.js","sourceRoot":"","sources":["../src/SkillImportExportService.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAqB,QAAQ,EAAE,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACtF,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAkClE,MAAM,OAAO,wBAAwB;IACjC;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,WAAW,CAC3B,OAAe,EACf,WAAqB,EACrB,QAA4B;QAE5B,MAAM,EAAE,GAAG,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC;QACzC,8FAA8F;QAC9F,4FAA4F;QAC5F,MAAM,IAAI,CAAC,uBAAuB,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,eAAe,CAAkB,eAAe,EAAE,WAAW,CAAC,CAAC;QACtF,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzC,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CA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,QAAQ,CAAC,OAAO,EAAE,CAAC;gBACjC,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,CAAC;gBACnC,IAAI,CAAC,OAAO,EAAE,CAAC;oBACX,MAAM,IAAI,KAAK,CAAC,6BAA6B,UAAU,8BAA8B,GAAG,CAAC,YAAY,EAAE,eAAe,IAAI,eAAe,EAAE,CAAC,CAAC;gBACjJ,CAAC;YACL,CAAC;QACL,CAAC;QAED,KAAK,MAAM,EAAE,IAAI,WAAW,EAAE,CAAC;YAC3B,MAAM,WAAW,GAAG,MAAM,QAAQ,CAAC,eAAe,CAAkD,UAAU,EAAE,WAAW,CAAC,CAAC;YAC7H,WAAW,CAAC,SAAS,EAAE,CAAC;YACxB,WAAW,CAAC,OAAO,GAAG,OAAO,CAAC;YAC7B,WAAiD,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;YACrE,MAAM,KAAK,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YACvC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACT,MAAM,IAAI,KAAK,CAAC,oBAAoB,UAAU,8BAA8B,WAAW,CAAC,YAAY,EAAE,eAAe,IAAI,eAAe,EAAE,CAAC,CAAC;YAChJ,CAAC;QACL,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pure parse/serialize for the portable SKILL.md format — no database or engine
|
|
3
|
+
* dependency, so this is fully unit-testable in isolation. `SkillImportExportService` builds on
|
|
4
|
+
* top of this to do the actual name<->ID resolution and entity persistence.
|
|
5
|
+
*
|
|
6
|
+
* ## Format
|
|
7
|
+
* ```markdown
|
|
8
|
+
* ---
|
|
9
|
+
* name: Report Builder
|
|
10
|
+
* description: Generates formatted business reports from query results
|
|
11
|
+
* category: Reporting
|
|
12
|
+
* actions:
|
|
13
|
+
* - Run Query
|
|
14
|
+
* - Generate PDF
|
|
15
|
+
* subAgents:
|
|
16
|
+
* - Report Formatter Agent
|
|
17
|
+
* ---
|
|
18
|
+
*
|
|
19
|
+
* Instructions body — plain markdown, appended to an accepting agent's system
|
|
20
|
+
* prompt when the skill is activated.
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Deliberately NOT a general-purpose YAML parser — the frontmatter shape is fixed and small
|
|
24
|
+
* (flat scalar keys + simple string-list keys), so a hand-rolled parser avoids taking on a new
|
|
25
|
+
* dependency for a narrow, fully-controlled need.
|
|
26
|
+
*
|
|
27
|
+
* @module @memberjunction/ai-agents
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* The frontmatter fields of a SKILL.md file. `actions`/`subAgents` are Action/Agent NAMES (not
|
|
31
|
+
* IDs) — portability across MJ instances means names are the only stable cross-instance
|
|
32
|
+
* reference; ID resolution happens at import time via {@link SkillImportExportService}.
|
|
33
|
+
*/
|
|
34
|
+
export interface SkillMarkdownFrontmatter {
|
|
35
|
+
name: string;
|
|
36
|
+
description?: string;
|
|
37
|
+
category?: string;
|
|
38
|
+
actions?: string[];
|
|
39
|
+
subAgents?: string[];
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Result of parsing a SKILL.md file: the frontmatter fields plus the Instructions body.
|
|
43
|
+
*/
|
|
44
|
+
export interface ParsedSkillMarkdown {
|
|
45
|
+
frontmatter: SkillMarkdownFrontmatter;
|
|
46
|
+
instructions: string;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Inputs to {@link SkillMarkdownConverter.Serialize} — the export-side counterpart of
|
|
50
|
+
* {@link ParsedSkillMarkdown}, using resolved names (not IDs) for portability.
|
|
51
|
+
*/
|
|
52
|
+
export interface SerializeSkillMarkdownParams {
|
|
53
|
+
name: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
category?: string;
|
|
56
|
+
actionNames?: string[];
|
|
57
|
+
subAgentNames?: string[];
|
|
58
|
+
instructions: string;
|
|
59
|
+
}
|
|
60
|
+
export declare class SkillMarkdownConverter {
|
|
61
|
+
/**
|
|
62
|
+
* Parses a SKILL.md document into its frontmatter + instructions body. Throws with a clear
|
|
63
|
+
* message on malformed input (missing/unterminated frontmatter block, missing required `name`).
|
|
64
|
+
*/
|
|
65
|
+
static Parse(markdownText: string): ParsedSkillMarkdown;
|
|
66
|
+
/**
|
|
67
|
+
* Serializes skill data into a SKILL.md document. The inverse of {@link Parse}.
|
|
68
|
+
*/
|
|
69
|
+
static Serialize(params: SerializeSkillMarkdownParams): string;
|
|
70
|
+
/**
|
|
71
|
+
* Parses the frontmatter line block into a {@link SkillMarkdownFrontmatter}. Supports flat
|
|
72
|
+
* `key: value` scalars and `key:` followed by ` - item` list entries — nothing more complex
|
|
73
|
+
* (no nested objects, no multiline scalars). Unknown keys are ignored rather than erroring, so
|
|
74
|
+
* a future field addition doesn't break parsing of older SKILL.md files.
|
|
75
|
+
*/
|
|
76
|
+
private static parseFrontmatterLines;
|
|
77
|
+
/** Quotes a scalar value if it contains a colon or leading/trailing whitespace that would otherwise break the simple parser. */
|
|
78
|
+
private static escapeScalar;
|
|
79
|
+
/** Strips the quoting {@link escapeScalar} applies, if present. */
|
|
80
|
+
private static unescapeScalar;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=SkillMarkdownConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillMarkdownConverter.d.ts","sourceRoot":"","sources":["../src/SkillMarkdownConverter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,WAAW,EAAE,wBAAwB,CAAC;IACtC,YAAY,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,4BAA4B;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;CACxB;AAID,qBAAa,sBAAsB;IAC/B;;;OAGG;WACW,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,mBAAmB;IA2B9D;;OAEG;WACW,SAAS,CAAC,MAAM,EAAE,4BAA4B,GAAG,MAAM;IA6BrE;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IA6CpC,gIAAgI;IAChI,OAAO,CAAC,MAAM,CAAC,YAAY;IAO3B,mEAAmE;IACnE,OAAO,CAAC,MAAM,CAAC,cAAc;CAOhC"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Pure parse/serialize for the portable SKILL.md format — no database or engine
|
|
3
|
+
* dependency, so this is fully unit-testable in isolation. `SkillImportExportService` builds on
|
|
4
|
+
* top of this to do the actual name<->ID resolution and entity persistence.
|
|
5
|
+
*
|
|
6
|
+
* ## Format
|
|
7
|
+
* ```markdown
|
|
8
|
+
* ---
|
|
9
|
+
* name: Report Builder
|
|
10
|
+
* description: Generates formatted business reports from query results
|
|
11
|
+
* category: Reporting
|
|
12
|
+
* actions:
|
|
13
|
+
* - Run Query
|
|
14
|
+
* - Generate PDF
|
|
15
|
+
* subAgents:
|
|
16
|
+
* - Report Formatter Agent
|
|
17
|
+
* ---
|
|
18
|
+
*
|
|
19
|
+
* Instructions body — plain markdown, appended to an accepting agent's system
|
|
20
|
+
* prompt when the skill is activated.
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Deliberately NOT a general-purpose YAML parser — the frontmatter shape is fixed and small
|
|
24
|
+
* (flat scalar keys + simple string-list keys), so a hand-rolled parser avoids taking on a new
|
|
25
|
+
* dependency for a narrow, fully-controlled need.
|
|
26
|
+
*
|
|
27
|
+
* @module @memberjunction/ai-agents
|
|
28
|
+
*/
|
|
29
|
+
const FRONTMATTER_DELIMITER = '---';
|
|
30
|
+
export class SkillMarkdownConverter {
|
|
31
|
+
/**
|
|
32
|
+
* Parses a SKILL.md document into its frontmatter + instructions body. Throws with a clear
|
|
33
|
+
* message on malformed input (missing/unterminated frontmatter block, missing required `name`).
|
|
34
|
+
*/
|
|
35
|
+
static Parse(markdownText) {
|
|
36
|
+
const normalized = markdownText.replace(/\r\n/g, '\n').trim();
|
|
37
|
+
const lines = normalized.split('\n');
|
|
38
|
+
if (lines[0]?.trim() !== FRONTMATTER_DELIMITER) {
|
|
39
|
+
throw new Error('Invalid SKILL.md: expected a frontmatter block starting with "---"');
|
|
40
|
+
}
|
|
41
|
+
const closingIndex = lines.findIndex((line, idx) => idx > 0 && line.trim() === FRONTMATTER_DELIMITER);
|
|
42
|
+
if (closingIndex === -1) {
|
|
43
|
+
throw new Error('Invalid SKILL.md: frontmatter block is not terminated with a closing "---"');
|
|
44
|
+
}
|
|
45
|
+
const frontmatterLines = lines.slice(1, closingIndex);
|
|
46
|
+
const instructions = lines.slice(closingIndex + 1).join('\n').trim();
|
|
47
|
+
const frontmatter = this.parseFrontmatterLines(frontmatterLines);
|
|
48
|
+
if (!frontmatter.name || frontmatter.name.trim().length === 0) {
|
|
49
|
+
throw new Error('Invalid SKILL.md: frontmatter is missing the required "name" field');
|
|
50
|
+
}
|
|
51
|
+
if (!instructions) {
|
|
52
|
+
throw new Error('Invalid SKILL.md: the Instructions body (after the frontmatter block) is empty');
|
|
53
|
+
}
|
|
54
|
+
return { frontmatter, instructions };
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Serializes skill data into a SKILL.md document. The inverse of {@link Parse}.
|
|
58
|
+
*/
|
|
59
|
+
static Serialize(params) {
|
|
60
|
+
const lines = [FRONTMATTER_DELIMITER];
|
|
61
|
+
lines.push(`name: ${this.escapeScalar(params.name)}`);
|
|
62
|
+
if (params.description) {
|
|
63
|
+
lines.push(`description: ${this.escapeScalar(params.description)}`);
|
|
64
|
+
}
|
|
65
|
+
if (params.category) {
|
|
66
|
+
lines.push(`category: ${this.escapeScalar(params.category)}`);
|
|
67
|
+
}
|
|
68
|
+
if (params.actionNames && params.actionNames.length > 0) {
|
|
69
|
+
lines.push('actions:');
|
|
70
|
+
for (const name of params.actionNames) {
|
|
71
|
+
lines.push(` - ${this.escapeScalar(name)}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
if (params.subAgentNames && params.subAgentNames.length > 0) {
|
|
75
|
+
lines.push('subAgents:');
|
|
76
|
+
for (const name of params.subAgentNames) {
|
|
77
|
+
lines.push(` - ${this.escapeScalar(name)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
lines.push(FRONTMATTER_DELIMITER);
|
|
81
|
+
lines.push('');
|
|
82
|
+
lines.push(params.instructions.trim());
|
|
83
|
+
lines.push('');
|
|
84
|
+
return lines.join('\n');
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Parses the frontmatter line block into a {@link SkillMarkdownFrontmatter}. Supports flat
|
|
88
|
+
* `key: value` scalars and `key:` followed by ` - item` list entries — nothing more complex
|
|
89
|
+
* (no nested objects, no multiline scalars). Unknown keys are ignored rather than erroring, so
|
|
90
|
+
* a future field addition doesn't break parsing of older SKILL.md files.
|
|
91
|
+
*/
|
|
92
|
+
static parseFrontmatterLines(lines) {
|
|
93
|
+
const result = { name: '' };
|
|
94
|
+
let currentListKey = null;
|
|
95
|
+
for (const rawLine of lines) {
|
|
96
|
+
if (rawLine.trim().length === 0) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const listItemMatch = rawLine.match(/^\s*-\s+(.*)$/);
|
|
100
|
+
if (listItemMatch && currentListKey) {
|
|
101
|
+
const value = this.unescapeScalar(listItemMatch[1]);
|
|
102
|
+
(result[currentListKey] ??= []).push(value);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
const keyValueMatch = rawLine.match(/^([A-Za-z][A-Za-z0-9_]*)\s*:\s*(.*)$/);
|
|
106
|
+
if (!keyValueMatch) {
|
|
107
|
+
throw new Error(`Invalid SKILL.md frontmatter line: "${rawLine}"`);
|
|
108
|
+
}
|
|
109
|
+
const [, key, rawValue] = keyValueMatch;
|
|
110
|
+
const value = rawValue.trim();
|
|
111
|
+
if (key === 'actions' || key === 'subAgents') {
|
|
112
|
+
currentListKey = key;
|
|
113
|
+
if (value.length > 0) {
|
|
114
|
+
// Inline list form, e.g. "actions: [Run Query, Generate PDF]" — split on commas.
|
|
115
|
+
const inline = value.replace(/^\[/, '').replace(/\]$/, '');
|
|
116
|
+
result[key] = inline.split(',').map(s => this.unescapeScalar(s.trim())).filter(s => s.length > 0);
|
|
117
|
+
currentListKey = null;
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
currentListKey = null;
|
|
122
|
+
if (key === 'name' || key === 'description' || key === 'category') {
|
|
123
|
+
result[key] = this.unescapeScalar(value);
|
|
124
|
+
}
|
|
125
|
+
// Unknown scalar keys are silently ignored (forward-compatibility).
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
/** Quotes a scalar value if it contains a colon or leading/trailing whitespace that would otherwise break the simple parser. */
|
|
130
|
+
static escapeScalar(value) {
|
|
131
|
+
if (/^\s|\s$|:/.test(value)) {
|
|
132
|
+
return `"${value.replace(/"/g, '\\"')}"`;
|
|
133
|
+
}
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
/** Strips the quoting {@link escapeScalar} applies, if present. */
|
|
137
|
+
static unescapeScalar(value) {
|
|
138
|
+
const trimmed = value.trim();
|
|
139
|
+
if (trimmed.startsWith('"') && trimmed.endsWith('"') && trimmed.length >= 2) {
|
|
140
|
+
return trimmed.slice(1, -1).replace(/\\"/g, '"');
|
|
141
|
+
}
|
|
142
|
+
return trimmed;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=SkillMarkdownConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SkillMarkdownConverter.js","sourceRoot":"","sources":["../src/SkillMarkdownConverter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAoCH,MAAM,qBAAqB,GAAG,KAAK,CAAC;AAEpC,MAAM,OAAO,sBAAsB;IAC/B;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,YAAoB;QACpC,MAAM,UAAU,GAAG,YAAY,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAErC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,qBAAqB,EAAE,CAAC;YAC7C,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;QAC1F,CAAC;QAED,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,qBAAqB,CAAC,CAAC;QACtG,IAAI,YAAY,KAAK,CAAC,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;QAClG,CAAC;QAED,MAAM,gBAAgB,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QACtD,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,IA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MAAM,CAAC,YAAY,CAAC,KAAa;QACrC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1B,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC;QAC7C,CAAC;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;IAED,mEAAmE;IAC3D,MAAM,CAAC,cAAc,CAAC,KAAa;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAC7B,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;YAC1E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,OAAO,CAAC;IACnB,CAAC;CACJ"}
|
|
@@ -73,9 +73,9 @@ export interface LoopAgentResponse<P = any> {
|
|
|
73
73
|
*/
|
|
74
74
|
nextStep?: {
|
|
75
75
|
/**
|
|
76
|
-
* Operation type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline'
|
|
76
|
+
* Operation type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill'
|
|
77
77
|
*/
|
|
78
|
-
type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline';
|
|
78
|
+
type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill' | 'Plan';
|
|
79
79
|
/**
|
|
80
80
|
* Actions to execute (when type='Actions')
|
|
81
81
|
*/
|
|
@@ -152,6 +152,27 @@ export interface LoopAgentResponse<P = any> {
|
|
|
152
152
|
* While operation details (when type='While')
|
|
153
153
|
*/
|
|
154
154
|
while?: WhileOperation;
|
|
155
|
+
/**
|
|
156
|
+
* Skills to activate (when type='Skill'). Reference by catalog Name only — you only ever
|
|
157
|
+
* see name + description for skills you haven't activated yet (progressive disclosure).
|
|
158
|
+
* Activating a skill appends its full instructions to your context and enables its
|
|
159
|
+
* bundled Actions/sub-agents for the rest of this run. This is NOT a nested agent run.
|
|
160
|
+
*/
|
|
161
|
+
skills?: Array<{
|
|
162
|
+
name: string;
|
|
163
|
+
/**
|
|
164
|
+
* Brief (one sentence) rationale for why you are activating this skill — what the
|
|
165
|
+
* current task needs that the skill provides. Recorded in the run's audit trail
|
|
166
|
+
* (AIAgentRunStep.Skills) so humans can review why capabilities were expanded.
|
|
167
|
+
*/
|
|
168
|
+
reason?: string;
|
|
169
|
+
}>;
|
|
170
|
+
/**
|
|
171
|
+
* The proposed plan (when type='Plan', Plan Mode only). Presenting a plan pauses the run
|
|
172
|
+
* and asks the human to approve or edit it via a response-form card before you may execute
|
|
173
|
+
* any Actions or Sub-Agents. See the Plan Mode section for when this is required.
|
|
174
|
+
*/
|
|
175
|
+
plan?: string;
|
|
155
176
|
};
|
|
156
177
|
}
|
|
157
178
|
//# sourceMappingURL=loop-agent-response-type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-response-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAC1M,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,YAAY,EAAE,gBAAg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;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-response-type.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"loop-agent-response-type.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":";AA8MA,oEAAoE;AACpE,sDAAsD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAA6B,MAAM,8BAA8B,CAAC;AAEpL,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAIxE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,qBACa,aAAc,SAAQ,aAAa;IAC5C,OAAO,CAAC,UAAU,CAAiC;IAEtC,wBAAwB,CAAC,GAAG,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC;IAM3G;;;;;;;;;;;OAWG;IACU,iBAAiB,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,GAAG,EAC7C,YAAY,EAAE,iBAAiB,GAAG,IAAI,EACtC,MAAM,EAAE,kBAAkB,CAAC,GAAG,EAAE,CAAC,CAAC,EAClC,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,GAAG,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,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
|
|
|
242
242
|
}));
|
|
243
243
|
}
|
|
244
244
|
break;
|
|
245
|
+
case 'Skill':
|
|
246
|
+
if (!response.nextStep.skills || response.nextStep.skills.length === 0) {
|
|
247
|
+
retVal.step = 'Retry';
|
|
248
|
+
retVal.message = 'When nextStep.type == "Skill", 1 or more skills must be specified in nextStep.skills array';
|
|
249
|
+
retVal.errorMessage = 'Skills not specified for Skill type';
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
retVal.step = 'Skill';
|
|
253
|
+
retVal.skillActivations = response.nextStep.skills.map(skill => ({
|
|
254
|
+
name: skill.name,
|
|
255
|
+
...(skill.reason ? { reason: skill.reason } : {})
|
|
256
|
+
}));
|
|
257
|
+
}
|
|
258
|
+
break;
|
|
259
|
+
case 'Plan':
|
|
260
|
+
if (!response.nextStep.plan || response.nextStep.plan.trim().length === 0) {
|
|
261
|
+
retVal.step = 'Retry';
|
|
262
|
+
retVal.message = 'When nextStep.type == "Plan", nextStep.plan must contain the proposed plan text';
|
|
263
|
+
retVal.errorMessage = 'Plan text not specified for Plan type';
|
|
264
|
+
}
|
|
265
|
+
else {
|
|
266
|
+
retVal.step = 'Plan';
|
|
267
|
+
retVal.planDetails = { plan: response.nextStep.plan };
|
|
268
|
+
}
|
|
269
|
+
break;
|
|
245
270
|
case 'ForEach':
|
|
246
271
|
if (!response.nextStep.forEach) {
|
|
247
272
|
retVal.step = 'Retry';
|
|
@@ -356,7 +381,7 @@ let LoopAgentType = class LoopAgentType extends BaseAgentType {
|
|
|
356
381
|
}
|
|
357
382
|
// Validate nextStep structure if present
|
|
358
383
|
if (response.nextStep) {
|
|
359
|
-
const validStepTypes = ['actions', 'sub-agent', 'chat', 'retry', 'foreach', 'while', 'clienttools', 'pipeline'];
|
|
384
|
+
const validStepTypes = ['actions', 'sub-agent', 'chat', 'retry', 'foreach', 'while', 'clienttools', 'pipeline', 'skill', 'plan'];
|
|
360
385
|
let lcaseType = response.nextStep.type?.toLowerCase().trim();
|
|
361
386
|
// allow the AI to mess up the case, but we need to validate it
|
|
362
387
|
// be smart/lenient about missing types. if type is missing but we have a nextStep.subAgent/subAgents, default to sub-agent and if type is missing and we have nextStep.actions, default to actions
|
|
@@ -384,6 +409,14 @@ let LoopAgentType = class LoopAgentType extends BaseAgentType {
|
|
|
384
409
|
response.nextStep.type = 'Pipeline'; // update the data structure to have the correct type
|
|
385
410
|
lcaseType = 'pipeline';
|
|
386
411
|
}
|
|
412
|
+
else if (!lcaseType && response.nextStep.skills && response.nextStep.skills.length > 0) {
|
|
413
|
+
response.nextStep.type = 'Skill'; // update the data structure to have the correct type
|
|
414
|
+
lcaseType = 'skill';
|
|
415
|
+
}
|
|
416
|
+
else if (!lcaseType && response.nextStep.plan) {
|
|
417
|
+
response.nextStep.type = 'Plan'; // update the data structure to have the correct type
|
|
418
|
+
lcaseType = 'plan';
|
|
419
|
+
}
|
|
387
420
|
if (!validStepTypes.includes(lcaseType)) {
|
|
388
421
|
const message = `LoopAgentResponse has invalid nextStep.type: ${response.nextStep.type}`;
|
|
389
422
|
LogError(message);
|