agenticpool 1.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.
Files changed (69) hide show
  1. package/AGENTS.md +56 -0
  2. package/README.md +42 -0
  3. package/agenticpool-cli-1.0.0.tgz +0 -0
  4. package/dist/api/ApiClient.d.ts +24 -0
  5. package/dist/api/ApiClient.js +79 -0
  6. package/dist/api/index.d.ts +1 -0
  7. package/dist/api/index.js +6 -0
  8. package/dist/auth/AuthHelper.d.ts +16 -0
  9. package/dist/auth/AuthHelper.js +137 -0
  10. package/dist/commands/auth.d.ts +2 -0
  11. package/dist/commands/auth.js +166 -0
  12. package/dist/commands/config.d.ts +2 -0
  13. package/dist/commands/config.js +51 -0
  14. package/dist/commands/connections.d.ts +2 -0
  15. package/dist/commands/connections.js +244 -0
  16. package/dist/commands/contacts.d.ts +2 -0
  17. package/dist/commands/contacts.js +205 -0
  18. package/dist/commands/conversations.d.ts +2 -0
  19. package/dist/commands/conversations.js +209 -0
  20. package/dist/commands/humans.d.ts +2 -0
  21. package/dist/commands/humans.js +129 -0
  22. package/dist/commands/identities.d.ts +2 -0
  23. package/dist/commands/identities.js +120 -0
  24. package/dist/commands/index.d.ts +10 -0
  25. package/dist/commands/index.js +24 -0
  26. package/dist/commands/messages.d.ts +2 -0
  27. package/dist/commands/messages.js +72 -0
  28. package/dist/commands/networks.d.ts +2 -0
  29. package/dist/commands/networks.js +237 -0
  30. package/dist/commands/profile.d.ts +2 -0
  31. package/dist/commands/profile.js +204 -0
  32. package/dist/config/ConfigManager.d.ts +31 -0
  33. package/dist/config/ConfigManager.js +135 -0
  34. package/dist/config/index.d.ts +1 -0
  35. package/dist/config/index.js +7 -0
  36. package/dist/index.d.ts +2 -0
  37. package/dist/index.js +22 -0
  38. package/dist/limits/LimitsManager.d.ts +23 -0
  39. package/dist/limits/LimitsManager.js +99 -0
  40. package/jest.config.js +23 -0
  41. package/package.json +47 -0
  42. package/src/api/ApiClient.ts +100 -0
  43. package/src/api/index.ts +1 -0
  44. package/src/auth/AuthHelper.ts +123 -0
  45. package/src/commands/auth.ts +169 -0
  46. package/src/commands/config.ts +51 -0
  47. package/src/commands/connections.ts +261 -0
  48. package/src/commands/contacts.ts +221 -0
  49. package/src/commands/conversations.ts +218 -0
  50. package/src/commands/humans.ts +124 -0
  51. package/src/commands/identities.ts +126 -0
  52. package/src/commands/index.ts +10 -0
  53. package/src/commands/messages.ts +72 -0
  54. package/src/commands/networks.ts +245 -0
  55. package/src/commands/profile.ts +184 -0
  56. package/src/config/ConfigManager.ts +137 -0
  57. package/src/config/index.ts +1 -0
  58. package/src/index.ts +35 -0
  59. package/src/limits/LimitsManager.ts +76 -0
  60. package/tests/ApiClient.test.ts +99 -0
  61. package/tests/ConfigManager.test.ts +41 -0
  62. package/tests/LimitsManager.test.ts +169 -0
  63. package/tests/__mocks__/@toon-format/toon.ts +27 -0
  64. package/tests/integration/cleanup.ts +187 -0
  65. package/tests/integration/e2e-cli.test.ts +465 -0
  66. package/tests/integration/e2e.test.ts +480 -0
  67. package/tests/integration/run-e2e.sh +44 -0
  68. package/tests/integration/setup.ts +188 -0
  69. package/tsconfig.json +28 -0
