@sowonai/crewx-sdk 0.1.0-dev.3 → 0.1.0-dev.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/index.d.ts CHANGED
@@ -24,3 +24,7 @@ export { RemoteAgentManager, FetchRemoteTransport, MockRemoteTransport, type Rem
24
24
  export type { RemoteAgentConfig, RemoteTransport, RemoteTransportRequestOptions, RemoteAgentQueryRequest, RemoteAgentExecuteRequest, RemoteAgentResponse, McpJsonRpcRequest, McpJsonRpcResponse, ToolNameMapping, RemoteAgentDescriptor, } from './core/remote';
25
25
  export { ParallelRunner, ParallelRunnerTimeoutError, createDefaultParallelRunner, runQueriesParallel, runExecutesParallel, } from './core/parallel';
26
26
  export type { ParallelRunnerMetrics, ParallelRunnerOptions, Task, TaskResult, TaskCallbacks, TaskExecutionContext, ParallelConfig, HelperResult, RetryPolicy, } from './core/parallel';
27
+ export { PropsValidator, type ValidationMode, } from './services/props-validator.service';
28
+ export type { PropSchema, ValidationResult as PropsValidationResult, ValidationError as PropsValidationDetail, } from './types/layout.types';
29
+ export { LayoutRenderer, PropsValidationError, type RenderOptions, } from './services/layout-renderer.service';
30
+ export type { RenderContext, LayoutDefinition, ValidationResult, ValidationError, } from './types/layout.types';
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runExecutesParallel = exports.runQueriesParallel = exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = exports.MockRemoteTransport = exports.FetchRemoteTransport = exports.RemoteAgentManager = exports.loadAgentConfigFromFile = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = exports.createStructuredPayload = exports.parseStructuredPayload = exports.isStructuredPayload = exports.DefaultMessageFormatter = exports.BaseMessageFormatter = exports.loadAvailableAgents = exports.MentionParser = exports.isError = exports.getErrorStack = exports.getErrorMessage = exports.SecurityLevel = exports.ExecutionMode = exports.CodexProvider = exports.CopilotProvider = exports.GeminiProvider = exports.ClaudeProvider = exports.BaseAIProvider = exports.ProviderNotAvailableError = exports.BuiltInProviders = exports.ProviderNamespace = exports.DocumentManager = exports.getConversationConfig = exports.DEFAULT_CONVERSATION_CONFIG = exports.getDefaultTimeoutConfig = exports.getTimeoutConfig = exports.DEFAULT_MAX_FILES = exports.DEFAULT_MAX_FILE_SIZE = exports.PREFIX_TOOL_NAME = exports.SERVER_NAME = void 0;
3
+ exports.PropsValidationError = exports.LayoutRenderer = exports.PropsValidator = exports.runExecutesParallel = exports.runQueriesParallel = exports.createDefaultParallelRunner = exports.ParallelRunnerTimeoutError = exports.ParallelRunner = exports.MockRemoteTransport = exports.FetchRemoteTransport = exports.RemoteAgentManager = exports.loadAgentConfigFromFile = exports.loadAgentConfigFromYaml = exports.createCrewxAgent = exports.createStructuredPayload = exports.parseStructuredPayload = exports.isStructuredPayload = exports.DefaultMessageFormatter = exports.BaseMessageFormatter = exports.loadAvailableAgents = exports.MentionParser = exports.isError = exports.getErrorStack = exports.getErrorMessage = exports.SecurityLevel = exports.ExecutionMode = exports.CodexProvider = exports.CopilotProvider = exports.GeminiProvider = exports.ClaudeProvider = exports.BaseAIProvider = exports.ProviderNotAvailableError = exports.BuiltInProviders = exports.ProviderNamespace = exports.DocumentManager = exports.getConversationConfig = exports.DEFAULT_CONVERSATION_CONFIG = exports.getDefaultTimeoutConfig = exports.getTimeoutConfig = exports.DEFAULT_MAX_FILES = exports.DEFAULT_MAX_FILE_SIZE = exports.PREFIX_TOOL_NAME = exports.SERVER_NAME = void 0;
4
4
  var constants_1 = require("./constants");
5
5
  Object.defineProperty(exports, "SERVER_NAME", { enumerable: true, get: function () { return constants_1.SERVER_NAME; } });
6
6
  Object.defineProperty(exports, "PREFIX_TOOL_NAME", { enumerable: true, get: function () { return constants_1.PREFIX_TOOL_NAME; } });
@@ -56,4 +56,9 @@ Object.defineProperty(exports, "ParallelRunnerTimeoutError", { enumerable: true,
56
56
  Object.defineProperty(exports, "createDefaultParallelRunner", { enumerable: true, get: function () { return parallel_1.createDefaultParallelRunner; } });
57
57
  Object.defineProperty(exports, "runQueriesParallel", { enumerable: true, get: function () { return parallel_1.runQueriesParallel; } });
58
58
  Object.defineProperty(exports, "runExecutesParallel", { enumerable: true, get: function () { return parallel_1.runExecutesParallel; } });
59
+ var props_validator_service_1 = require("./services/props-validator.service");
60
+ Object.defineProperty(exports, "PropsValidator", { enumerable: true, get: function () { return props_validator_service_1.PropsValidator; } });
61
+ var layout_renderer_service_1 = require("./services/layout-renderer.service");
62
+ Object.defineProperty(exports, "LayoutRenderer", { enumerable: true, get: function () { return layout_renderer_service_1.LayoutRenderer; } });
63
+ Object.defineProperty(exports, "PropsValidationError", { enumerable: true, get: function () { return layout_renderer_service_1.PropsValidationError; } });
59
64
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAMA,yCAKqB;AAJnB,wGAAA,WAAW,OAAA;AACX,6GAAA,gBAAgB,OAAA;AAChB,kHAAA,qBAAqB,OAAA;AACrB,8GAAA,iBAAiB,OAAA;AAKnB,0DAAoF;AAA3E,kHAAA,gBAAgB,OAAA;AAAE,yHAAA,uBAAuB,OAAA;AAUlD,0EAG4C;AAF1C,kIAAA,2BAA2B,OAAA;AAC3B,4HAAA,qBAAqB,OAAA;AAIvB,+DAA8D;AAArD,kHAAA,eAAe,OAAA;AAGxB,gFAIgD;AAH9C,0HAAA,iBAAiB,OAAA;AACjB,yHAAA,gBAAgB,OAAA;AAChB,kIAAA,yBAAyB,OAAA;AAQ3B,sEAAmE;AAA1D,kHAAA,cAAc,OAAA;AACvB,8CAK0B;AAJxB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,0GAAA,aAAa,OAAA;AAyBf,mDAAmE;AAA1D,4GAAA,aAAa,OAAA;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B,8CAK0B;AAJxB,2GAAA,cAAc,OAAA;AACd,2GAAA,cAAc,OAAA;AACd,4GAAA,eAAe,OAAA;AACf,0GAAA,aAAa,OAAA;AAyBf,mDAAmE;AAA1D,4GAAA,aAAa,OAAA;AAAE,4GAAA,aAAa,OAAA;AAGrC,mDAA8E;AAArE,8GAAA,eAAe,OAAA;AAAE,4GAAA,aAAa,OAAA;AAAE,sGAAA,OAAO,OAAA;AAChD,yDAKgC;AAJ9B,+GAAA,aAAa,OAAA;AACb,qHAAA,mBAAmB,OAAA;AAIrB,yEAKwC;AAJtC,8HAAA,oBAAoB,OAAA;AACpB,iIAAA,uBAAuB,OAAA;AAYzB,6EAI0C;AAHxC,+HAAA,mBAAmB,OAAA;AACnB,kIAAA,sBAAsB,OAAA;AACtB,mIAAA,uBAAuB,OAAA;AAIzB,sCASsB;AARpB,yGAAA,gBAAgB,OAAA;AAChB,gHAAA,uBAAuB,OAAA;AACvB,gHAAA,uBAAuB,OAAA;AAgBzB,wCAKuB;AAJrB,4GAAA,kBAAkB,OAAA;AAClB,8GAAA,oBAAoB,OAAA;AACpB,6GAAA,mBAAmB,OAAA;AAiBrB,4CAMyB;AALvB,0GAAA,cAAc,OAAA;AACd,sHAAA,0BAA0B,OAAA;AAC1B,uHAAA,2BAA2B,OAAA;AAC3B,8GAAA,kBAAkB,OAAA;AAClB,+GAAA,mBAAmB,OAAA;AAerB,8EAG4C;AAF1C,yHAAA,cAAc,OAAA;AAUhB,8EAI4C;AAH1C,yHAAA,cAAc,OAAA;AACd,+HAAA,oBAAoB,OAAA"}
@@ -0,0 +1,2 @@
1
+ export * from './layout-renderer.service';
2
+ export * from './props-validator.service';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./layout-renderer.service"), exports);
18
+ __exportStar(require("./props-validator.service"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAMA,4DAA0C;AAC1C,4DAA0C"}
@@ -0,0 +1,15 @@
1
+ import { LayoutDefinition, LoaderOptions } from '../types/layout.types';
2
+ export declare class LayoutLoader {
3
+ private layouts;
4
+ private options;
5
+ constructor(options?: Partial<LoaderOptions>);
6
+ load(layoutId: string, propsOverride?: Record<string, any>): LayoutDefinition;
7
+ getLayoutIds(): string[];
8
+ hasLayout(layoutId: string): boolean;
9
+ reload(): void;
10
+ private loadAllLayouts;
11
+ private loadLayoutFile;
12
+ private parsePropsSchema;
13
+ private extractDefaultProps;
14
+ private normalizeLayoutId;
15
+ }
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.LayoutLoader = void 0;
37
+ const fs_1 = require("fs");
38
+ const path = __importStar(require("path"));
39
+ const js_yaml_1 = require("js-yaml");
40
+ const layout_types_1 = require("../types/layout.types");
41
+ const DEFAULT_OPTIONS = {
42
+ templatesPath: path.join(__dirname, '../../../templates/agents'),
43
+ validationMode: 'lenient',
44
+ fallbackLayoutId: 'crewx/default',
45
+ };
46
+ class LayoutLoader {
47
+ constructor(options) {
48
+ this.layouts = new Map();
49
+ this.options = { ...DEFAULT_OPTIONS, ...options };
50
+ this.loadAllLayouts();
51
+ }
52
+ load(layoutId, propsOverride) {
53
+ const normalizedId = this.normalizeLayoutId(layoutId);
54
+ let layout = this.layouts.get(normalizedId);
55
+ if (!layout) {
56
+ console.warn(`Layout not found: ${normalizedId}, falling back to ${this.options.fallbackLayoutId}`);
57
+ layout = this.layouts.get(this.options.fallbackLayoutId);
58
+ if (!layout) {
59
+ throw new layout_types_1.LayoutLoadError(`Fallback layout not found: ${this.options.fallbackLayoutId}`, this.options.fallbackLayoutId);
60
+ }
61
+ }
62
+ if (propsOverride && Object.keys(propsOverride).length > 0) {
63
+ return {
64
+ ...layout,
65
+ defaultProps: { ...layout.defaultProps, ...propsOverride },
66
+ };
67
+ }
68
+ return layout;
69
+ }
70
+ getLayoutIds() {
71
+ return Array.from(this.layouts.keys());
72
+ }
73
+ hasLayout(layoutId) {
74
+ const normalizedId = this.normalizeLayoutId(layoutId);
75
+ return this.layouts.has(normalizedId);
76
+ }
77
+ reload() {
78
+ this.layouts.clear();
79
+ this.loadAllLayouts();
80
+ }
81
+ loadAllLayouts() {
82
+ const layoutsDir = this.options.templatesPath;
83
+ if (!(0, fs_1.existsSync)(layoutsDir)) {
84
+ throw new layout_types_1.LayoutLoadError(`Templates directory not found: ${layoutsDir}`, undefined, new Error(`Directory does not exist: ${layoutsDir}`));
85
+ }
86
+ try {
87
+ const files = (0, fs_1.readdirSync)(layoutsDir).filter(f => f.endsWith('.yaml') || f.endsWith('.yml'));
88
+ if (files.length === 0) {
89
+ console.warn(`No layout files found in ${layoutsDir}`);
90
+ }
91
+ for (const file of files) {
92
+ const layoutName = file.replace(/\.(yaml|yml)$/, '');
93
+ const layoutPath = path.join(layoutsDir, file);
94
+ try {
95
+ const layout = this.loadLayoutFile(layoutPath, layoutName);
96
+ const layoutId = `crewx/${layoutName}`;
97
+ this.layouts.set(layoutId, layout);
98
+ console.log(`Loaded layout: ${layoutId} from ${file}`);
99
+ }
100
+ catch (error) {
101
+ console.error(`Failed to load layout file ${file}:`, error);
102
+ }
103
+ }
104
+ console.log(`Loaded ${this.layouts.size} layouts from ${layoutsDir}`);
105
+ }
106
+ catch (error) {
107
+ throw new layout_types_1.LayoutLoadError(`Failed to read layouts directory: ${layoutsDir}`, undefined, error instanceof Error ? error : new Error(String(error)));
108
+ }
109
+ }
110
+ loadLayoutFile(filePath, layoutName) {
111
+ try {
112
+ const content = (0, fs_1.readFileSync)(filePath, 'utf-8');
113
+ if (!content || content.trim().length === 0) {
114
+ console.warn(`Empty YAML file: ${filePath}, will use fallback`);
115
+ throw new layout_types_1.LayoutLoadError(`Empty YAML file: ${filePath}`, layoutName, new Error('File content is empty'));
116
+ }
117
+ const parsed = (0, js_yaml_1.load)(content);
118
+ if (!parsed || typeof parsed !== 'object') {
119
+ console.warn(`Invalid YAML content in ${filePath} (parsed as ${typeof parsed}), will use fallback`);
120
+ throw new layout_types_1.LayoutLoadError(`Invalid or empty YAML in ${filePath}`, layoutName, new Error('YAML parsing returned null/undefined or non-object'));
121
+ }
122
+ if (parsed.layouts && typeof parsed.layouts === 'object') {
123
+ const layoutTemplate = parsed.layouts[layoutName] || parsed.layouts['default'];
124
+ if (!layoutTemplate || (typeof layoutTemplate === 'string' && layoutTemplate.trim().length === 0)) {
125
+ console.warn(`Empty or missing layout template in ${filePath} for ${layoutName}`);
126
+ throw new layout_types_1.LayoutLoadError(`Layout template not found or empty in layouts map: ${layoutName}`, layoutName);
127
+ }
128
+ return {
129
+ id: `crewx/${layoutName}`,
130
+ version: parsed.version || '1.0.0',
131
+ description: parsed.description || `CrewX ${layoutName} layout`,
132
+ template: layoutTemplate,
133
+ propsSchema: this.parsePropsSchema(parsed.propsSchema || {}),
134
+ defaultProps: this.extractDefaultProps(parsed.propsSchema || {}),
135
+ };
136
+ }
137
+ else {
138
+ if (!parsed.template || (typeof parsed.template === 'string' && parsed.template.trim().length === 0)) {
139
+ console.warn(`Empty or missing template field in ${filePath}`);
140
+ throw new layout_types_1.LayoutLoadError(`Layout template is missing or empty in ${filePath}`, layoutName);
141
+ }
142
+ return {
143
+ id: parsed.id || `crewx/${layoutName}`,
144
+ version: parsed.version || '1.0.0',
145
+ description: parsed.description || '',
146
+ template: parsed.template,
147
+ propsSchema: this.parsePropsSchema(parsed.propsSchema || {}),
148
+ defaultProps: this.extractDefaultProps(parsed.propsSchema || {}),
149
+ };
150
+ }
151
+ }
152
+ catch (error) {
153
+ throw new layout_types_1.LayoutLoadError(`Failed to load layout file: ${filePath}`, layoutName, error instanceof Error ? error : new Error(String(error)));
154
+ }
155
+ }
156
+ parsePropsSchema(raw) {
157
+ const schema = {};
158
+ for (const [key, value] of Object.entries(raw)) {
159
+ if (typeof value === 'object' && value !== null) {
160
+ schema[key] = value;
161
+ }
162
+ }
163
+ return schema;
164
+ }
165
+ extractDefaultProps(propsSchema) {
166
+ const defaults = {};
167
+ for (const [key, schema] of Object.entries(propsSchema)) {
168
+ if (schema && typeof schema === 'object' && 'defaultValue' in schema) {
169
+ defaults[key] = schema.defaultValue;
170
+ }
171
+ }
172
+ return defaults;
173
+ }
174
+ normalizeLayoutId(layoutId) {
175
+ if (!layoutId) {
176
+ return this.options.fallbackLayoutId;
177
+ }
178
+ if (layoutId.includes('/')) {
179
+ return layoutId;
180
+ }
181
+ return `crewx/${layoutId}`;
182
+ }
183
+ }
184
+ exports.LayoutLoader = LayoutLoader;
185
+ //# sourceMappingURL=layout-loader.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-loader.service.js","sourceRoot":"","sources":["../../src/services/layout-loader.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,2BAA2D;AAC3D,2CAA6B;AAC7B,qCAA2C;AAC3C,wDAM+B;AAK/B,MAAM,eAAe,GAA4B;IAC/C,aAAa,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,2BAA2B,CAAC;IAChE,cAAc,EAAE,SAAS;IACzB,gBAAgB,EAAE,eAAe;CAClC,CAAC;AAcF,MAAa,YAAY;IAIvB,YAAY,OAAgC;QAHpC,YAAO,GAAkC,IAAI,GAAG,EAAE,CAAC;QAIzD,IAAI,CAAC,OAAO,GAAG,EAAE,GAAG,eAAe,EAAE,GAAG,OAAO,EAAE,CAAC;QAClD,IAAI,CAAC,cAAc,EAAE,CAAC;IACxB,CAAC;IAkBD,IAAI,CAAC,QAAgB,EAAE,aAAmC;QAExD,MAAM,YAAY,GAAG,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;QAGtD,IAAI,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QAE5C,IA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CAAC;QACvC,CAAC;QAGD,IAAI,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3B,OAAO,QAAQ,CAAC;QAClB,CAAC;QAGD,OAAO,SAAS,QAAQ,EAAE,CAAC;IAC7B,CAAC;CACF;AAtQD,oCAsQC"}
@@ -0,0 +1,24 @@
1
+ import { PropsValidator } from './props-validator.service';
2
+ import type { LayoutDefinition, RenderContext, PropSchema, ValidationResult } from '../types/layout.types';
3
+ export { PropsValidationError } from '../types/layout.types';
4
+ export type { LayoutDefinition, RenderContext, PropSchema, ValidationResult as PropsValidationResult, } from '../types/layout.types';
5
+ export interface RenderOptions {
6
+ validationMode?: 'strict' | 'lenient';
7
+ skipValidation?: boolean;
8
+ }
9
+ export declare class LayoutRenderer {
10
+ private readonly handlebars;
11
+ private readonly propsValidator;
12
+ constructor(propsValidator?: PropsValidator);
13
+ render(layout: LayoutDefinition, context: RenderContext, options?: RenderOptions): string;
14
+ validate(props: Record<string, any> | undefined, propsSchema: Record<string, PropSchema>, mode?: 'strict' | 'lenient'): ValidationResult;
15
+ resolveProps(layout: LayoutDefinition, props: Record<string, any> | undefined, mode?: 'strict' | 'lenient'): ValidationResult;
16
+ private prepareRenderContext;
17
+ private registerHelpers;
18
+ private validateSecurityConstraints;
19
+ private executeValidation;
20
+ private mergeProps;
21
+ private deepMerge;
22
+ private cloneDeep;
23
+ private isPlainObject;
24
+ }
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LayoutRenderer = exports.PropsValidationError = void 0;
7
+ const handlebars_1 = __importDefault(require("handlebars"));
8
+ const props_validator_service_1 = require("./props-validator.service");
9
+ const layout_types_1 = require("../types/layout.types");
10
+ var layout_types_2 = require("../types/layout.types");
11
+ Object.defineProperty(exports, "PropsValidationError", { enumerable: true, get: function () { return layout_types_2.PropsValidationError; } });
12
+ class LayoutRenderer {
13
+ constructor(propsValidator) {
14
+ this.handlebars = handlebars_1.default.create();
15
+ this.propsValidator = propsValidator ?? new props_validator_service_1.PropsValidator();
16
+ this.registerHelpers();
17
+ }
18
+ render(layout, context, options = {}) {
19
+ try {
20
+ const preparedContext = this.prepareRenderContext(layout, context, options);
21
+ const template = this.handlebars.compile(layout.template);
22
+ const result = template(preparedContext);
23
+ this.validateSecurityConstraints(result);
24
+ return result;
25
+ }
26
+ catch (error) {
27
+ if (error instanceof Error) {
28
+ throw new Error(`Template rendering failed for layout '${layout.id}': ${error.message}`);
29
+ }
30
+ throw new Error(`Unknown error rendering layout '${layout.id}'`);
31
+ }
32
+ }
33
+ validate(props, propsSchema, mode = 'lenient') {
34
+ return this.executeValidation(props, propsSchema, mode);
35
+ }
36
+ resolveProps(layout, props, mode = 'lenient') {
37
+ const mergedProps = this.mergeProps(layout.defaultProps, props);
38
+ if (!layout.propsSchema || Object.keys(layout.propsSchema).length === 0) {
39
+ return {
40
+ valid: true,
41
+ props: mergedProps,
42
+ errors: [],
43
+ };
44
+ }
45
+ return this.executeValidation(mergedProps, layout.propsSchema, mode);
46
+ }
47
+ prepareRenderContext(layout, context, options) {
48
+ const { validationMode = 'lenient', skipValidation = false } = options;
49
+ const resolvedProps = skipValidation
50
+ ? this.mergeProps(layout.defaultProps, context.props)
51
+ : this.resolveProps(layout, context.props, validationMode).props;
52
+ return {
53
+ ...context,
54
+ props: resolvedProps,
55
+ };
56
+ }
57
+ registerHelpers() {
58
+ if (handlebars_1.default.helpers.each) {
59
+ this.handlebars.registerHelper('each', handlebars_1.default.helpers.each);
60
+ }
61
+ if (handlebars_1.default.helpers.if) {
62
+ this.handlebars.registerHelper('if', handlebars_1.default.helpers.if);
63
+ }
64
+ if (handlebars_1.default.helpers.unless) {
65
+ this.handlebars.registerHelper('unless', handlebars_1.default.helpers.unless);
66
+ }
67
+ if (handlebars_1.default.helpers.with) {
68
+ this.handlebars.registerHelper('with', handlebars_1.default.helpers.with);
69
+ }
70
+ this.handlebars.registerHelper('eq', function (a, b) {
71
+ return a === b;
72
+ });
73
+ this.handlebars.registerHelper('ne', function (a, b) {
74
+ return a !== b;
75
+ });
76
+ this.handlebars.registerHelper('gt', function (a, b) {
77
+ return a > b;
78
+ });
79
+ this.handlebars.registerHelper('lt', function (a, b) {
80
+ return a < b;
81
+ });
82
+ this.handlebars.registerHelper('json', function (obj) {
83
+ return new handlebars_1.default.SafeString(JSON.stringify(obj));
84
+ });
85
+ }
86
+ validateSecurityConstraints(content) {
87
+ const dangerousPatterns = [
88
+ /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
89
+ /javascript:/gi,
90
+ /on\w+\s*=/gi,
91
+ /<iframe\b[^>]*>/gi,
92
+ /<object\b[^>]*>/gi,
93
+ /<embed\b[^>]*>/gi,
94
+ ];
95
+ for (const pattern of dangerousPatterns) {
96
+ if (pattern.test(content)) {
97
+ throw new Error('Security constraint violation: Potentially dangerous content detected');
98
+ }
99
+ }
100
+ if (!content.includes('<crewx_system_prompt>') && !content.includes('<system_prompt')) {
101
+ console.warn('Warning: Layout does not contain required security containers');
102
+ }
103
+ }
104
+ executeValidation(props, propsSchema, mode) {
105
+ try {
106
+ return this.propsValidator.validate(props, propsSchema, mode);
107
+ }
108
+ catch (error) {
109
+ if (error instanceof layout_types_1.PropsValidationError && error.errors && error.errors.length > 0) {
110
+ const firstError = error.errors[0];
111
+ if (firstError) {
112
+ throw new layout_types_1.PropsValidationError(firstError.message, error.errors);
113
+ }
114
+ }
115
+ throw error;
116
+ }
117
+ }
118
+ mergeProps(defaultProps, overrides) {
119
+ const base = this.cloneDeep(defaultProps ?? {});
120
+ if (!overrides) {
121
+ return base;
122
+ }
123
+ return this.deepMerge(base, overrides);
124
+ }
125
+ deepMerge(target, source) {
126
+ for (const [key, value] of Object.entries(source)) {
127
+ if (this.isPlainObject(value)) {
128
+ const existing = target[key];
129
+ target[key] = this.deepMerge(this.isPlainObject(existing) ? existing : {}, value);
130
+ continue;
131
+ }
132
+ if (Array.isArray(value)) {
133
+ target[key] = this.cloneDeep(value);
134
+ continue;
135
+ }
136
+ target[key] = value;
137
+ }
138
+ return target;
139
+ }
140
+ cloneDeep(value) {
141
+ if (Array.isArray(value)) {
142
+ return value.map(item => this.cloneDeep(item));
143
+ }
144
+ if (this.isPlainObject(value)) {
145
+ const cloned = {};
146
+ for (const [key, nested] of Object.entries(value)) {
147
+ cloned[key] = this.cloneDeep(nested);
148
+ }
149
+ return cloned;
150
+ }
151
+ return value;
152
+ }
153
+ isPlainObject(value) {
154
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
155
+ }
156
+ }
157
+ exports.LayoutRenderer = LayoutRenderer;
158
+ //# sourceMappingURL=layout-renderer.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-renderer.service.js","sourceRoot":"","sources":["../../src/services/layout-renderer.service.ts"],"names":[],"mappings":";;;;;;AASA,4DAAoC;AACpC,uEAA2D;AAO3D,wDAA2F;AAG3F,sDAA6D;AAApD,oHAAA,oBAAoB,OAAA;AAoB7B,MAAa,cAAc;IAIzB,YAAY,cAA+B;QACzC,IAAI,CAAC,UAAU,GAAG,oBAAU,CAAC,MAAM,EAAE,CAAC;QACtC,IAAI,CAAC,cAAc,GAAG,cAAc,IAAI,IAAI,wCAAc,EAAE,CAAC;QAC7D,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAUD,MAAM,CACJ,MAAwB,EACxB,OAAsB,EACtB,UAAyB,EAAE;QAE3B,IAAI,CAAC;YACH,MAAM,eAAe,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC5E,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC1D,MAAM,MAAM,GAAG,QAAQ,CAAC,eAAe,CAAC,CAAC;YA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,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,SAAS,CAAI,KAAQ;QAC3B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAiB,CAAC;QACjE,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAwB,EAAE,CAAC;YACvC,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAA4B,CAAC,EAAE,CAAC;gBACzE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,MAAW,CAAC;QACrB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,KAAc;QAClC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;CACF;AA7ND,wCA6NC"}
@@ -0,0 +1,29 @@
1
+ import { PropSchema, ValidationResult } from '../types/layout.types';
2
+ export type ValidationMode = 'strict' | 'lenient';
3
+ export interface PropsValidatorOptions {
4
+ defaultMode?: ValidationMode;
5
+ }
6
+ export declare class PropsValidator {
7
+ private readonly defaultMode;
8
+ constructor(options?: PropsValidatorOptions);
9
+ validate(props: Record<string, any> | undefined, schema: Record<string, PropSchema>, mode?: ValidationMode): ValidationResult;
10
+ private validateObject;
11
+ private resolveProp;
12
+ private validateType;
13
+ private validateString;
14
+ private validateNumber;
15
+ private validateBoolean;
16
+ private validateArray;
17
+ private validateArrayOf;
18
+ private validatePlainObject;
19
+ private validateFunction;
20
+ private validateShape;
21
+ private validateOneOfType;
22
+ private matchesType;
23
+ private applyDefaults;
24
+ private cloneValue;
25
+ private isPlainObject;
26
+ private isNil;
27
+ private buildPath;
28
+ private describeType;
29
+ }
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropsValidator = void 0;
4
+ const layout_types_1 = require("../types/layout.types");
5
+ class PropsValidator {
6
+ constructor(options = {}) {
7
+ this.defaultMode = options.defaultMode ?? 'lenient';
8
+ }
9
+ validate(props, schema, mode = this.defaultMode) {
10
+ const errors = [];
11
+ const resolvedProps = this.validateObject(props ?? {}, schema, mode, ['props'], errors);
12
+ if (errors.length > 0 && mode === 'strict') {
13
+ throw new layout_types_1.PropsValidationError('Props validation failed in strict mode', errors);
14
+ }
15
+ return {
16
+ valid: errors.length === 0,
17
+ props: resolvedProps,
18
+ errors,
19
+ };
20
+ }
21
+ validateObject(provided, schema, mode, pathSegments, errors) {
22
+ const sanitized = {};
23
+ if (mode === 'strict') {
24
+ for (const key of Object.keys(provided)) {
25
+ if (!schema[key]) {
26
+ errors.push({
27
+ path: this.buildPath([...pathSegments, key]),
28
+ message: `Unknown prop '${key}'`,
29
+ value: provided[key],
30
+ });
31
+ }
32
+ }
33
+ }
34
+ for (const [key, propSchema] of Object.entries(schema)) {
35
+ const fullPath = [...pathSegments, key];
36
+ const rawValue = provided[key];
37
+ const result = this.resolveProp(rawValue, propSchema, fullPath, mode, errors);
38
+ if (result.shouldAssign) {
39
+ sanitized[key] = result.value;
40
+ }
41
+ }
42
+ if (mode === 'lenient') {
43
+ }
44
+ else if (mode === 'strict') {
45
+ }
46
+ return sanitized;
47
+ }
48
+ resolveProp(value, schema, pathSegments, mode, errors) {
49
+ const path = this.buildPath(pathSegments);
50
+ if (this.isNil(value)) {
51
+ if (schema.isRequired) {
52
+ errors.push({
53
+ path,
54
+ message: `Required prop '${pathSegments[pathSegments.length - 1]}' is missing`,
55
+ });
56
+ }
57
+ if (schema.defaultValue !== undefined) {
58
+ return { shouldAssign: true, value: this.cloneValue(schema.defaultValue) };
59
+ }
60
+ if (schema.type === 'shape' && schema.shape) {
61
+ const nestedDefaults = this.applyDefaults(schema.shape);
62
+ if (Object.keys(nestedDefaults).length > 0) {
63
+ return { shouldAssign: true, value: nestedDefaults };
64
+ }
65
+ }
66
+ return { shouldAssign: false };
67
+ }
68
+ const typeResult = this.validateType(value, schema, pathSegments, mode, errors);
69
+ if (!typeResult.valid) {
70
+ if (schema.type === 'shape' &&
71
+ typeResult.value &&
72
+ this.isPlainObject(typeResult.value)) {
73
+ return { shouldAssign: true, value: typeResult.value };
74
+ }
75
+ errors.push({ path, message: typeResult.error ?? 'Invalid value', value });
76
+ if (schema.defaultValue !== undefined) {
77
+ return { shouldAssign: true, value: this.cloneValue(schema.defaultValue) };
78
+ }
79
+ if (schema.type === 'shape' && schema.shape) {
80
+ const nestedDefaults = this.applyDefaults(schema.shape);
81
+ if (Object.keys(nestedDefaults).length > 0) {
82
+ return { shouldAssign: true, value: nestedDefaults };
83
+ }
84
+ }
85
+ return { shouldAssign: false };
86
+ }
87
+ return { shouldAssign: true, value: typeResult.value };
88
+ }
89
+ validateType(value, schema, pathSegments, mode, errors) {
90
+ const { type } = schema;
91
+ switch (type) {
92
+ case 'string':
93
+ return this.validateString(value, schema);
94
+ case 'number':
95
+ return this.validateNumber(value, schema);
96
+ case 'bool':
97
+ return this.validateBoolean(value);
98
+ case 'array':
99
+ return this.validateArray(value, schema);
100
+ case 'arrayOf':
101
+ return this.validateArrayOf(value, schema, pathSegments, mode, errors);
102
+ case 'object':
103
+ return this.validatePlainObject(value);
104
+ case 'shape':
105
+ return this.validateShape(value, schema, pathSegments, mode, errors);
106
+ case 'oneOfType':
107
+ return this.validateOneOfType(value, schema);
108
+ case 'func':
109
+ return this.validateFunction(value);
110
+ case 'node':
111
+ return { valid: true, value };
112
+ default:
113
+ return { valid: true, value };
114
+ }
115
+ }
116
+ validateString(value, schema) {
117
+ if (typeof value !== 'string') {
118
+ return { valid: false, error: `Expected string, got ${this.describeType(value)}` };
119
+ }
120
+ if (schema.oneOf && !schema.oneOf.includes(value)) {
121
+ return {
122
+ valid: false,
123
+ error: `Expected one of: ${schema.oneOf.join(', ')}`,
124
+ };
125
+ }
126
+ if (schema.minLength !== undefined && value.length < schema.minLength) {
127
+ return {
128
+ valid: false,
129
+ error: `String length must be >= ${schema.minLength}`,
130
+ };
131
+ }
132
+ if (schema.maxLength !== undefined && value.length > schema.maxLength) {
133
+ return {
134
+ valid: false,
135
+ error: `String length must be <= ${schema.maxLength}`,
136
+ };
137
+ }
138
+ if (schema.pattern) {
139
+ const pattern = new RegExp(schema.pattern);
140
+ if (!pattern.test(value)) {
141
+ return {
142
+ valid: false,
143
+ error: `String does not match pattern ${schema.pattern}`,
144
+ };
145
+ }
146
+ }
147
+ return { valid: true, value };
148
+ }
149
+ validateNumber(value, schema) {
150
+ if (typeof value !== 'number' || Number.isNaN(value)) {
151
+ return { valid: false, error: `Expected number, got ${this.describeType(value)}` };
152
+ }
153
+ if (schema.min !== undefined && value < schema.min) {
154
+ return { valid: false, error: `Number must be >= ${schema.min}` };
155
+ }
156
+ if (schema.max !== undefined && value > schema.max) {
157
+ return { valid: false, error: `Number must be <= ${schema.max}` };
158
+ }
159
+ if (schema.oneOf && !schema.oneOf.includes(value)) {
160
+ return {
161
+ valid: false,
162
+ error: `Expected one of: ${schema.oneOf.join(', ')}`,
163
+ };
164
+ }
165
+ return { valid: true, value };
166
+ }
167
+ validateBoolean(value) {
168
+ if (typeof value !== 'boolean') {
169
+ return { valid: false, error: `Expected boolean, got ${this.describeType(value)}` };
170
+ }
171
+ return { valid: true, value };
172
+ }
173
+ validateArray(value, schema) {
174
+ if (!Array.isArray(value)) {
175
+ return { valid: false, error: `Expected array, got ${this.describeType(value)}` };
176
+ }
177
+ if (schema.minLength !== undefined && value.length < schema.minLength) {
178
+ return {
179
+ valid: false,
180
+ error: `Array length must be >= ${schema.minLength}`,
181
+ };
182
+ }
183
+ if (schema.maxLength !== undefined && value.length > schema.maxLength) {
184
+ return {
185
+ valid: false,
186
+ error: `Array length must be <= ${schema.maxLength}`,
187
+ };
188
+ }
189
+ return { valid: true, value: [...value] };
190
+ }
191
+ validateArrayOf(value, schema, pathSegments, mode, errors) {
192
+ const base = this.validateArray(value, schema);
193
+ if (!base.valid) {
194
+ return base;
195
+ }
196
+ const itemValues = [];
197
+ const itemType = schema.itemType;
198
+ const itemOneOf = schema.itemOneOf;
199
+ const beforeErrors = errors.length;
200
+ base.value.forEach((item, index) => {
201
+ const itemPath = [...pathSegments, String(index)];
202
+ if (itemType) {
203
+ const result = this.validateType(item, { type: itemType }, itemPath, mode, errors);
204
+ if (!result.valid) {
205
+ errors.push({
206
+ path: this.buildPath(itemPath),
207
+ message: result.error ?? 'Invalid array item',
208
+ value: item,
209
+ });
210
+ }
211
+ else {
212
+ itemValues.push(result.value);
213
+ }
214
+ }
215
+ else {
216
+ itemValues.push(item);
217
+ }
218
+ if (itemOneOf && !itemOneOf.includes(item)) {
219
+ errors.push({
220
+ path: this.buildPath(itemPath),
221
+ message: `Array item must be one of: ${itemOneOf.join(', ')}`,
222
+ value: item,
223
+ });
224
+ }
225
+ });
226
+ return { valid: errors.length === beforeErrors, value: itemValues };
227
+ }
228
+ validatePlainObject(value) {
229
+ if (!this.isPlainObject(value)) {
230
+ return { valid: false, error: `Expected object, got ${this.describeType(value)}` };
231
+ }
232
+ return { valid: true, value: { ...value } };
233
+ }
234
+ validateFunction(value) {
235
+ if (typeof value !== 'function') {
236
+ return { valid: false, error: `Expected function, got ${this.describeType(value)}` };
237
+ }
238
+ return { valid: true, value };
239
+ }
240
+ validateShape(value, schema, pathSegments, mode, errors) {
241
+ if (!this.isPlainObject(value)) {
242
+ return { valid: false, error: `Expected object, got ${this.describeType(value)}` };
243
+ }
244
+ const beforeErrors = errors.length;
245
+ const nested = this.validateObject(value, schema.shape ?? {}, mode, pathSegments, errors);
246
+ return { valid: errors.length === beforeErrors, value: nested };
247
+ }
248
+ validateOneOfType(value, schema) {
249
+ const types = schema.types ?? [];
250
+ const matches = types.some(typeName => this.matchesType(value, typeName));
251
+ if (!matches) {
252
+ return {
253
+ valid: false,
254
+ error: `Value does not match any allowed type: ${types.join(', ')}`,
255
+ };
256
+ }
257
+ return { valid: true, value };
258
+ }
259
+ matchesType(value, typeName) {
260
+ switch (typeName) {
261
+ case 'string':
262
+ return typeof value === 'string';
263
+ case 'number':
264
+ return typeof value === 'number' && !Number.isNaN(value);
265
+ case 'bool':
266
+ case 'boolean':
267
+ return typeof value === 'boolean';
268
+ case 'array':
269
+ return Array.isArray(value);
270
+ case 'object':
271
+ return this.isPlainObject(value);
272
+ case 'func':
273
+ case 'function':
274
+ return typeof value === 'function';
275
+ case 'shape':
276
+ return this.isPlainObject(value);
277
+ case 'node':
278
+ return value === null || value === undefined || typeof value !== 'symbol';
279
+ default:
280
+ return true;
281
+ }
282
+ }
283
+ applyDefaults(schema) {
284
+ const defaults = {};
285
+ for (const [key, propSchema] of Object.entries(schema)) {
286
+ if (propSchema.defaultValue !== undefined) {
287
+ defaults[key] = this.cloneValue(propSchema.defaultValue);
288
+ continue;
289
+ }
290
+ if (propSchema.type === 'shape' && propSchema.shape) {
291
+ const nestedDefaults = this.applyDefaults(propSchema.shape);
292
+ if (Object.keys(nestedDefaults).length > 0) {
293
+ defaults[key] = nestedDefaults;
294
+ }
295
+ }
296
+ }
297
+ return defaults;
298
+ }
299
+ cloneValue(value) {
300
+ if (Array.isArray(value)) {
301
+ return value.map(item => this.cloneValue(item));
302
+ }
303
+ if (this.isPlainObject(value)) {
304
+ const cloned = {};
305
+ for (const [key, nested] of Object.entries(value)) {
306
+ cloned[key] = this.cloneValue(nested);
307
+ }
308
+ return cloned;
309
+ }
310
+ return value;
311
+ }
312
+ isPlainObject(value) {
313
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
314
+ }
315
+ isNil(value) {
316
+ return value === null || value === undefined;
317
+ }
318
+ buildPath(segments) {
319
+ return segments.join('.');
320
+ }
321
+ describeType(value) {
322
+ if (Array.isArray(value)) {
323
+ return 'array';
324
+ }
325
+ if (value === null) {
326
+ return 'null';
327
+ }
328
+ return typeof value;
329
+ }
330
+ }
331
+ exports.PropsValidator = PropsValidator;
332
+ //# sourceMappingURL=props-validator.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"props-validator.service.js","sourceRoot":"","sources":["../../src/services/props-validator.service.ts"],"names":[],"mappings":";;;AAAA,wDAK+B;AAc/B,MAAa,cAAc;IAGzB,YAAY,UAAiC,EAAE;QAC7C,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,IAAI,SAAS,CAAC;IACtD,CAAC;IAED,QAAQ,CACN,KAAsC,EACtC,MAAkC,EAClC,OAAuB,IAAI,CAAC,WAAW;QAEvC,MAAM,MAAM,GAAsB,EAAE,CAAC;QACrC,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CACvC,KAAK,IAAI,EAAE,EACX,MAAM,EACN,IAAI,EACJ,CAAC,OAAO,CAAC,EACT,MAAM,CACP,CAAC;QAEF,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3C,MAAM,IAAI,mCAAoB,CAAC,wCAAwC,EAAE,MAAM,CAAC,CAAC;QACnF,CAAC;QAED,OAAO;YACL,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC;YAC1B,KAAK,EAAE,aAAa;YACpB,MAAM;SACP,CAAC;IACJ,CAAC;IAEO,cAAc,CACpB,QAA6B,EAC7B,MAAkC,EAClC,IAAoB,EACpB,YAAsB,EACtB,MAAyB;QAEzB,MAAM,SAAS,GAAwB,EAAE,CAAC;QAG1C,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;YACtB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;oBACjB,MAAM,CAAC,I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AI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAiB,CAAC;QAClE,CAAC;QAED,IAAI,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9B,MAAM,MAAM,GAAwB,EAAE,CAAC;YACvC,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAA4B,CAAC,EAAE,CAAC;gBACzE,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACxC,CAAC;YACD,OAAO,MAAW,CAAC;QACrB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,aAAa,CAAC,KAAU;QAC9B,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9E,CAAC;IAEO,KAAK,CAAC,KAAU;QACtB,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,CAAC;IAC/C,CAAC;IAEO,SAAS,CAAC,QAAkB;QAClC,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAEO,YAAY,CAAC,KAAU;QAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,OAAO,CAAC;QACjB,CAAC;QAED,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YACnB,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,OAAO,OAAO,KAAK,CAAC;IACtB,CAAC;CACF;AAhcD,wCAgcC"}
@@ -0,0 +1,77 @@
1
+ export interface PropSchema {
2
+ type: 'string' | 'number' | 'bool' | 'array' | 'arrayOf' | 'object' | 'shape' | 'oneOfType' | 'func' | 'node';
3
+ isRequired?: boolean;
4
+ defaultValue?: any;
5
+ oneOf?: any[];
6
+ min?: number;
7
+ max?: number;
8
+ minLength?: number;
9
+ maxLength?: number;
10
+ itemType?: string;
11
+ itemOneOf?: any[];
12
+ shape?: Record<string, PropSchema>;
13
+ types?: string[];
14
+ pattern?: string;
15
+ description?: string;
16
+ }
17
+ export interface LayoutDefinition {
18
+ id: string;
19
+ version: string;
20
+ description: string;
21
+ template: string;
22
+ propsSchema: Record<string, PropSchema>;
23
+ defaultProps: Record<string, any>;
24
+ }
25
+ export type InlineLayoutSpec = string | {
26
+ id: string;
27
+ props?: Record<string, any>;
28
+ };
29
+ export interface ValidationResult {
30
+ valid: boolean;
31
+ props: Record<string, any>;
32
+ errors: ValidationError[];
33
+ }
34
+ export interface ValidationError {
35
+ path: string;
36
+ message: string;
37
+ value?: any;
38
+ }
39
+ export interface LoaderOptions {
40
+ templatesPath: string;
41
+ validationMode?: 'strict' | 'lenient';
42
+ fallbackLayoutId?: string;
43
+ }
44
+ export interface RenderContext {
45
+ agent: {
46
+ id: string;
47
+ name: string;
48
+ inline: {
49
+ prompt: string;
50
+ };
51
+ };
52
+ documents: Record<string, {
53
+ content: string;
54
+ toc?: string;
55
+ summary?: string;
56
+ }>;
57
+ vars: Record<string, any>;
58
+ props: Record<string, any>;
59
+ }
60
+ export interface RawLayoutYaml {
61
+ id?: string;
62
+ version?: string;
63
+ description?: string;
64
+ propsSchema?: Record<string, any>;
65
+ template?: string;
66
+ layouts?: Record<string, string>;
67
+ }
68
+ export declare class LayoutLoadError extends Error {
69
+ readonly layoutId?: string | undefined;
70
+ readonly cause?: Error | undefined;
71
+ constructor(message: string, layoutId?: string | undefined, cause?: Error | undefined);
72
+ }
73
+ export declare class PropsValidationError extends Error {
74
+ readonly errors: ValidationError[];
75
+ readonly cause?: Error | undefined;
76
+ constructor(message: string, errors?: ValidationError[], cause?: Error | undefined);
77
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PropsValidationError = exports.LayoutLoadError = void 0;
4
+ class LayoutLoadError extends Error {
5
+ constructor(message, layoutId, cause) {
6
+ super(message);
7
+ this.layoutId = layoutId;
8
+ this.cause = cause;
9
+ this.name = 'LayoutLoadError';
10
+ }
11
+ }
12
+ exports.LayoutLoadError = LayoutLoadError;
13
+ class PropsValidationError extends Error {
14
+ constructor(message, errors = [], cause) {
15
+ super(message);
16
+ this.errors = errors;
17
+ this.cause = cause;
18
+ this.name = 'PropsValidationError';
19
+ }
20
+ }
21
+ exports.PropsValidationError = PropsValidationError;
22
+ //# sourceMappingURL=layout.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout.types.js","sourceRoot":"","sources":["../../src/types/layout.types.ts"],"names":[],"mappings":";;;AAqHA,MAAa,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe,EAAkB,QAAiB,EAAkB,KAAa;QAC3F,KAAK,CAAC,OAAO,CAAC,CAAC;QAD4B,aAAQ,GAAR,QAAQ,CAAS;QAAkB,UAAK,GAAL,KAAK,CAAQ;QAE3F,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAKD,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YACE,OAAe,EACC,SAA4B,EAAE,EAC9B,KAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,WAAM,GAAN,MAAM,CAAwB;QAC9B,UAAK,GAAL,KAAK,CAAQ;QAG7B,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AATD,oDASC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sowonai/crewx-sdk",
3
- "version": "0.1.0-dev.3",
3
+ "version": "0.1.0-dev.5",
4
4
  "license": "Apache-2.0",
5
5
  "description": "SowonAI CrewX SDK",
6
6
  "type": "commonjs",