@aeon-ai/aeonjs 0.0.0
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 +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/package.json +23 -0
- package/src/index.ts +70 -0
- package/tsconfig.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Message = {
|
|
2
|
+
role: string;
|
|
3
|
+
content: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
export default class Aeon {
|
|
7
|
+
private static apiKey;
|
|
8
|
+
private static projectId;
|
|
9
|
+
private static endpoint;
|
|
10
|
+
private static initialized;
|
|
11
|
+
constructor(apiKey: string, projectId: number, endpoint?: string);
|
|
12
|
+
trackConversation({ conversationId, provider, model, messages, }: {
|
|
13
|
+
conversationId: string;
|
|
14
|
+
provider: string;
|
|
15
|
+
model: string;
|
|
16
|
+
messages: Message[];
|
|
17
|
+
}): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,OAAO,CAAC,MAAM,CAAC,MAAM,CAAS;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAS;IACjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAkC;IACzD,OAAO,CAAC,MAAM,CAAC,WAAW,CAAS;gBAGjC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,QAAQ,GAAE,MAA+B;IAcrC,iBAAiB,CAAC,EACtB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,QAAQ,GACT,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,EAAE,CAAC;KACrB;CA8BF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
class Aeon {
|
|
2
|
+
constructor(apiKey, projectId, endpoint = "https://withaeon.com") {
|
|
3
|
+
if (Aeon.initialized) {
|
|
4
|
+
throw new Error("Aeon has already been initialized");
|
|
5
|
+
}
|
|
6
|
+
Aeon.initialized = true;
|
|
7
|
+
Aeon.apiKey = apiKey;
|
|
8
|
+
Aeon.projectId = projectId;
|
|
9
|
+
Aeon.endpoint = endpoint;
|
|
10
|
+
console.log("Aeon initialized with endpoint:", Aeon.endpoint);
|
|
11
|
+
}
|
|
12
|
+
async trackConversation({ conversationId, provider, model, messages, }) {
|
|
13
|
+
if (!Aeon.apiKey || !Aeon.projectId) {
|
|
14
|
+
throw new Error("Missing credentials");
|
|
15
|
+
}
|
|
16
|
+
if (messages.length >= 40) {
|
|
17
|
+
throw new Error("Reached messages limit");
|
|
18
|
+
}
|
|
19
|
+
try {
|
|
20
|
+
await fetch(`${Aeon.endpoint}/api/v1/projects/${Aeon.projectId}/agents/conversations`, {
|
|
21
|
+
method: "POST",
|
|
22
|
+
headers: {
|
|
23
|
+
"Content-Type": "application/json",
|
|
24
|
+
Authorization: Aeon.apiKey,
|
|
25
|
+
},
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
conversation_id: conversationId,
|
|
28
|
+
provider,
|
|
29
|
+
model,
|
|
30
|
+
messages,
|
|
31
|
+
}),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
console.error("Aeon error:", e);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
Aeon.endpoint = "https://withaeon.com";
|
|
40
|
+
Aeon.initialized = false;
|
|
41
|
+
export default Aeon;
|
|
42
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,MAAqB,IAAI;IAMvB,YACE,MAAc,EACd,SAAiB,EACjB,WAAmB,sBAAsB;QAEzC,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,EACtB,cAAc,EACd,QAAQ,EACR,KAAK,EACL,QAAQ,GAMT;QACC,IAAI,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC;YACpC,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QACzC,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC;YACH,MAAM,KAAK,CACT,GAAG,IAAI,CAAC,QAAQ,oBAAoB,IAAI,CAAC,SAAS,uBAAuB,EACzE;gBACE,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;oBAClC,aAAa,EAAE,IAAI,CAAC,MAAM;iBAC3B;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,eAAe,EAAE,cAAc;oBAC/B,QAAQ;oBACR,KAAK;oBACL,QAAQ;iBACT,CAAC;aACH,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;;AA3Dc,aAAQ,GAAW,sBAAsB,CAAC;AAC1C,gBAAW,GAAG,KAAK,CAAC;eAJhB,IAAI"}
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aeon-ai/aeonjs",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"build": "tsc",
|
|
18
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"typescript": "^5.9.3"
|
|
22
|
+
}
|
|
23
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export type Message = {
|
|
2
|
+
role: string;
|
|
3
|
+
content: string;
|
|
4
|
+
timestamp: number;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export default class Aeon {
|
|
8
|
+
private static apiKey: string;
|
|
9
|
+
private static projectId: number;
|
|
10
|
+
private static endpoint: string = "https://withaeon.com";
|
|
11
|
+
private static initialized = false;
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
apiKey: string,
|
|
15
|
+
projectId: number,
|
|
16
|
+
endpoint: string = "https://withaeon.com"
|
|
17
|
+
) {
|
|
18
|
+
if (Aeon.initialized) {
|
|
19
|
+
throw new Error("Aeon has already been initialized");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
Aeon.initialized = true;
|
|
23
|
+
Aeon.apiKey = apiKey;
|
|
24
|
+
Aeon.projectId = projectId;
|
|
25
|
+
Aeon.endpoint = endpoint;
|
|
26
|
+
|
|
27
|
+
console.log("Aeon initialized with endpoint:", Aeon.endpoint);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async trackConversation({
|
|
31
|
+
conversationId,
|
|
32
|
+
provider,
|
|
33
|
+
model,
|
|
34
|
+
messages,
|
|
35
|
+
}: {
|
|
36
|
+
conversationId: string;
|
|
37
|
+
provider: string;
|
|
38
|
+
model: string;
|
|
39
|
+
messages: Message[];
|
|
40
|
+
}) {
|
|
41
|
+
if (!Aeon.apiKey || !Aeon.projectId) {
|
|
42
|
+
throw new Error("Missing credentials");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (messages.length >= 40) {
|
|
46
|
+
throw new Error("Reached messages limit");
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
try {
|
|
50
|
+
await fetch(
|
|
51
|
+
`${Aeon.endpoint}/api/v1/projects/${Aeon.projectId}/agents/conversations`,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
headers: {
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
Authorization: Aeon.apiKey,
|
|
57
|
+
},
|
|
58
|
+
body: JSON.stringify({
|
|
59
|
+
conversation_id: conversationId,
|
|
60
|
+
provider,
|
|
61
|
+
model,
|
|
62
|
+
messages,
|
|
63
|
+
}),
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
} catch (e) {
|
|
67
|
+
console.error("Aeon error:", e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
// Visit https://aka.ms/tsconfig to read more about this file
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
// File Layout
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
|
|
8
|
+
// Environment Settings
|
|
9
|
+
// See also https://aka.ms/tsconfig/module
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"target": "es2020",
|
|
12
|
+
"types": [],
|
|
13
|
+
// For nodejs:
|
|
14
|
+
// "lib": ["esnext"],
|
|
15
|
+
// "types": ["node"],
|
|
16
|
+
// and npm install -D @types/node
|
|
17
|
+
|
|
18
|
+
// Other Outputs
|
|
19
|
+
"sourceMap": true,
|
|
20
|
+
"declaration": true,
|
|
21
|
+
"declarationMap": true,
|
|
22
|
+
|
|
23
|
+
// Stricter Typechecking Options
|
|
24
|
+
"noUncheckedIndexedAccess": true,
|
|
25
|
+
"exactOptionalPropertyTypes": true,
|
|
26
|
+
|
|
27
|
+
// Style Options
|
|
28
|
+
// "noImplicitReturns": true,
|
|
29
|
+
// "noImplicitOverride": true,
|
|
30
|
+
// "noUnusedLocals": true,
|
|
31
|
+
// "noUnusedParameters": true,
|
|
32
|
+
// "noFallthroughCasesInSwitch": true,
|
|
33
|
+
// "noPropertyAccessFromIndexSignature": true,
|
|
34
|
+
|
|
35
|
+
// Recommended Options
|
|
36
|
+
"esModuleInterop": true,
|
|
37
|
+
"strict": true,
|
|
38
|
+
"jsx": "react-jsx",
|
|
39
|
+
"verbatimModuleSyntax": true,
|
|
40
|
+
"isolatedModules": true,
|
|
41
|
+
"noUncheckedSideEffectImports": true,
|
|
42
|
+
"moduleDetection": "force",
|
|
43
|
+
"skipLibCheck": true,
|
|
44
|
+
}
|
|
45
|
+
}
|