@scout9/app 1.0.0-alpha.0.5.3 → 1.0.0-alpha.0.5.5
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/dist/{dev-be9ba80f.cjs → dev-0474d2a6.cjs} +99 -57
- package/dist/{index-11e312c6.cjs → index-81a32056.cjs} +56 -45
- package/dist/index.cjs +3 -3
- package/dist/{macros-57f9b28b.cjs → macros-ee7553f8.cjs} +13 -8
- package/dist/{multipart-parser-8a217889.cjs → multipart-parser-f24b1f9a.cjs} +3 -3
- package/dist/schemas.cjs +1 -1
- package/dist/testing-tools.cjs +2 -2
- package/package.json +1 -1
- package/src/core/config/agents.js +2 -3
- package/src/core/config/commands.js +38 -28
- package/src/core/config/entities.js +17 -9
- package/src/core/config/index.js +3 -2
- package/src/core/config/workflow.js +11 -5
- package/src/core/index.js +2 -3
- package/src/report.js +8 -2
- package/src/runtime/schemas/commands.js +10 -0
- package/src/runtime/schemas/config.js +2 -1
- package/src/runtime/schemas/conversation.js +41 -36
- package/src/runtime/schemas/index.js +5 -4
- package/src/runtime/schemas/users.js +1 -1
- package/src/runtime/schemas/workflow.js +0 -7
- package/src/testing-tools/dev.js +370 -364
- package/src/utils/configs/agents.js +2 -1
- package/src/utils/configs/entities.js +14 -4
- package/src/utils/configs/workflow.js +42 -35
- package/src/utils/project.js +4 -2
- package/types/index.d.ts +6645 -6568
- package/types/index.d.ts.map +31 -29
|
@@ -3,6 +3,7 @@ import colors from 'kleur';
|
|
|
3
3
|
import { globSync } from 'glob';
|
|
4
4
|
import { checkVariableType, requireProjectFile } from '../../utils/index.js';
|
|
5
5
|
import { AgentsConfigurationSchema, AgentsSchema } from '../../runtime/index.js';
|
|
6
|
+
import { logUserValidationError } from '../../report.js';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @param {Array<Agent>} agents
|
|
@@ -29,7 +30,7 @@ export function validateAgentConfig(agents) {
|
|
|
29
30
|
const result = AgentsSchema.safeParse(agents);
|
|
30
31
|
if (!result.success) {
|
|
31
32
|
result.error.source = `src/entities/agents.js|ts`;
|
|
32
|
-
throw result.error
|
|
33
|
+
throw logUserValidationError(result.error, `src/entities/agents.js|ts`)
|
|
33
34
|
}
|
|
34
35
|
return agents;
|
|
35
36
|
}
|
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
EntityRootProjectConfigurationSchema
|
|
8
8
|
} from '../../runtime/index.js';
|
|
9
9
|
import { checkVariableType, requireOptionalProjectFile, requireProjectFile } from '../module.js';
|
|
10
|
+
import { logUserValidationError } from '../../report.js';
|
|
11
|
+
import { simplifyError } from '../error.js';
|
|
10
12
|
|
|
11
13
|
async function loadEntityApiConfig(cwd, filePath) {
|
|
12
14
|
const dir = path.dirname(filePath);
|
|
@@ -86,7 +88,7 @@ export default async function loadEntitiesConfig(
|
|
|
86
88
|
const result = EntityConfigurationSchema.safeParse(entityConfig, {path: ['entities', config.length]});
|
|
87
89
|
if (!result.success) {
|
|
88
90
|
result.error.source = filePath;
|
|
89
|
-
throw result.error;
|
|
91
|
+
throw logUserValidationError(result.error, filePath);
|
|
90
92
|
}
|
|
91
93
|
} else if (isSpecial && (fileName === 'index' || fileName === 'config')) {
|
|
92
94
|
// If this is a special entity file, then ignore as we will capture it another method
|
|
@@ -100,7 +102,12 @@ export default async function loadEntitiesConfig(
|
|
|
100
102
|
entities: parents.reverse(),
|
|
101
103
|
api
|
|
102
104
|
};
|
|
103
|
-
|
|
105
|
+
|
|
106
|
+
try {
|
|
107
|
+
EntityRootProjectConfigurationSchema.parse(entityProjectConfig);
|
|
108
|
+
} catch (e) {
|
|
109
|
+
throw simplifyError(e);
|
|
110
|
+
}
|
|
104
111
|
const existingIndex = config.findIndex(c => c.entity === entityProjectConfig.entity);
|
|
105
112
|
if (existingIndex > -1) {
|
|
106
113
|
if (config[existingIndex].entities.length !== entityProjectConfig.entities.length) {
|
|
@@ -138,8 +145,11 @@ export default async function loadEntitiesConfig(
|
|
|
138
145
|
// }
|
|
139
146
|
|
|
140
147
|
// Validate the config
|
|
141
|
-
|
|
148
|
+
try {
|
|
149
|
+
return EntitiesRootProjectConfigurationSchema.parse(config);
|
|
150
|
+
} catch (e) {
|
|
151
|
+
throw simplifyError(e);
|
|
152
|
+
}
|
|
142
153
|
|
|
143
|
-
return config;
|
|
144
154
|
}
|
|
145
155
|
|
|
@@ -1,47 +1,54 @@
|
|
|
1
1
|
import { globSync } from 'glob';
|
|
2
2
|
import { WorkflowConfigurationSchema, WorkflowsConfigurationSchema } from '../../runtime/index.js';
|
|
3
|
+
import { simplifyError } from '../error.js';
|
|
4
|
+
import { logUserValidationError } from '../../report.js';
|
|
3
5
|
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
|
-
* @returns {Promise<
|
|
8
|
+
* @returns {Promise<WorkflowsConfigurationSchema>}
|
|
7
9
|
*/
|
|
8
10
|
export default async function loadWorkflowsConfig(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
{
|
|
12
|
+
cwd = process.cwd(),
|
|
13
|
+
src = 'src'
|
|
14
|
+
// cb = (message) => {}
|
|
15
|
+
} = {}
|
|
14
16
|
) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
// const config = globSync(path.resolve(cwd, `${src}/workflows/**/workflow.{ts,js}`), {cwd, absolute: true})
|
|
18
|
+
const config = globSync(`${src}/workflows/**/workflow.{ts,js}`, {cwd, absolute: true})
|
|
19
|
+
.map((path) => {
|
|
20
|
+
const segments = path.split('/');
|
|
21
|
+
const srcIndex = segments.findIndex((segment, index) => segment === src && segments[index + 1] === 'workflows');
|
|
22
|
+
const parents = segments.slice(srcIndex + 2, -1).reverse(); // +2 to skip "${src}" and "workflows"
|
|
23
|
+
return {path, parents};
|
|
24
|
+
})
|
|
25
|
+
.filter(path => {
|
|
26
|
+
if (path.parents.length > 0) {
|
|
27
|
+
return true;
|
|
28
|
+
} else {
|
|
29
|
+
console.log(`WARNING: "${path}" Is not a valid entity path, must be contained in a named src under workflows/`);
|
|
30
|
+
}
|
|
31
|
+
})
|
|
32
|
+
.map(({path, parents}) => {
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
// Validate project configuration
|
|
35
|
+
/** @type {WorkflowConfigurationSchema} */
|
|
36
|
+
const workflowConfig = {
|
|
37
|
+
entity: parents[0],
|
|
38
|
+
entities: parents.reverse()
|
|
39
|
+
};
|
|
40
|
+
try {
|
|
41
|
+
return WorkflowConfigurationSchema.parse(workflowConfig);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
throw logUserValidationError(e, path);
|
|
44
|
+
}
|
|
45
|
+
});
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
// Validate the config
|
|
48
|
+
try {
|
|
49
|
+
return WorkflowsConfigurationSchema.parse(config);
|
|
50
|
+
} catch (e) {
|
|
51
|
+
throw simplifyError(e);
|
|
52
|
+
}
|
|
42
53
|
|
|
43
|
-
// Validate the config
|
|
44
|
-
WorkflowsConfigurationSchema.parse(config);
|
|
45
|
-
|
|
46
|
-
return config;
|
|
47
54
|
}
|
package/src/utils/project.js
CHANGED
|
@@ -11,6 +11,7 @@ import loadWorkflowsConfig from './configs/workflow.js';
|
|
|
11
11
|
import { Scout9ProjectBuildConfigSchema } from '../runtime/index.js';
|
|
12
12
|
import { ProgressLogger } from './logger.js';
|
|
13
13
|
import { formatGlobPattern, normalizeGlobPattern } from './glob.js';
|
|
14
|
+
import { logUserValidationError } from '../report.js';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Utility class to load and write project files in a targeted way
|
|
@@ -278,7 +279,8 @@ export default class ProjectFiles {
|
|
|
278
279
|
...(await this._loadEnv()),
|
|
279
280
|
entities: [],
|
|
280
281
|
agents: [],
|
|
281
|
-
workflows: []
|
|
282
|
+
workflows: [],
|
|
283
|
+
commands: []
|
|
282
284
|
};
|
|
283
285
|
|
|
284
286
|
// Load entities, except for special entities such as ["agents"]
|
|
@@ -298,7 +300,7 @@ export default class ProjectFiles {
|
|
|
298
300
|
const result = Scout9ProjectBuildConfigSchema.safeParse(projectConfig);
|
|
299
301
|
if (!result.success) {
|
|
300
302
|
result.error.source = `${this.src}/index.js`;
|
|
301
|
-
throw result.error;
|
|
303
|
+
throw logUserValidationError(result.error, `${this.src}/index.js`);
|
|
302
304
|
}
|
|
303
305
|
|
|
304
306
|
// Log
|