@m6d/cortex-server 1.1.1 → 1.1.2
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/README.md +38 -38
- package/dist/src/factory.d.ts +13 -1
- package/dist/src/ws/index.d.ts +1 -1
- package/package.json +54 -54
- package/src/adapters/database.ts +21 -28
- package/src/adapters/minio.ts +69 -69
- package/src/adapters/mssql.ts +171 -195
- package/src/adapters/storage.ts +4 -4
- package/src/ai/fetch.ts +31 -31
- package/src/ai/helpers.ts +18 -22
- package/src/ai/index.ts +101 -113
- package/src/ai/interceptors/resolve-captured-files.ts +42 -49
- package/src/ai/prompt.ts +80 -83
- package/src/ai/tools/call-endpoint.tool.ts +75 -82
- package/src/ai/tools/capture-files.tool.ts +15 -17
- package/src/ai/tools/execute-code.tool.ts +73 -80
- package/src/ai/tools/query-graph.tool.ts +17 -17
- package/src/auth/middleware.ts +51 -51
- package/src/cli/extract-endpoints.ts +436 -474
- package/src/config.ts +124 -134
- package/src/db/migrate.ts +13 -13
- package/src/db/migrations/20260309012148_cloudy_maria_hill/snapshot.json +303 -303
- package/src/db/schema.ts +46 -58
- package/src/factory.ts +136 -139
- package/src/graph/generate-cypher.ts +97 -97
- package/src/graph/helpers.ts +37 -37
- package/src/graph/index.ts +20 -20
- package/src/graph/neo4j.ts +82 -89
- package/src/graph/resolver.ts +201 -211
- package/src/graph/seed.ts +101 -114
- package/src/graph/types.ts +88 -88
- package/src/graph/validate.ts +55 -57
- package/src/index.ts +5 -5
- package/src/routes/chat.ts +23 -23
- package/src/routes/files.ts +75 -80
- package/src/routes/threads.ts +52 -54
- package/src/routes/ws.ts +22 -22
- package/src/types.ts +30 -30
- package/src/ws/connections.ts +11 -11
- package/src/ws/events.ts +2 -2
- package/src/ws/index.ts +1 -5
- package/src/ws/notify.ts +4 -4
package/src/config.ts
CHANGED
|
@@ -4,153 +4,143 @@ import type { StorageAdapter } from "./adapters/storage";
|
|
|
4
4
|
import type { DomainDef } from "./graph/types.ts";
|
|
5
5
|
|
|
6
6
|
export type KnowledgeConfig = {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
swagger?: { url: string };
|
|
8
|
+
domains?: Record<string, DomainDef>;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export type DatabaseConfig = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
type: "mssql";
|
|
13
|
+
connectionString: string;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export type StorageConfig = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
endPoint: string;
|
|
18
|
+
port: number;
|
|
19
|
+
useSSL: boolean;
|
|
20
|
+
accessKey: string;
|
|
21
|
+
secretKey: string;
|
|
22
|
+
bucketName?: string;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export type CortexAgentDefinition = {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
) => Promise<Record<string, unknown>>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
reranker?: {
|
|
67
|
-
url: string;
|
|
68
|
-
apiKey: string;
|
|
69
|
-
};
|
|
70
|
-
knowledge?: KnowledgeConfig | null;
|
|
26
|
+
systemPrompt: string | ((session: Record<string, unknown> | null) => string | Promise<string>);
|
|
27
|
+
tools?: Record<string, unknown>;
|
|
28
|
+
backendFetch?: {
|
|
29
|
+
baseUrl: string;
|
|
30
|
+
apiKey: string;
|
|
31
|
+
headers?: Record<string, string>;
|
|
32
|
+
transformRequestBody?: (
|
|
33
|
+
body: Record<string, unknown>,
|
|
34
|
+
context: { token: string },
|
|
35
|
+
) => Promise<Record<string, unknown>>;
|
|
36
|
+
};
|
|
37
|
+
loadSessionData?: (token: string) => Promise<Record<string, unknown>>;
|
|
38
|
+
onToolCall?: (toolCall: {
|
|
39
|
+
toolName: string;
|
|
40
|
+
toolCallId: string;
|
|
41
|
+
args: Record<string, unknown>;
|
|
42
|
+
}) => void;
|
|
43
|
+
onStreamFinish?: (result: { messages: UIMessage[]; isAborted: boolean }) => void;
|
|
44
|
+
model?: {
|
|
45
|
+
baseURL: string;
|
|
46
|
+
apiKey: string;
|
|
47
|
+
modelName: string;
|
|
48
|
+
providerName?: string;
|
|
49
|
+
};
|
|
50
|
+
embedding?: {
|
|
51
|
+
baseURL: string;
|
|
52
|
+
apiKey: string;
|
|
53
|
+
modelName: string;
|
|
54
|
+
dimension: number;
|
|
55
|
+
};
|
|
56
|
+
neo4j?: {
|
|
57
|
+
url: string;
|
|
58
|
+
user: string;
|
|
59
|
+
password: string;
|
|
60
|
+
};
|
|
61
|
+
reranker?: {
|
|
62
|
+
url: string;
|
|
63
|
+
apiKey: string;
|
|
64
|
+
};
|
|
65
|
+
knowledge?: KnowledgeConfig | null;
|
|
71
66
|
};
|
|
72
67
|
|
|
73
68
|
export type ResolvedCortexAgentConfig = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
) => Promise<Record<string, unknown>>;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onStreamFinish?: (result: {
|
|
117
|
-
messages: UIMessage[];
|
|
118
|
-
isAborted: boolean;
|
|
119
|
-
}) => void;
|
|
120
|
-
knowledge?: KnowledgeConfig;
|
|
69
|
+
db: DatabaseAdapter;
|
|
70
|
+
storage: StorageAdapter;
|
|
71
|
+
model: {
|
|
72
|
+
baseURL: string;
|
|
73
|
+
apiKey: string;
|
|
74
|
+
modelName: string;
|
|
75
|
+
providerName?: string;
|
|
76
|
+
};
|
|
77
|
+
embedding: {
|
|
78
|
+
baseURL: string;
|
|
79
|
+
apiKey: string;
|
|
80
|
+
modelName: string;
|
|
81
|
+
dimension: number;
|
|
82
|
+
};
|
|
83
|
+
neo4j: {
|
|
84
|
+
url: string;
|
|
85
|
+
user: string;
|
|
86
|
+
password: string;
|
|
87
|
+
};
|
|
88
|
+
reranker?: {
|
|
89
|
+
url: string;
|
|
90
|
+
apiKey: string;
|
|
91
|
+
};
|
|
92
|
+
systemPrompt: string | ((session: Record<string, unknown> | null) => string | Promise<string>);
|
|
93
|
+
tools?: Record<string, unknown>;
|
|
94
|
+
backendFetch?: {
|
|
95
|
+
baseUrl: string;
|
|
96
|
+
apiKey: string;
|
|
97
|
+
headers?: Record<string, string>;
|
|
98
|
+
transformRequestBody?: (
|
|
99
|
+
body: Record<string, unknown>,
|
|
100
|
+
context: { token: string },
|
|
101
|
+
) => Promise<Record<string, unknown>>;
|
|
102
|
+
};
|
|
103
|
+
loadSessionData?: (token: string) => Promise<Record<string, unknown>>;
|
|
104
|
+
onToolCall?: (toolCall: {
|
|
105
|
+
toolName: string;
|
|
106
|
+
toolCallId: string;
|
|
107
|
+
args: Record<string, unknown>;
|
|
108
|
+
}) => void;
|
|
109
|
+
onStreamFinish?: (result: { messages: UIMessage[]; isAborted: boolean }) => void;
|
|
110
|
+
knowledge?: KnowledgeConfig;
|
|
121
111
|
};
|
|
122
112
|
|
|
123
113
|
export type CortexConfig = {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
114
|
+
port?: number;
|
|
115
|
+
database: DatabaseConfig;
|
|
116
|
+
storage: StorageConfig;
|
|
117
|
+
auth: {
|
|
118
|
+
jwksUri: string;
|
|
119
|
+
issuer: string;
|
|
120
|
+
tokenExtractor?: (req: Request) => string | null;
|
|
121
|
+
cookieName?: string;
|
|
122
|
+
};
|
|
123
|
+
model: {
|
|
124
|
+
baseURL: string;
|
|
125
|
+
apiKey: string;
|
|
126
|
+
modelName: string;
|
|
127
|
+
providerName?: string;
|
|
128
|
+
};
|
|
129
|
+
embedding: {
|
|
130
|
+
baseURL: string;
|
|
131
|
+
apiKey: string;
|
|
132
|
+
modelName: string;
|
|
133
|
+
dimension: number;
|
|
134
|
+
};
|
|
135
|
+
neo4j: {
|
|
136
|
+
url: string;
|
|
137
|
+
user: string;
|
|
138
|
+
password: string;
|
|
139
|
+
};
|
|
140
|
+
reranker?: {
|
|
141
|
+
url: string;
|
|
142
|
+
apiKey: string;
|
|
143
|
+
};
|
|
144
|
+
knowledge?: KnowledgeConfig;
|
|
145
|
+
agents: Record<string, CortexAgentDefinition>;
|
|
156
146
|
};
|
package/src/db/migrate.ts
CHANGED
|
@@ -4,18 +4,18 @@ import { migrate } from "drizzle-orm/node-mssql/migrator";
|
|
|
4
4
|
import { resolve } from "path";
|
|
5
5
|
|
|
6
6
|
export async function runMigrations(connectionString: string) {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const pool = new mssql.ConnectionPool(connectionString);
|
|
8
|
+
await pool.connect();
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
try {
|
|
11
|
+
const db = drizzle({ client: pool, casing: "snake_case" });
|
|
12
|
+
const migrationsFolder = resolve(import.meta.dir, "migrations");
|
|
13
|
+
console.log("[cortex-server] Running migrations from:", migrationsFolder);
|
|
14
|
+
await migrate(db, { migrationsFolder });
|
|
15
|
+
console.log("[cortex-server] Migrations complete");
|
|
16
|
+
} catch (e) {
|
|
17
|
+
console.log(e);
|
|
18
|
+
} finally {
|
|
19
|
+
await pool.close();
|
|
20
|
+
}
|
|
21
21
|
}
|