@crewx/sdk 0.8.0-rc.79 → 0.8.0-rc.82

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.
Files changed (292) hide show
  1. package/dist/__tests__/adapter/context-builder.test.d.ts +1 -0
  2. package/dist/__tests__/adapter/plugin-helper.test.d.ts +1 -0
  3. package/dist/__tests__/adapter/registration-integration.test.d.ts +1 -0
  4. package/dist/__tests__/adapter/scoped-store.test.d.ts +1 -0
  5. package/dist/__tests__/plugins/conversation.test.d.ts +1 -0
  6. package/dist/__tests__/testing/createMockContext.test.d.ts +1 -0
  7. package/dist/adapter/context-builder.d.ts +0 -9
  8. package/dist/adapter/index.d.ts +0 -1
  9. package/dist/adapter/plugin-helper.d.ts +0 -7
  10. package/dist/adapter/scoped-store.d.ts +0 -10
  11. package/dist/adapter/types.d.ts +0 -7
  12. package/dist/agent/resolver.d.ts +0 -13
  13. package/dist/boxing/box-storage.interface.d.ts +0 -4
  14. package/dist/boxing/box.service.d.ts +0 -4
  15. package/dist/boxing/box.types.d.ts +0 -4
  16. package/dist/boxing/context-builder.d.ts +0 -4
  17. package/dist/client/CrewxClient.d.ts +0 -32
  18. package/dist/client/index.d.ts +0 -1
  19. package/dist/client/index.js +1 -6
  20. package/dist/config/loader.browser.d.ts +0 -8
  21. package/dist/config/loader.d.ts +0 -12
  22. package/dist/conversation/__tests__/sqlite-provider.test.d.ts +1 -0
  23. package/dist/conversation/__tests__/to-task-reader.test.d.ts +1 -0
  24. package/dist/conversation/index.d.ts +0 -1
  25. package/dist/conversation/sqlite-provider.d.ts +0 -9
  26. package/dist/conversation/to-task-reader.d.ts +0 -11
  27. package/dist/conversation/to-template-messages.d.ts +0 -13
  28. package/dist/conversation/types.d.ts +0 -58
  29. package/dist/esm/client/index.js +1 -2
  30. package/dist/esm/hooks/index.js +7 -6
  31. package/dist/esm/index.js +79 -60
  32. package/dist/esm/plugins/index.js +52 -0
  33. package/dist/esm/testing/index.js +1 -0
  34. package/dist/esm/tools/node/index.js +36 -54
  35. package/dist/events/TypedEventEmitter.d.ts +0 -24
  36. package/dist/events/types.d.ts +0 -43
  37. package/dist/facade/Crewx.browser.d.ts +0 -40
  38. package/dist/facade/Crewx.d.ts +0 -163
  39. package/dist/hooks/define.d.ts +0 -1
  40. package/dist/hooks/dispatch.d.ts +0 -12
  41. package/dist/hooks/index.d.ts +0 -1
  42. package/dist/hooks/index.js +7 -24
  43. package/dist/hooks/observer.d.ts +0 -1
  44. package/dist/hooks/plugin.d.ts +0 -1
  45. package/dist/hooks/tool-normalize.d.ts +0 -26
  46. package/dist/hooks/types.d.ts +0 -1
  47. package/dist/hooks/yaml-plugin.d.ts +0 -1
  48. package/dist/index.browser.d.ts +0 -7
  49. package/dist/index.browser.js +2 -25
  50. package/dist/index.d.ts +0 -4
  51. package/dist/index.js +79 -151
  52. package/dist/layout/loader.d.ts +0 -20
  53. package/dist/layout/props-validator.d.ts +0 -6
  54. package/dist/layout/renderer.d.ts +0 -24
  55. package/dist/layout/types.d.ts +0 -42
  56. package/dist/parallel/agent-runtime.d.ts +0 -11
  57. package/dist/parallel/helpers.d.ts +0 -1
  58. package/dist/parallel/index.d.ts +0 -1
  59. package/dist/parallel/parallel-runner.d.ts +0 -8
  60. package/dist/parallel/types.d.ts +0 -24
  61. package/dist/parsers/agent-call.util.d.ts +0 -3
  62. package/dist/parsers/claude.parser.d.ts +0 -8
  63. package/dist/parsers/codex.parser.d.ts +0 -8
  64. package/dist/parsers/copilot.parser.d.ts +0 -9
  65. package/dist/parsers/gemini.parser.d.ts +0 -10
  66. package/dist/parsers/opencode.parser.d.ts +0 -10
  67. package/dist/parsers/router.d.ts +0 -5
  68. package/dist/paths.d.ts +1 -0
  69. package/dist/platform/BrowserFsAdapter.d.ts +0 -20
  70. package/dist/platform/IFsAdapter.d.ts +0 -23
  71. package/dist/platform/NodeFsAdapter.d.ts +0 -8
  72. package/dist/plugin/plugin-provider.d.ts +0 -22
  73. package/dist/plugin/types.d.ts +0 -31
  74. package/dist/plugin.d.ts +0 -27
  75. package/dist/plugins/conversation.d.ts +0 -2
  76. package/dist/plugins/file-logger.d.ts +0 -13
  77. package/dist/plugins/index.d.ts +0 -10
  78. package/dist/plugins/index.js +52 -19
  79. package/dist/plugins/sqlite-tracing.d.ts +0 -13
  80. package/dist/plugins/sqlite-tracing.spec.d.ts +1 -0
  81. package/dist/provider/bridge.browser.d.ts +0 -20
  82. package/dist/provider/bridge.d.ts +0 -47
  83. package/dist/provider/parse-usage.d.ts +0 -14
  84. package/dist/provider/register-api.d.ts +0 -7
  85. package/dist/provider/vercel-runtime.d.ts +0 -29
  86. package/dist/remote/index.d.ts +0 -6
  87. package/dist/remote/remote-agent-manager.d.ts +0 -31
  88. package/dist/remote/remote-provider.d.ts +0 -15
  89. package/dist/remote/remote-transport.d.ts +0 -17
  90. package/dist/remote/types.d.ts +0 -59
  91. package/dist/server/auth.d.ts +0 -16
  92. package/dist/server/handler.d.ts +0 -17
  93. package/dist/server/index.d.ts +0 -4
  94. package/dist/server/tool-adapter.d.ts +0 -16
  95. package/dist/template/engine.d.ts +0 -19
  96. package/dist/template/helpers/exec.browser.d.ts +0 -7
  97. package/dist/template/helpers/exec.d.ts +0 -45
  98. package/dist/template/helpers/fenced_code.d.ts +0 -16
  99. package/dist/template/helpers/format-conversation.d.ts +0 -22
  100. package/dist/template/helpers/include.d.ts +0 -15
  101. package/dist/template/helpers/p1p2.d.ts +0 -32
  102. package/dist/template/loader/DocumentLoader.d.ts +0 -30
  103. package/dist/template/types.d.ts +0 -30
  104. package/dist/testing/index.d.ts +0 -1
  105. package/dist/testing/index.js +1 -16
  106. package/dist/testing/mock-audit.d.ts +0 -1
  107. package/dist/testing/mock-context.d.ts +0 -1
  108. package/dist/testing/mock-logger.d.ts +0 -1
  109. package/dist/testing/mock-router.d.ts +0 -1
  110. package/dist/testing/mock-storage.d.ts +0 -1
  111. package/dist/testing/mock-store.d.ts +0 -1
  112. package/dist/tools/delegate.d.ts +0 -7
  113. package/dist/tools/index.d.ts +0 -4
  114. package/dist/tools/node/builtin.d.ts +0 -16
  115. package/dist/tools/node/index.d.ts +0 -20
  116. package/dist/tools/node/index.js +36 -59
  117. package/dist/types/index.d.ts +0 -20
  118. package/dist/types/task-log.types.d.ts +0 -4
  119. package/dist/utils/env-defaults.d.ts +0 -16
  120. package/dist/utils/glob-match.d.ts +0 -16
  121. package/dist/utils/id.d.ts +0 -15
  122. package/dist/utils/timestamp.d.ts +0 -1
  123. package/dist/utils/workspace.d.ts +0 -4
  124. package/package.json +24 -25
  125. package/dist/adapter/context-builder.js +0 -87
  126. package/dist/adapter/index.js +0 -21
  127. package/dist/adapter/plugin-helper.js +0 -45
  128. package/dist/adapter/scoped-store.js +0 -43
  129. package/dist/adapter/types.js +0 -23
  130. package/dist/agent/resolver.js +0 -46
  131. package/dist/boxing/box-storage.interface.js +0 -6
  132. package/dist/boxing/box.service.js +0 -73
  133. package/dist/boxing/box.types.js +0 -6
  134. package/dist/boxing/context-builder.js +0 -79
  135. package/dist/client/CrewxClient.js +0 -86
  136. package/dist/config/loader.browser.js +0 -59
  137. package/dist/config/loader.js +0 -95
  138. package/dist/conversation/index.js +0 -25
  139. package/dist/conversation/sqlite-provider.js +0 -178
  140. package/dist/conversation/to-task-reader.js +0 -28
  141. package/dist/conversation/to-template-messages.js +0 -34
  142. package/dist/conversation/types.js +0 -10
  143. package/dist/esm/agent/resolver.js +0 -41
  144. package/dist/esm/boxing/box-storage.interface.js +0 -5
  145. package/dist/esm/boxing/box.service.js +0 -69
  146. package/dist/esm/boxing/box.types.js +0 -5
  147. package/dist/esm/boxing/context-builder.js +0 -76
  148. package/dist/esm/client/CrewxClient.js +0 -82
  149. package/dist/esm/config/loader.browser.js +0 -54
  150. package/dist/esm/config/loader.js +0 -77
  151. package/dist/esm/events/TypedEventEmitter.js +0 -61
  152. package/dist/esm/events/types.js +0 -8
  153. package/dist/esm/facade/Crewx.browser.js +0 -310
  154. package/dist/esm/facade/Crewx.js +0 -941
  155. package/dist/esm/hooks/define.js +0 -10
  156. package/dist/esm/hooks/dispatch.js +0 -76
  157. package/dist/esm/hooks/observer.js +0 -56
  158. package/dist/esm/hooks/plugin.js +0 -12
  159. package/dist/esm/hooks/types.js +0 -9
  160. package/dist/esm/index.browser.js +0 -15
  161. package/dist/esm/layout/loader.js +0 -268
  162. package/dist/esm/layout/props-validator.js +0 -297
  163. package/dist/esm/layout/renderer.js +0 -180
  164. package/dist/esm/layout/types.js +0 -31
  165. package/dist/esm/parallel/agent-runtime.js +0 -21
  166. package/dist/esm/parallel/helpers.js +0 -214
  167. package/dist/esm/parallel/index.js +0 -5
  168. package/dist/esm/parallel/parallel-runner.js +0 -221
  169. package/dist/esm/parallel/types.js +0 -5
  170. package/dist/esm/parsers/agent-call.util.js +0 -15
  171. package/dist/esm/parsers/claude.parser.js +0 -64
  172. package/dist/esm/parsers/codex.parser.js +0 -97
  173. package/dist/esm/parsers/copilot.parser.js +0 -63
  174. package/dist/esm/parsers/gemini.parser.js +0 -43
  175. package/dist/esm/parsers/opencode.parser.js +0 -73
  176. package/dist/esm/parsers/router.js +0 -53
  177. package/dist/esm/platform/BrowserFsAdapter.js +0 -80
  178. package/dist/esm/platform/IFsAdapter.js +0 -2
  179. package/dist/esm/platform/NodeFsAdapter.js +0 -34
  180. package/dist/esm/plugin/plugin-provider.js +0 -202
  181. package/dist/esm/plugin/types.js +0 -8
  182. package/dist/esm/plugin.js +0 -25
  183. package/dist/esm/provider/bridge.browser.js +0 -43
  184. package/dist/esm/provider/bridge.js +0 -373
  185. package/dist/esm/provider/parse-usage.js +0 -80
  186. package/dist/esm/provider/register-api.js +0 -21
  187. package/dist/esm/provider/vercel-runtime.js +0 -310
  188. package/dist/esm/remote/index.js +0 -10
  189. package/dist/esm/remote/remote-agent-manager.js +0 -194
  190. package/dist/esm/remote/remote-provider.js +0 -98
  191. package/dist/esm/remote/remote-transport.js +0 -79
  192. package/dist/esm/remote/types.js +0 -8
  193. package/dist/esm/server/auth.js +0 -31
  194. package/dist/esm/server/handler.js +0 -72
  195. package/dist/esm/server/index.js +0 -5
  196. package/dist/esm/server/tool-adapter.js +0 -92
  197. package/dist/esm/template/engine.js +0 -100
  198. package/dist/esm/template/helpers/exec.browser.js +0 -31
  199. package/dist/esm/template/helpers/exec.js +0 -220
  200. package/dist/esm/template/helpers/fenced_code.js +0 -17
  201. package/dist/esm/template/helpers/include.js +0 -20
  202. package/dist/esm/template/helpers/p1p2.js +0 -83
  203. package/dist/esm/template/loader/DocumentLoader.js +0 -124
  204. package/dist/esm/template/types.js +0 -5
  205. package/dist/esm/tools/delegate.js +0 -57
  206. package/dist/esm/tools/index.js +0 -5
  207. package/dist/esm/tools/node/builtin.js +0 -541
  208. package/dist/esm/types/index.js +0 -27
  209. package/dist/esm/types/task-log.types.js +0 -5
  210. package/dist/esm/utils/env-defaults.js +0 -23
  211. package/dist/esm/utils/glob-match.js +0 -38
  212. package/dist/esm/utils/id.js +0 -46
  213. package/dist/esm/utils/workspace.js +0 -21
  214. package/dist/events/TypedEventEmitter.js +0 -65
  215. package/dist/events/types.js +0 -9
  216. package/dist/facade/Crewx.browser.js +0 -314
  217. package/dist/facade/Crewx.js +0 -1299
  218. package/dist/hooks/define.js +0 -13
  219. package/dist/hooks/dispatch.js +0 -147
  220. package/dist/hooks/observer.js +0 -60
  221. package/dist/hooks/plugin.js +0 -17
  222. package/dist/hooks/tool-normalize.js +0 -110
  223. package/dist/hooks/types.js +0 -12
  224. package/dist/hooks/yaml-plugin.js +0 -356
  225. package/dist/layout/loader.js +0 -305
  226. package/dist/layout/props-validator.js +0 -301
  227. package/dist/layout/renderer.js +0 -193
  228. package/dist/layout/types.js +0 -36
  229. package/dist/parallel/agent-runtime.js +0 -25
  230. package/dist/parallel/helpers.js +0 -219
  231. package/dist/parallel/index.js +0 -13
  232. package/dist/parallel/parallel-runner.js +0 -226
  233. package/dist/parallel/types.js +0 -6
  234. package/dist/parsers/agent-call.util.js +0 -19
  235. package/dist/parsers/api.parser.d.ts +0 -10
  236. package/dist/parsers/api.parser.js +0 -26
  237. package/dist/parsers/claude.parser.js +0 -67
  238. package/dist/parsers/codex.parser.js +0 -100
  239. package/dist/parsers/copilot.parser.js +0 -66
  240. package/dist/parsers/gemini.parser.js +0 -46
  241. package/dist/parsers/opencode.parser.js +0 -76
  242. package/dist/parsers/router.js +0 -56
  243. package/dist/platform/BrowserFsAdapter.js +0 -84
  244. package/dist/platform/IFsAdapter.js +0 -3
  245. package/dist/platform/NodeFsAdapter.js +0 -38
  246. package/dist/plugin/plugin-provider.js +0 -207
  247. package/dist/plugin/types.js +0 -9
  248. package/dist/plugin.js +0 -29
  249. package/dist/plugins/conversation.js +0 -59
  250. package/dist/plugins/file-logger.js +0 -87
  251. package/dist/plugins/sqlite-tracing.js +0 -112
  252. package/dist/provider/bridge.browser.js +0 -49
  253. package/dist/provider/bridge.js +0 -381
  254. package/dist/provider/mastra-runtime.d.ts +0 -45
  255. package/dist/provider/mastra-runtime.js +0 -208
  256. package/dist/provider/parse-usage.js +0 -83
  257. package/dist/provider/register-api.js +0 -24
  258. package/dist/provider/vercel-runtime.js +0 -347
  259. package/dist/remote/index.js +0 -32
  260. package/dist/remote/remote-agent-manager.js +0 -198
  261. package/dist/remote/remote-provider.js +0 -141
  262. package/dist/remote/remote-transport.js +0 -83
  263. package/dist/remote/types.js +0 -9
  264. package/dist/server/auth.js +0 -35
  265. package/dist/server/handler.js +0 -75
  266. package/dist/server/index.js +0 -9
  267. package/dist/server/tool-adapter.js +0 -95
  268. package/dist/template/engine.js +0 -137
  269. package/dist/template/helpers/exec.browser.js +0 -41
  270. package/dist/template/helpers/exec.js +0 -230
  271. package/dist/template/helpers/fenced_code.js +0 -20
  272. package/dist/template/helpers/format-conversation.js +0 -53
  273. package/dist/template/helpers/include.js +0 -23
  274. package/dist/template/helpers/p1p2.js +0 -90
  275. package/dist/template/loader/DocumentLoader.js +0 -128
  276. package/dist/template/types.js +0 -6
  277. package/dist/testing/mock-audit.js +0 -13
  278. package/dist/testing/mock-context.js +0 -68
  279. package/dist/testing/mock-logger.js +0 -27
  280. package/dist/testing/mock-router.js +0 -67
  281. package/dist/testing/mock-storage.js +0 -21
  282. package/dist/testing/mock-store.js +0 -8
  283. package/dist/tools/delegate.js +0 -60
  284. package/dist/tools/index.js +0 -9
  285. package/dist/tools/node/builtin.js +0 -547
  286. package/dist/types/index.js +0 -32
  287. package/dist/types/task-log.types.js +0 -6
  288. package/dist/utils/env-defaults.js +0 -27
  289. package/dist/utils/glob-match.js +0 -42
  290. package/dist/utils/id.js +0 -50
  291. package/dist/utils/timestamp.js +0 -13
  292. package/dist/utils/workspace.js +0 -58
