@aeon-ai/aeonjs 0.0.0 → 0.0.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/dist/index.d.ts CHANGED
@@ -4,16 +4,17 @@ export type Message = {
4
4
  timestamp: number;
5
5
  };
6
6
  export default class Aeon {
7
- private static apiKey;
8
- private static projectId;
9
- private static endpoint;
7
+ private apiKey;
8
+ private projectId;
9
+ private endpoint;
10
10
  private static initialized;
11
11
  constructor(apiKey: string, projectId: number, endpoint?: string);
12
- trackConversation({ conversationId, provider, model, messages, }: {
12
+ trackConversation({ conversationId, provider, model, messages, userId, }: {
13
13
  conversationId: string;
14
14
  provider: string;
15
15
  model: string;
16
16
  messages: Message[];
17
+ userId?: string;
17
18
  }): Promise<void>;
18
19
  }
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
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,CAAS;IACvB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,QAAQ,CAAkC;IAClD,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,EACR,MAAM,GACP,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,OAAO,EAAE,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAkCF"}
package/dist/index.js CHANGED
@@ -1,42 +1,45 @@
1
1
  class Aeon {
2
2
  constructor(apiKey, projectId, endpoint = "https://withaeon.com") {
3
+ this.endpoint = "https://withaeon.com";
3
4
  if (Aeon.initialized) {
4
5
  throw new Error("Aeon has already been initialized");
5
6
  }
6
7
  Aeon.initialized = true;
7
- Aeon.apiKey = apiKey;
8
- Aeon.projectId = projectId;
9
- Aeon.endpoint = endpoint;
10
- console.log("Aeon initialized with endpoint:", Aeon.endpoint);
8
+ this.apiKey = apiKey;
9
+ this.projectId = projectId;
10
+ this.endpoint = endpoint;
11
+ console.log("Aeon initialized with endpoint:", this.endpoint);
11
12
  }
12
- async trackConversation({ conversationId, provider, model, messages, }) {
13
- if (!Aeon.apiKey || !Aeon.projectId) {
13
+ async trackConversation({ conversationId, provider, model, messages, userId, }) {
14
+ if (!this.apiKey || !this.projectId) {
14
15
  throw new Error("Missing credentials");
15
16
  }
16
- if (messages.length >= 40) {
17
- throw new Error("Reached messages limit");
18
- }
19
17
  try {
20
- await fetch(`${Aeon.endpoint}/api/v1/projects/${Aeon.projectId}/agents/conversations`, {
18
+ const res = await fetch(`${this.endpoint}/api/v1/projects/${this.projectId}/agents/conversations`, {
21
19
  method: "POST",
22
20
  headers: {
23
21
  "Content-Type": "application/json",
24
- Authorization: Aeon.apiKey,
22
+ Authorization: this.apiKey,
25
23
  },
26
24
  body: JSON.stringify({
27
25
  conversation_id: conversationId,
28
26
  provider,
29
27
  model,
30
28
  messages,
29
+ user_id: userId,
31
30
  }),
32
31
  });
32
+ if (!res.ok) {
33
+ const text = await res.text();
34
+ throw new Error(`Aeon HTTP error ${res.status}: ${text}`);
35
+ }
36
+ console.log("Conversation tracked successfully");
33
37
  }
34
38
  catch (e) {
35
39
  console.error("Aeon error:", e);
36
40
  }
37
41
  }
38
42
  }
39
- Aeon.endpoint = "https://withaeon.com";
40
43
  Aeon.initialized = false;
41
44
  export default Aeon;
42
45
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +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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;;AAhEc,gBAAW,GAAG,KAAK,AAAR,CAAS;eAJhB,IAAI"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeon-ai/aeonjs",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",
package/src/index.ts CHANGED
@@ -5,26 +5,26 @@ export type Message = {
5
5
  };
6
6
 
7
7
  export default class Aeon {
8
- private static apiKey: string;
9
- private static projectId: number;
10
- private static endpoint: string = "https://withaeon.com";
8
+ private apiKey: string;
9
+ private projectId: number;
10
+ private endpoint: string = "https://withaeon.com";
11
11
  private static initialized = false;
12
12
 
13
13
  constructor(
14
14
  apiKey: string,
15
15
  projectId: number,
16
- endpoint: string = "https://withaeon.com"
16
+ endpoint: string = "https://withaeon.com",
17
17
  ) {
18
18
  if (Aeon.initialized) {
19
19
  throw new Error("Aeon has already been initialized");
20
20
  }
21
21
 
22
22
  Aeon.initialized = true;
23
- Aeon.apiKey = apiKey;
24
- Aeon.projectId = projectId;
25
- Aeon.endpoint = endpoint;
23
+ this.apiKey = apiKey;
24
+ this.projectId = projectId;
25
+ this.endpoint = endpoint;
26
26
 
27
- console.log("Aeon initialized with endpoint:", Aeon.endpoint);
27
+ console.log("Aeon initialized with endpoint:", this.endpoint);
28
28
  }
29
29
 
30
30
  async trackConversation({
@@ -32,37 +32,43 @@ export default class Aeon {
32
32
  provider,
33
33
  model,
34
34
  messages,
35
+ userId,
35
36
  }: {
36
37
  conversationId: string;
37
38
  provider: string;
38
39
  model: string;
39
40
  messages: Message[];
41
+ userId?: string;
40
42
  }) {
41
- if (!Aeon.apiKey || !Aeon.projectId) {
43
+ if (!this.apiKey || !this.projectId) {
42
44
  throw new Error("Missing credentials");
43
45
  }
44
46
 
45
- if (messages.length >= 40) {
46
- throw new Error("Reached messages limit");
47
- }
48
-
49
47
  try {
50
- await fetch(
51
- `${Aeon.endpoint}/api/v1/projects/${Aeon.projectId}/agents/conversations`,
48
+ const res = await fetch(
49
+ `${this.endpoint}/api/v1/projects/${this.projectId}/agents/conversations`,
52
50
  {
53
51
  method: "POST",
54
52
  headers: {
55
53
  "Content-Type": "application/json",
56
- Authorization: Aeon.apiKey,
54
+ Authorization: this.apiKey,
57
55
  },
58
56
  body: JSON.stringify({
59
57
  conversation_id: conversationId,
60
58
  provider,
61
59
  model,
62
60
  messages,
61
+ user_id: userId,
63
62
  }),
64
- }
63
+ },
65
64
  );
65
+
66
+ if (!res.ok) {
67
+ const text = await res.text();
68
+ throw new Error(`Aeon HTTP error ${res.status}: ${text}`);
69
+ }
70
+
71
+ console.log("Conversation tracked successfully");
66
72
  } catch (e) {
67
73
  console.error("Aeon error:", e);
68
74
  }