@siduri-x/api 1.0.2 → 1.0.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/app.d.ts +43 -0
- package/dist/app.js +637 -0
- package/dist/auth.d.ts +34 -0
- package/dist/auth.js +84 -0
- package/dist/auth.test.d.ts +1 -0
- package/dist/auth.test.js +74 -0
- package/dist/b0-b6.test.d.ts +1 -0
- package/dist/b0-b6.test.js +121 -0
- package/dist/context-mapper.d.ts +18 -0
- package/dist/context-mapper.js +160 -0
- package/dist/context-mapper.test.d.ts +1 -0
- package/dist/context-mapper.test.js +136 -0
- package/dist/cors.d.ts +3 -0
- package/dist/cors.js +42 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +191 -0
- package/dist/index.test.d.ts +1 -0
- package/dist/index.test.js +137 -0
- package/dist/runtime.d.ts +1 -0
- package/dist/runtime.js +17 -0
- package/dist/runtime.test.d.ts +1 -0
- package/dist/runtime.test.js +282 -0
- package/dist/smoke.test.d.ts +0 -0
- package/dist/smoke.test.js +6 -0
- package/dist/t4-gating.test.d.ts +1 -0
- package/dist/t4-gating.test.js +193 -0
- package/dist/t5-experience.test.d.ts +1 -0
- package/dist/t5-experience.test.js +155 -0
- package/dist/t6-security.test.d.ts +1 -0
- package/dist/t6-security.test.js +423 -0
- package/dist/t7-release.test.d.ts +1 -0
- package/dist/t7-release.test.js +119 -0
- package/package.json +14 -11
- package/src/app.ts +36 -64
- package/src/auth.test.ts +56 -23
- package/src/auth.ts +74 -22
- package/src/context-mapper.test.ts +42 -147
- package/src/context-mapper.ts +44 -179
- package/src/index.test.ts +8 -32
- package/src/index.ts +19 -3
- package/src/runtime.test.ts +3 -5
- package/src/t5-experience.test.ts +0 -1
- package/src/t6-security.test.ts +0 -1
package/src/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Express } from 'express';
|
|
|
4
4
|
import { createApp, AppInstance, AppBrainConfig, AppBehaviorConfig } from './app';
|
|
5
5
|
import { SiduriRuntime } from './runtime';
|
|
6
6
|
import { OpenAICompatibleBrain, OpenRouterBrain } from '@siduri-x/brain';
|
|
7
|
-
import { PostgresMemoryOrgan } from '@siduri-x/memory';
|
|
7
|
+
import { PostgresMemoryOrgan, InMemoryMemoryOrgan } from '@siduri-x/memory';
|
|
8
8
|
import { VoiceAdapter, VoiceConfig } from '@siduri-x/voice';
|
|
9
9
|
import { EKnowledgeAdapter, EKnowledgeConfig } from '@siduri-x/knowledge';
|
|
10
10
|
import { OpenRouterVisionAdapter, OpenRouterVisionConfig } from '@siduri-x/vision';
|
|
@@ -77,6 +77,20 @@ function createBody(config?: Live2DAdapterConfig & { provider?: string }) {
|
|
|
77
77
|
: new Live2DAdapter(config);
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
function createMemory(config?: { provider?: string; connectionString?: string; maxConnections?: number }) {
|
|
81
|
+
if (isDisabled(config)) return undefined;
|
|
82
|
+
const provider = config?.provider || 'postgres';
|
|
83
|
+
if (provider === 'in-memory') {
|
|
84
|
+
return new InMemoryMemoryOrgan();
|
|
85
|
+
}
|
|
86
|
+
if (provider === 'postgres') {
|
|
87
|
+
const connectionString =
|
|
88
|
+
config?.connectionString || process.env.DATABASE_URL || 'postgresql://postgres:postgres@localhost:5432/siduri';
|
|
89
|
+
return new PostgresMemoryOrgan({ connectionString, maxConnections: config?.maxConnections });
|
|
90
|
+
}
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
|
|
80
94
|
const PORT = process.env.PORT || 3001;
|
|
81
95
|
|
|
82
96
|
const defaultCompanionConfig = {
|
|
@@ -138,7 +152,7 @@ async function bootDefaultCompanion() {
|
|
|
138
152
|
const config: any = await loadCompanionConfig();
|
|
139
153
|
|
|
140
154
|
const brain = createBrain(config.brain);
|
|
141
|
-
const memory =
|
|
155
|
+
const memory = createMemory(config.memory);
|
|
142
156
|
const voice = createVoice(config.voice);
|
|
143
157
|
const knowledge = createKnowledge(config.knowledge);
|
|
144
158
|
const vision = createVision(config.vision);
|
|
@@ -149,7 +163,9 @@ async function bootDefaultCompanion() {
|
|
|
149
163
|
const behavior = createBehavior(config.behavior);
|
|
150
164
|
const body = createBody(config.body);
|
|
151
165
|
|
|
152
|
-
|
|
166
|
+
if (memory && typeof (memory as any).runMigrations === 'function') {
|
|
167
|
+
await (memory as any).runMigrations().catch((e: any) => console.warn("Migrations warning:", e.message));
|
|
168
|
+
}
|
|
153
169
|
|
|
154
170
|
const runtime = new SiduriRuntime('default', config as any, { brain, memory, voice, knowledge, vision, behavior, body });
|
|
155
171
|
await runtime.initialize();
|
package/src/runtime.test.ts
CHANGED
|
@@ -79,7 +79,7 @@ describe('Siduri Runtime Orchestration', () => {
|
|
|
79
79
|
expect(noKnowledgeContext).toBe(true);
|
|
80
80
|
expect(proposedClaims.length).toBe(1);
|
|
81
81
|
expect(proposedClaims[0].subject).toBe("Test");
|
|
82
|
-
expect(proposedClaims[0].scope).toBe("
|
|
82
|
+
expect(proposedClaims[0].scope).toBe("user");
|
|
83
83
|
expect(response.metadata.memory_proposals[0].proposal_id).toBe("claim-1");
|
|
84
84
|
});
|
|
85
85
|
|
|
@@ -95,7 +95,7 @@ describe('Siduri Runtime Orchestration', () => {
|
|
|
95
95
|
riskLevel: 'LOW',
|
|
96
96
|
requiredCapabilities: ['chat:public'],
|
|
97
97
|
},
|
|
98
|
-
execute: async (params) => {
|
|
98
|
+
execute: async (params: any) => {
|
|
99
99
|
toolExecuted = true;
|
|
100
100
|
return { hits: [`Result for ${params.query}`] };
|
|
101
101
|
},
|
|
@@ -147,7 +147,6 @@ describe('Siduri Runtime Orchestration', () => {
|
|
|
147
147
|
},
|
|
148
148
|
conversation: {
|
|
149
149
|
channel: 'direct',
|
|
150
|
-
audienceId: 'audience-direct',
|
|
151
150
|
correlationId: 'corr-alice-123',
|
|
152
151
|
},
|
|
153
152
|
};
|
|
@@ -234,7 +233,6 @@ describe('Siduri Runtime Orchestration', () => {
|
|
|
234
233
|
},
|
|
235
234
|
conversation: {
|
|
236
235
|
channel: 'public',
|
|
237
|
-
audienceId: 'audience-public',
|
|
238
236
|
correlationId: 'corr-bob-999',
|
|
239
237
|
},
|
|
240
238
|
};
|
|
@@ -291,7 +289,7 @@ describe('Siduri Runtime Orchestration', () => {
|
|
|
291
289
|
id: 'test-web-channel',
|
|
292
290
|
name: 'Web Channel',
|
|
293
291
|
medium: 'web',
|
|
294
|
-
deliver: async (out) => {
|
|
292
|
+
deliver: async (out: any) => {
|
|
295
293
|
deliveredOutput = out;
|
|
296
294
|
},
|
|
297
295
|
},
|
|
@@ -161,7 +161,6 @@ describe('T5 Experience Event and Output Adapters Suite', () => {
|
|
|
161
161
|
responseId: 'resp-1',
|
|
162
162
|
correlationId: 'corr-1',
|
|
163
163
|
channel: 'public' as const,
|
|
164
|
-
audienceId: 'audience-public',
|
|
165
164
|
approval: 'STAGED' as any, // Not approved!
|
|
166
165
|
kind: 'voice' as const,
|
|
167
166
|
lifecycle: 'STARTED' as const,
|
package/src/t6-security.test.ts
CHANGED