@@ -0,0 +1,188 @@
1
+ import axios from 'axios';
2
+
3
+ export const MAIN_API = 'https://us-central1-agenticpool.cloudfunctions.net/api';
4
+ export const HUMANS_API = 'https://us-central1-agenticpool-humans.cloudfunctions.net/api';
5
+ export const FB_API_KEY = 'AIzaSyCj3cTJHju9PJWr-v_oi2RhLIKGRLX0fK4';
6
+ export const FB_AUTH_URL = 'https://identitytoolkit.googleapis.com/v1/accounts';
7
+ export const NETWORK_ID = 'gamers-united';
8
+ export const TEST_PREFIX = `e2e-test-${Date.now()}`;
9
+
10
+ export interface AgentState {
11
+ publicToken: string;
12
+ privateKey: string;
13
+ jwt: string;
14
+ expiresAt: number;
15
+ }
16
+
17
+ export interface HumanState {
18
+ uid: string;
19
+ email: string;
20
+ idToken: string;
21
+ }
22
+
23
+ export const state: {
24
+ agentA: AgentState;
25
+ agentB: AgentState;
26
+ conversationId: string;
27
+ connectionId: string;
28
+ identityAId: string;
29
+ identityBId: string;
30
+ humanA: HumanState;
31
+ humanB: HumanState;
32
+ } = {
33
+ agentA: { publicToken: '', privateKey: '', jwt: '', expiresAt: 0 },
34
+ agentB: { publicToken: '', privateKey: '', jwt: '', expiresAt: 0 },
35
+ conversationId: '',
36
+ connectionId: '',
37
+ identityAId: '',
38
+ identityBId: '',
39
+ humanA: { uid: '', email: '', idToken: '' },
40
+ humanB: { uid: '', email: '', idToken: '' },
41
+ };
42
+
43
+ export function log(message: string) {
44
+ console.log(` ${message}`);
45
+ }
46
+
47
+ export function logStep(step: number, message: string) {
48
+ console.log(` ▸ Step ${step}: ${message}`);
49
+ }
50
+
51
+ export function logOk(message: string) {
52
+ console.log(` ✓ ${message}`);
53
+ }
54
+
55
+ export function logDetail(message: string) {
56
+ console.log(` → ${message}`);
57
+ }
58
+
59
+ export interface ApiResponse<T = any> { success: boolean; data: T; error?: string; message?: string; }
60
+
61
+ export async function mainGet<T = any>(path: string, token?: string): Promise<ApiResponse<T>> {
62
+ const headers: Record<string, string> = {};
63
+ if (token) headers.Authorization = `Bearer ${token}`;
64
+ const res = await axios.get(`${MAIN_API}${path}`, {
65
+ headers,
66
+ params: { format: 'json' },
67
+ timeout: 30000,
68
+ validateStatus: () => true,
69
+ });
70
+ if (res.status >= 400) {
71
+ throw new Error(`GET ${path} → ${res.status}: ${JSON.stringify(res.data)}`);
72
+ }
73
+ return res.data;
74
+ }
75
+
76
+ export async function mainPost<T = any>(path: string, body: any, token?: string): Promise<ApiResponse<T>> {
77
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
78
+ if (token) headers.Authorization = `Bearer ${token}`;
79
+ const res = await axios.post(`${MAIN_API}${path}`, body, {
80
+ headers,
81
+ params: { format: 'json' },
82
+ timeout: 30000,
83
+ validateStatus: () => true,
84
+ });
85
+ if (res.status >= 400) {
86
+ throw new Error(`POST ${path} → ${res.status}: ${JSON.stringify(res.data)}`);
87
+ }
88
+ return res.data;
89
+ }
90
+
91
+ export async function mainPut<T = any>(path: string, body: any, token?: string): Promise<ApiResponse<T>> {
92
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
93
+ if (token) headers.Authorization = `Bearer ${token}`;
94
+ const res = await axios.put(`${MAIN_API}${path}`, body, {
95
+ headers,
96
+ params: { format: 'json' },
97
+ timeout: 30000,
98
+ });
99
+ return res.data;
100
+ }
101
+
102
+ export async function humansGet<T = any>(path: string, token: string): Promise<ApiResponse<T>> {
103
+ const res = await axios.get(`${HUMANS_API}${path}`, {
104
+ headers: { Authorization: `Bearer ${token}` },
105
+ timeout: 30000,
106
+ });
107
+ return res.data;
108
+ }
109
+
110
+ export async function humansPost<T = any>(path: string, body: any, token: string): Promise<ApiResponse<T>> {
111
+ const res = await axios.post(`${HUMANS_API}${path}`, body, {
112
+ headers: {
113
+ Authorization: `Bearer ${token}`,
114
+ 'Content-Type': 'application/json',
115
+ },
116
+ timeout: 30000,
117
+ validateStatus: () => true,
118
+ });
119
+ if (res.status >= 400) {
120
+ throw new Error(`POST ${path} → ${res.status}: ${JSON.stringify(res.data)}`);
121
+ }
122
+ return res.data;
123
+ }
124
+
125
+ export async function humansPut<T = any>(path: string, body: any, token: string): Promise<ApiResponse<T>> {
126
+ const res = await axios.put(`${HUMANS_API}${path}`, body, {
127
+ headers: {
128
+ Authorization: `Bearer ${token}`,
129
+ 'Content-Type': 'application/json',
130
+ },
131
+ timeout: 30000,
132
+ validateStatus: () => true,
133
+ });
134
+ if (res.status >= 400) {
135
+ throw new Error(`PUT ${path} → ${res.status}: ${JSON.stringify(res.data)}`);
136
+ }
137
+ return res.data;
138
+ }
139
+
140
+ export async function humansDelete<T = any>(path: string, token: string): Promise<ApiResponse<T>> {
141
+ const res = await axios.delete(`${HUMANS_API}${path}`, {
142
+ headers: { Authorization: `Bearer ${token}` },
143
+ timeout: 30000,
144
+ });
145
+ return res.data;
146
+ }
147
+
148
+ export async function createFirebaseUser(email: string, password: string): Promise<HumanState> {
149
+ const res = await axios.post(`${FB_AUTH_URL}:signUp?key=${FB_API_KEY}`, {
150
+ email,
151
+ password,
152
+ returnSecureToken: true,
153
+ });
154
+ return {
155
+ uid: res.data.localId,
156
+ email: res.data.email,
157
+ idToken: res.data.idToken,
158
+ };
159
+ }
160
+
161
+ export async function signInFirebaseUser(email: string, password: string): Promise<string> {
162
+ const res = await axios.post(`${FB_AUTH_URL}:signInWithPassword?key=${FB_API_KEY}`, {
163
+ email,
164
+ password,
165
+ returnSecureToken: true,
166
+ });
167
+ return res.data.idToken;
168
+ }
169
+
170
+ export async function deleteFirebaseUser(idToken: string): Promise<void> {
171
+ try {
172
+ await axios.post(`${FB_AUTH_URL}:delete?key=${FB_API_KEY}`, { idToken });
173
+ } catch {
174
+ // ignore cleanup errors
175
+ }
176
+ }
177
+
178
+ export async function cleanupIdentities(token: string, ...ids: string[]): Promise<void> {
179
+ for (const id of ids) {
180
+ if (id) {
181
+ try {
182
+ await humansDelete(`/v1/identities/${id}`, token);
183
+ } catch {
184
+ // ignore
185
+ }
186
+ }
187
+ }
188
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "commonjs",
5
+ "lib": ["ES2020"],
6
+ "declaration": true,
7
+ "strict": true,
8
+ "noImplicitAny": true,
9
+ "strictNullChecks": true,
10
+ "noImplicitThis": true,
11
+ "alwaysStrict": true,
12
+ "noUnusedLocals": false,
13
+ "noUnusedParameters": false,
14
+ "noImplicitReturns": true,
15
+ "noFallthroughCasesInSwitch": false,
16
+ "inlineSourceMap": true,
17
+ "inlineSources": true,
18
+ "experimentalDecorators": true,
19
+ "strictPropertyInitialization": false,
20
+ "outDir": "./dist",
21
+ "rootDir": "./src",
22
+ "skipLibCheck": true,
23
+ "esModuleInterop": true,
24
+ "resolveJsonModule": true
25
+ },
26
+ "include": ["src/**/*"],
27
+ "exclude": ["node_modules", "dist", "tests"]
28
+ }