@sidurijs/api 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
 
2
- > @sidurijs/api@1.0.2 build /home/zagin/Projects/vxnus-studio/projects/siduri-x/apps/api
2
+ > @sidurijs/api@1.0.4 build /home/zagin/Projects/vxnus-studio/projects/siduri-x/apps/api
3
3
  > tsc
4
4
 
@@ -1,9 +1,13 @@
1
1
 
2
- > @sidurijs/api@1.0.1 test /home/zagin/Projects/vxnus-studio/projects/siduri-x/apps/api
2
+ > @sidurijs/api@1.0.4 test /home/zagin/Projects/vxnus-studio/projects/siduri-x/apps/api
3
3
  > jest --config jest.config.json
4
4
 
5
- PASS src/context-mapper.test.ts (6.742 s)
6
- PASS src/runtime.test.ts (7.635 s)
5
+ PASS src/context-mapper.test.ts (14.72 s)
6
+ PASS src/knowledge.test.ts (18.588 s)
7
+ PASS src/index.test.ts
8
+ PASS src/t6-security.test.ts (17.383 s)
9
+ PASS src/teach-mode.test.ts (18.646 s)
10
+ PASS src/runtime.test.ts (17.892 s)
7
11
  ● Console
8
12
 
9
13
  console.error
@@ -25,20 +29,16 @@ PASS src/runtime.test.ts (7.635 s)
25
29
  at PerceptionPipeline.execute (../../packages/core/dist/perception-pipeline.js:21:34)
26
30
  at Object.<anonymous> (src/runtime.test.ts:74:22)
27
31
 
28
- PASS src/t7-release.test.ts
29
- PASS src/b0-b6.test.ts
30
- PASS src/index.test.ts
31
32
  PASS src/auth.test.ts
32
33
  PASS src/smoke.test.ts
33
- PASS src/knowledge.test.ts (9.111 s)
34
34
  PASS src/boot.test.ts
35
- PASS src/t4-gating.test.ts (9.041 s)
36
- PASS src/teach-mode.test.ts (9.014 s)
37
- PASS src/t6-security.test.ts (9.098 s)
38
- PASS src/t5-experience.test.ts (9.227 s)
35
+ PASS src/b0-b6.test.ts
36
+ PASS src/t7-release.test.ts
37
+ PASS src/t4-gating.test.ts (18.564 s)
38
+ PASS src/t5-experience.test.ts (18.36 s)
39
39
  
40
40
  Test Suites: 13 passed, 13 total
41
41
  Tests: 95 passed, 95 total
42
42
  Snapshots: 0 total
43
- Time: 10.494 s, estimated 14 s
43
+ Time: 22.109 s, estimated 25 s
44
44
  Ran all test suites.