@@ -1,301 +0,0 @@
1
- "use strict";
2
- /**
3
- * PropsValidator — React PropTypes style props validation.
4
- * Ported 1:1 from packages/sdk-bak/src/services/props-validator.service.ts.
5
- * Only the import path is changed.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.PropsValidator = void 0;
9
- const types_1 = require("./types");
10
- class PropsValidator {
11
- defaultMode;
12
- constructor(options = {}) {
13
- this.defaultMode = options.defaultMode ?? 'lenient';
14
- }
15
- validate(props, schema, mode = this.defaultMode) {
16
- const errors = [];
17
- const resolvedProps = this.validateObject(props ?? {}, schema, mode, ['props'], errors);
18
- if (errors.length > 0 && mode === 'strict') {
19
- throw new types_1.PropsValidationError('Props validation failed in strict mode', errors);
20
- }
21
- return {
22
- valid: errors.length === 0,
23
- props: resolvedProps,
24
- errors,
25
- };
26
- }
27
- validateObject(provided, schema, mode, pathSegments, errors) {
28
- const sanitized = {};
29
- if (mode === 'strict') {
30
- for (const key of Object.keys(provided)) {
31
- if (!schema[key]) {
32
- errors.push({
33
- path: this.buildPath([...pathSegments, key]),
34
- message: `Unknown prop '${key}'`,
35
- value: provided[key],
36
- });
37
- }
38
- }
39
- }
40
- for (const [key, propSchema] of Object.entries(schema)) {
41
- const fullPath = [...pathSegments, key];
42
- const rawValue = provided[key];
43
- const result = this.resolveProp(rawValue, propSchema, fullPath, mode, errors);
44
- if (result.shouldAssign) {
45
- sanitized[key] = result.value;
46
- }
47
- }
48
- return sanitized;
49
- }
50
- resolveProp(value, schema, pathSegments, mode, errors) {
51
- const path = this.buildPath(pathSegments);
52
- if (this.isNil(value)) {
53
- if (schema.isRequired) {
54
- errors.push({
55
- path,
56
- message: `Required prop '${pathSegments[pathSegments.length - 1]}' is missing`,
57
- });
58
- }
59
- if (schema.defaultValue !== undefined) {
60
- return { shouldAssign: true, value: this.cloneValue(schema.defaultValue) };
61
- }
62
- if (schema.type === 'shape' && schema.shape) {
63
- const nestedDefaults = this.applyDefaults(schema.shape);
64
- if (Object.keys(nestedDefaults).length > 0) {
65
- return { shouldAssign: true, value: nestedDefaults };
66
- }
67
- }
68
- return { shouldAssign: false };
69
- }
70
- const typeResult = this.validateType(value, schema, pathSegments, mode, errors);
71
- if (!typeResult.valid) {
72
- if (schema.type === 'shape' &&
73
- typeResult.value &&
74
- this.isPlainObject(typeResult.value)) {
75
- return { shouldAssign: true, value: typeResult.value };
76
- }
77
- errors.push({ path, message: typeResult.error ?? 'Invalid value', value });
78
- if (schema.defaultValue !== undefined) {
79
- return { shouldAssign: true, value: this.cloneValue(schema.defaultValue) };
80
- }
81
- if (schema.type === 'shape' && schema.shape) {
82
- const nestedDefaults = this.applyDefaults(schema.shape);
83
- if (Object.keys(nestedDefaults).length > 0) {
84
- return { shouldAssign: true, value: nestedDefaults };
85
- }
86
- }
87
- return { shouldAssign: false };
88
- }
89
- return { shouldAssign: true, value: typeResult.value };
90
- }
91
- validateType(value, schema, pathSegments, mode, errors) {
92
- const { type } = schema;
93
- switch (type) {
94
- case 'string':
95
- return this.validateString(value, schema);
96
- case 'number':
97
- return this.validateNumber(value, schema);
98
- case 'bool':
99
- return this.validateBoolean(value);
100
- case 'array':
101
- return this.validateArray(value, schema);
102
- case 'arrayOf':
103
- return this.validateArrayOf(value, schema, pathSegments, mode, errors);
104
- case 'object':
105
- return this.validatePlainObject(value);
106
- case 'shape':
107
- return this.validateShape(value, schema, pathSegments, mode, errors);
108
- case 'oneOfType':
109
- return this.validateOneOfType(value, schema);
110
- case 'func':
111
- return this.validateFunction(value);
112
- case 'node':
113
- return { valid: true, value };
114
- default:
115
- return { valid: true, value };
116
- }
117
- }
118
- validateString(value, schema) {
119
- if (typeof value !== 'string') {
120
- return { valid: false, error: `Expected string, got ${this.describeType(value)}` };
121
- }
122
- if (schema.oneOf && !schema.oneOf.includes(value)) {
123
- return { valid: false, error: `Expected one of: ${schema.oneOf.join(', ')}` };
124
- }
125
- if (schema.minLength !== undefined && value.length < schema.minLength) {
126
- return { valid: false, error: `String length must be >= ${schema.minLength}` };
127
- }
128
- if (schema.maxLength !== undefined && value.length > schema.maxLength) {
129
- return { valid: false, error: `String length must be <= ${schema.maxLength}` };
130
- }
131
- if (schema.pattern) {
132
- const pattern = new RegExp(schema.pattern);
133
- if (!pattern.test(value)) {
134
- return { valid: false, error: `String does not match pattern ${schema.pattern}` };
135
- }
136
- }
137
- return { valid: true, value };
138
- }
139
- validateNumber(value, schema) {
140
- if (typeof value !== 'number' || Number.isNaN(value)) {
141
- return { valid: false, error: `Expected number, got ${this.describeType(value)}` };
142
- }
143
- if (schema.min !== undefined && value < schema.min) {
144
- return { valid: false, error: `Number must be >= ${schema.min}` };
145
- }
146
- if (schema.max !== undefined && value > schema.max) {
147
- return { valid: false, error: `Number must be <= ${schema.max}` };
148
- }
149
- if (schema.oneOf && !schema.oneOf.includes(value)) {
150
- return { valid: false, error: `Expected one of: ${schema.oneOf.join(', ')}` };
151
- }
152
- return { valid: true, value };
153
- }
154
- validateBoolean(value) {
155
- if (typeof value !== 'boolean') {
156
- return { valid: false, error: `Expected boolean, got ${this.describeType(value)}` };
157
- }
158
- return { valid: true, value };
159
- }
160
- validateArray(value, schema) {
161
- if (!Array.isArray(value)) {
162
- return { valid: false, error: `Expected array, got ${this.describeType(value)}` };
163
- }
164
- if (schema.minLength !== undefined && value.length < schema.minLength) {
165
- return { valid: false, error: `Array length must be >= ${schema.minLength}` };
166
- }
167
- if (schema.maxLength !== undefined && value.length > schema.maxLength) {
168
- return { valid: false, error: `Array length must be <= ${schema.maxLength}` };
169
- }
170
- return { valid: true, value: [...value] };
171
- }
172
- validateArrayOf(value, schema, pathSegments, mode, errors) {
173
- const base = this.validateArray(value, schema);
174
- if (!base.valid)
175
- return base;
176
- const itemValues = [];
177
- const itemType = schema.itemType;
178
- const itemOneOf = schema.itemOneOf;
179
- const beforeErrors = errors.length;
180
- base.value.forEach((item, index) => {
181
- const itemPath = [...pathSegments, String(index)];
182
- if (itemType) {
183
- const result = this.validateType(item, { type: itemType }, itemPath, mode, errors);
184
- if (!result.valid) {
185
- errors.push({
186
- path: this.buildPath(itemPath),
187
- message: result.error ?? 'Invalid array item',
188
- value: item,
189
- });
190
- }
191
- else {
192
- itemValues.push(result.value);
193
- }
194
- }
195
- else {
196
- itemValues.push(item);
197
- }
198
- if (itemOneOf && !itemOneOf.includes(item)) {
199
- errors.push({
200
- path: this.buildPath(itemPath),
201
- message: `Array item must be one of: ${itemOneOf.join(', ')}`,
202
- value: item,
203
- });
204
- }
205
- });
206
- return { valid: errors.length === beforeErrors, value: itemValues };
207
- }
208
- validatePlainObject(value) {
209
- if (!this.isPlainObject(value)) {
210
- return { valid: false, error: `Expected object, got ${this.describeType(value)}` };
211
- }
212
- return { valid: true, value: { ...value } };
213
- }
214
- validateFunction(value) {
215
- if (typeof value !== 'function') {
216
- return { valid: false, error: `Expected function, got ${this.describeType(value)}` };
217
- }
218
- return { valid: true, value };
219
- }
220
- validateShape(value, schema, pathSegments, mode, errors) {
221
- if (!this.isPlainObject(value)) {
222
- return { valid: false, error: `Expected object, got ${this.describeType(value)}` };
223
- }
224
- const beforeErrors = errors.length;
225
- const nested = this.validateObject(value, schema.shape ?? {}, mode, pathSegments, errors);
226
- return { valid: errors.length === beforeErrors, value: nested };
227
- }
228
- validateOneOfType(value, schema) {
229
- const types = schema.types ?? [];
230
- const matches = types.some(typeName => this.matchesType(value, typeName));
231
- if (!matches) {
232
- return {
233
- valid: false,
234
- error: `Value does not match any allowed type: ${types.join(', ')}`,
235
- };
236
- }
237
- return { valid: true, value };
238
- }
239
- matchesType(value, typeName) {
240
- switch (typeName) {
241
- case 'string': return typeof value === 'string';
242
- case 'number': return typeof value === 'number' && !Number.isNaN(value);
243
- case 'bool':
244
- case 'boolean': return typeof value === 'boolean';
245
- case 'array': return Array.isArray(value);
246
- case 'object': return this.isPlainObject(value);
247
- case 'func':
248
- case 'function': return typeof value === 'function';
249
- case 'shape': return this.isPlainObject(value);
250
- case 'node': return value === null || value === undefined || typeof value !== 'symbol';
251
- default: return true;
252
- }
253
- }
254
- applyDefaults(schema) {
255
- const defaults = {};
256
- for (const [key, propSchema] of Object.entries(schema)) {
257
- if (propSchema.defaultValue !== undefined) {
258
- defaults[key] = this.cloneValue(propSchema.defaultValue);
259
- continue;
260
- }
261
- if (propSchema.type === 'shape' && propSchema.shape) {
262
- const nestedDefaults = this.applyDefaults(propSchema.shape);
263
- if (Object.keys(nestedDefaults).length > 0) {
264
- defaults[key] = nestedDefaults;
265
- }
266
- }
267
- }
268
- return defaults;
269
- }
270
- cloneValue(value) {
271
- if (Array.isArray(value)) {
272
- return value.map(item => this.cloneValue(item));
273
- }
274
- if (this.isPlainObject(value)) {
275
- const cloned = {};
276
- for (const [key, nested] of Object.entries(value)) {
277
- cloned[key] = this.cloneValue(nested);
278
- }
279
- return cloned;
280
- }
281
- return value;
282
- }
283
- isPlainObject(value) {
284
- return typeof value === 'object' && value !== null && !Array.isArray(value);
285
- }
286
- isNil(value) {
287
- return value === null || value === undefined;
288
- }
289
- buildPath(segments) {
290
- return segments.join('.');
291
- }
292
- describeType(value) {
293
- if (Array.isArray(value))
294
- return 'array';
295
- if (value === null)
296
- return 'null';
297
- return typeof value;
298
- }
299
- }
300
- exports.PropsValidator = PropsValidator;
301
- //# sourceMappingURL=props-validator.js.map
@@ -1,193 +0,0 @@
1
- "use strict";
2
- /**
3
- * LayoutRenderer — Handlebars-based layout rendering.
4
- * Ported from packages/sdk-bak/src/services/layout-renderer.service.ts.
5
- * Excluded: registerTemplateHelpers (exec/shell-quote).
6
- * Exec is handled separately by TemplateEngine in the facade layer.
7
- * WI-CONV-002: formatConversation helper restored.
8
- */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.LayoutRenderer = exports.PropsValidationError = void 0;
14
- const handlebars_1 = __importDefault(require("handlebars"));
15
- const format_conversation_1 = require("../template/helpers/format-conversation");
16
- const props_validator_1 = require("./props-validator");
17
- const types_1 = require("./types");
18
- var types_2 = require("./types");
19
- Object.defineProperty(exports, "PropsValidationError", { enumerable: true, get: function () { return types_2.PropsValidationError; } });
20
- /**
21
- * LayoutRenderer — renders layout templates with Handlebars.
22
- */
23
- class LayoutRenderer {
24
- handlebars;
25
- propsValidator;
26
- constructor(propsValidator) {
27
- this.handlebars = handlebars_1.default.create();
28
- this.propsValidator = propsValidator ?? new props_validator_1.PropsValidator();
29
- this.registerHelpers();
30
- }
31
- /**
32
- * Render a layout template with the given context.
33
- */
34
- render(layout, context, options = {}) {
35
- try {
36
- const preparedContext = this.prepareRenderContext(layout, context, options);
37
- const template = this.handlebars.compile(layout.template, { noEscape: true });
38
- return template(preparedContext);
39
- }
40
- catch (error) {
41
- if (error instanceof Error) {
42
- throw new Error(`Template rendering failed for layout '${layout.id}': ${error.message}`);
43
- }
44
- throw new Error(`Unknown error rendering layout '${layout.id}'`);
45
- }
46
- }
47
- /**
48
- * Validate props against schema.
49
- */
50
- validate(props, propsSchema, mode = 'lenient') {
51
- return this.executeValidation(props, propsSchema, mode);
52
- }
53
- /**
54
- * Merge default props and runtime props, then validate.
55
- */
56
- resolveProps(layout, props, mode = 'lenient') {
57
- const mergedProps = this.mergeProps(layout.defaultProps, props);
58
- if (!layout.propsSchema || Object.keys(layout.propsSchema).length === 0) {
59
- return { valid: true, props: mergedProps, errors: [] };
60
- }
61
- return this.executeValidation(mergedProps, layout.propsSchema, mode);
62
- }
63
- prepareRenderContext(layout, context, options) {
64
- const { validationMode = 'lenient', skipValidation = false } = options;
65
- const resolvedProps = skipValidation
66
- ? this.mergeProps(layout.defaultProps, context.props)
67
- : this.resolveProps(layout, context.props, validationMode).props;
68
- return {
69
- ...context,
70
- vars: this.sanitizeVars(context.vars),
71
- props: resolvedProps,
72
- };
73
- }
74
- /**
75
- * Register built-in Handlebars helpers (no exec).
76
- * WI-CONV-002: formatConversation block helper registered for conversation history.
77
- */
78
- registerHelpers() {
79
- // Conversation history block helper (WI-CONV-002)
80
- this.handlebars.registerHelper('formatConversation', format_conversation_1.formatConversationHelper);
81
- // Built-in block helpers
82
- if (handlebars_1.default.helpers.each) {
83
- this.handlebars.registerHelper('each', handlebars_1.default.helpers.each);
84
- }
85
- if (handlebars_1.default.helpers.if) {
86
- this.handlebars.registerHelper('if', handlebars_1.default.helpers.if);
87
- }
88
- if (handlebars_1.default.helpers.unless) {
89
- this.handlebars.registerHelper('unless', handlebars_1.default.helpers.unless);
90
- }
91
- if (handlebars_1.default.helpers.with) {
92
- this.handlebars.registerHelper('with', handlebars_1.default.helpers.with);
93
- }
94
- this.handlebars.registerHelper('eq', function (a, b) {
95
- return a === b;
96
- });
97
- this.handlebars.registerHelper('ne', function (a, b) {
98
- return a !== b;
99
- });
100
- this.handlebars.registerHelper('gt', function (a, b) {
101
- return a > b;
102
- });
103
- this.handlebars.registerHelper('lt', function (a, b) {
104
- return a < b;
105
- });
106
- this.handlebars.registerHelper('json', function (obj) {
107
- return new handlebars_1.default.SafeString(JSON.stringify(obj));
108
- });
109
- this.handlebars.registerHelper('raw', function (options) {
110
- return typeof options?.fn === 'function' ? options.fn(this) : '';
111
- });
112
- this.handlebars.registerHelper('escapeHandlebars', function (text) {
113
- if (typeof text !== 'string')
114
- return '';
115
- return text.replace(/\{\{/g, '&#123;&#123;').replace(/\}\}/g, '&#125;&#125;');
116
- });
117
- this.handlebars.registerHelper('formatFileSize', function (bytes) {
118
- if (bytes === 0)
119
- return '0 B';
120
- const sizes = ['B', 'KB', 'MB', 'GB'];
121
- const i = Math.floor(Math.log(bytes) / Math.log(1024));
122
- return Math.round((bytes / Math.pow(1024, i)) * 100) / 100 + ' ' + sizes[i];
123
- });
124
- }
125
- executeValidation(props, propsSchema, mode) {
126
- try {
127
- return this.propsValidator.validate(props, propsSchema, mode);
128
- }
129
- catch (error) {
130
- if (error instanceof types_1.PropsValidationError && error.errors && error.errors.length > 0) {
131
- const firstError = error.errors[0];
132
- if (firstError) {
133
- throw new types_1.PropsValidationError(firstError.message, error.errors);
134
- }
135
- }
136
- throw error;
137
- }
138
- }
139
- mergeProps(defaultProps, overrides) {
140
- const base = this.cloneDeep(defaultProps ?? {});
141
- if (!overrides)
142
- return base;
143
- return this.deepMerge(base, overrides);
144
- }
145
- deepMerge(target, source) {
146
- for (const [key, value] of Object.entries(source)) {
147
- if (this.isPlainObject(value)) {
148
- const existing = target[key];
149
- target[key] = this.deepMerge(this.isPlainObject(existing) ? existing : {}, value);
150
- continue;
151
- }
152
- if (Array.isArray(value)) {
153
- target[key] = this.cloneDeep(value);
154
- continue;
155
- }
156
- target[key] = value;
157
- }
158
- return target;
159
- }
160
- cloneDeep(value) {
161
- if (Array.isArray(value)) {
162
- return value.map(item => this.cloneDeep(item));
163
- }
164
- if (this.isPlainObject(value)) {
165
- const cloned = {};
166
- for (const [key, nested] of Object.entries(value)) {
167
- cloned[key] = this.cloneDeep(nested);
168
- }
169
- return cloned;
170
- }
171
- return value;
172
- }
173
- isPlainObject(value) {
174
- return typeof value === 'object' && value !== null && !Array.isArray(value);
175
- }
176
- sanitizeVars(vars) {
177
- if (!vars)
178
- return {};
179
- const sanitizedVars = { ...vars };
180
- if (typeof vars.user_input === 'string') {
181
- sanitizedVars.user_input_raw = vars.user_input;
182
- const escapedHandlebars = vars.user_input
183
- .replace(/\{\{\{/g, '&#123;&#123;&#123;')
184
- .replace(/\}\}\}/g, '&#125;&#125;&#125;')
185
- .replace(/\{\{/g, '&#123;&#123;')
186
- .replace(/\}\}/g, '&#125;&#125;');
187
- sanitizedVars.user_input = this.handlebars.escapeExpression(escapedHandlebars);
188
- }
189
- return sanitizedVars;
190
- }
191
- }
192
- exports.LayoutRenderer = LayoutRenderer;
193
- //# sourceMappingURL=renderer.js.map
@@ -1,36 +0,0 @@
1
- "use strict";
2
- /**
3
- * Layout system type definitions for CrewX SDK.
4
- * Ported from packages/sdk-bak/src/types/layout.types.ts (1:1, import path only changed).
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PropsValidationError = exports.LayoutLoadError = void 0;
8
- /**
9
- * Error thrown when layout loading fails.
10
- */
11
- class LayoutLoadError extends Error {
12
- layoutId;
13
- cause;
14
- constructor(message, layoutId, cause) {
15
- super(message);
16
- this.layoutId = layoutId;
17
- this.cause = cause;
18
- this.name = 'LayoutLoadError';
19
- }
20
- }
21
- exports.LayoutLoadError = LayoutLoadError;
22
- /**
23
- * Error thrown when props validation fails (strict mode).
24
- */
25
- class PropsValidationError extends Error {
26
- errors;
27
- cause;
28
- constructor(message, errors = [], cause) {
29
- super(message);
30
- this.errors = errors;
31
- this.cause = cause;
32
- this.name = 'PropsValidationError';
33
- }
34
- }
35
- exports.PropsValidationError = PropsValidationError;
36
- //# sourceMappingURL=types.js.map
@@ -1,25 +0,0 @@
1
- "use strict";
2
- /**
3
- * Minimal AgentRuntime for the parallel execution module.
4
- * Provides query/execute methods to run agent operations.
5
- * Tests use vi.spyOn(AgentRuntime.prototype, 'query') to mock these methods.
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.AgentRuntime = void 0;
9
- /**
10
- * Runtime that executes agent query/execute operations.
11
- * Default implementation throws — callers must inject a working provider
12
- * or mock the prototype methods in tests.
13
- */
14
- class AgentRuntime {
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- async query(_request) {
17
- throw new Error('AgentRuntime.query is not implemented. Provide a subclass or mock AgentRuntime.prototype.query.');
18
- }
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- async execute(_request) {
21
- throw new Error('AgentRuntime.execute is not implemented. Provide a subclass or mock AgentRuntime.prototype.execute.');
22
- }
23
- }
24
- exports.AgentRuntime = AgentRuntime;
25
- //# sourceMappingURL=agent-runtime.js.map