package/dist/app.js CHANGED
@@ -150,8 +150,19 @@ function createApp(runtimes = new Map()) {
150
150
  const parsed = await (0, self_1.compilePersonaDocument)(content, {
151
151
  brain: runtime?.brain,
152
152
  companionId,
153
- fallbackToParser: true,
153
+ fallbackToParser: false,
154
154
  });
155
+ if (!parsed.isValid) {
156
+ return res.json({
157
+ detected: true,
158
+ filename: node_path_1.default.basename(matchedFilePath),
159
+ path: matchedFilePath,
160
+ content,
161
+ parsed,
162
+ error: parsed.errors?.[0] || 'Brain compilation failed',
163
+ alreadyInstalled: false,
164
+ });
165
+ }
155
166
  let alreadyInstalled = false;
156
167
  const repo = new self_1.SqliteSelfRepository({ dbPath: process.env.STORAGE_PATH || process.env.SQLITE_DB_PATH || 'siduri.sqlite' });
157
168
  try {
@@ -191,8 +202,14 @@ function createApp(runtimes = new Map()) {
191
202
  const parsed = await (0, self_1.compilePersonaDocument)(content, {
192
203
  brain: runtime?.brain,
193
204
  companionId: targetId,
194
- fallbackToParser: true,
205
+ fallbackToParser: false,
195
206
  });
207
+ if (!parsed.isValid) {
208
+ return res.status(200).json({
209
+ error: parsed.errors?.[0] || 'Brain compilation failed',
210
+ ...parsed,
211
+ });
212
+ }
196
213
  res.json(parsed);
197
214
  }
198
215
  catch (e) {
@@ -29,7 +29,29 @@ describe('Teach Mode API', () => {
29
29
  const mockAuthHeader = { 'Authorization': 'Bearer test-token' };
30
30
  beforeAll(() => {
31
31
  process.env.AUTH_TOKEN = 'test-token';
32
- const instance = (0, app_1.createApp)(new Map());
32
+ const defaultMockBrain = {
33
+ generatePlan: jest.fn(),
34
+ compilePersona: jest.fn().mockImplementation(async (content) => {
35
+ if (content.includes('kind: "other"')) {
36
+ return { isValid: false, manifest: null, errors: ['Invalid persona manifest'] };
37
+ }
38
+ return {
39
+ isValid: true,
40
+ greeting: 'Hello from Test Bot!',
41
+ manifest: {
42
+ id: 'test-bot',
43
+ name: 'Test Bot',
44
+ version: '1.0.0',
45
+ identity: { name: 'Test Bot' },
46
+ directives: [
47
+ { id: 'dir-1', directive: 'Be helpful', category: 'behavioral' },
48
+ { id: 'dir-2', directive: 'Execute system commands', category: 'behavioral' },
49
+ ],
50
+ },
51
+ };
52
+ }),
53
+ };
54
+ const instance = (0, app_1.createApp)(new Map([['default', { id: 'default', brain: defaultMockBrain }]]));
33
55
  app = instance.app;
34
56
  });
35
57
  afterAll(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sidurijs/api",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -12,18 +12,18 @@
12
12
  "cors": "^2.8.6",
13
13
  "dotenv": "^17.4.2",
14
14
  "express": "^5.2.1",
15
- "@sidurijs/body": "1.0.0",
16
- "@sidurijs/brain": "1.0.1",
17
- "@sidurijs/core": "1.0.2",
18
- "@sidurijs/ear": "1.0.0",
19
- "@sidurijs/hands": "1.0.0",
20
- "@sidurijs/knowledge": "1.0.0",
21
- "@sidurijs/archive": "1.0.1",
22
- "@sidurijs/mouth": "1.0.0",
23
- "@sidurijs/observation": "1.0.0",
24
- "@sidurijs/self": "1.0.0",
25
- "@sidurijs/vision": "1.0.0",
26
- "@sidurijs/voice": "1.0.0"
15
+ "@sidurijs/body": "1.0.1",
16
+ "@sidurijs/brain": "1.0.3",
17
+ "@sidurijs/core": "1.0.4",
18
+ "@sidurijs/ear": "1.0.1",
19
+ "@sidurijs/hands": "1.0.1",
20
+ "@sidurijs/knowledge": "1.0.2",
21
+ "@sidurijs/archive": "1.0.2",
22
+ "@sidurijs/mouth": "1.0.1",
23
+ "@sidurijs/observation": "1.0.1",
24
+ "@sidurijs/self": "1.0.2",
25
+ "@sidurijs/vision": "1.0.1",
26
+ "@sidurijs/voice": "1.0.1"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/cors": "^2.8.19",
package/src/app.ts CHANGED
@@ -173,9 +173,21 @@ export function createApp(runtimes: Map<string, SiduriRuntime> = new Map()): App
173
173
  const parsed = await compilePersonaDocument(content, {
174
174
  brain: runtime?.brain,
175
175
  companionId,
176
- fallbackToParser: true,
176
+ fallbackToParser: false,
177
177
  });
178
178
 
179
+ if (!parsed.isValid) {
180
+ return res.json({
181
+ detected: true,
182
+ filename: path.basename(matchedFilePath),
183
+ path: matchedFilePath,
184
+ content,
185
+ parsed,
186
+ error: parsed.errors?.[0] || 'Brain compilation failed',
187
+ alreadyInstalled: false,
188
+ });
189
+ }
190
+
179
191
  let alreadyInstalled = false;
180
192
  const repo = new SqliteSelfRepository({ dbPath: process.env.STORAGE_PATH || process.env.SQLITE_DB_PATH || 'siduri.sqlite' });
181
193
  try {
@@ -215,8 +227,14 @@ export function createApp(runtimes: Map<string, SiduriRuntime> = new Map()): App
215
227
  const parsed = await compilePersonaDocument(content, {
216
228
  brain: runtime?.brain,
217
229
  companionId: targetId,
218
- fallbackToParser: true,
230
+ fallbackToParser: false,
219
231
  });
232
+ if (!parsed.isValid) {
233
+ return res.status(200).json({
234
+ error: parsed.errors?.[0] || 'Brain compilation failed',
235
+ ...parsed,
236
+ });
237
+ }
220
238
  res.json(parsed);
221
239
  } catch (e: any) {
222
240
  res.status(500).json({ error: e.message });
@@ -27,7 +27,29 @@ describe('Teach Mode API', () => {
27
27
 
28
28
  beforeAll(() => {
29
29
  process.env.AUTH_TOKEN = 'test-token';
30
- const instance = createApp(new Map());
30
+ const defaultMockBrain = {
31
+ generatePlan: jest.fn(),
32
+ compilePersona: jest.fn().mockImplementation(async (content: string) => {
33
+ if (content.includes('kind: "other"')) {
34
+ return { isValid: false, manifest: null, errors: ['Invalid persona manifest'] };
35
+ }
36
+ return {
37
+ isValid: true,
38
+ greeting: 'Hello from Test Bot!',
39
+ manifest: {
40
+ id: 'test-bot',
41
+ name: 'Test Bot',
42
+ version: '1.0.0',
43
+ identity: { name: 'Test Bot' },
44
+ directives: [
45
+ { id: 'dir-1', directive: 'Be helpful', category: 'behavioral' },
46
+ { id: 'dir-2', directive: 'Execute system commands', category: 'behavioral' },
47
+ ],
48
+ },
49
+ };
50
+ }),
51
+ };
52
+ const instance = createApp(new Map([['default', { id: 'default', brain: defaultMockBrain }]]) as any);
31
53
  app = instance.app;
32
54
  });
33
55