From 25824ed0aca6d8a3c54f3b89262c9b55d15a662f Mon Sep 17 00:00:00 2001 From: Wuesteon Date: Wed, 26 Nov 2025 01:31:12 +0100 Subject: [PATCH] make auth working --- .claude-flow/metrics/system-metrics.json | 1968 ++++++++++ .dockerignore | 37 + chat/TESTING_GUIDE.md | 681 ++++ chat/apps/mobile/services/api.ts | 633 ++++ chat/apps/mobile/services/conversation.ts | 614 ++- chat/apps/mobile/services/document.ts | 194 +- chat/apps/mobile/services/openai.ts | 180 +- chat/apps/mobile/services/space.ts | 396 +- chat/apps/mobile/services/template.ts | 161 +- chat/apps/web/package.json | 1 + chat/apps/web/src/app.d.ts | 7 +- chat/apps/web/src/hooks.server.ts | 35 +- chat/apps/web/src/lib/services/api.ts | 688 +++- chat/apps/web/src/lib/services/chat.ts | 25 +- .../apps/web/src/lib/services/conversation.ts | 229 +- chat/apps/web/src/lib/services/document.ts | 158 +- chat/apps/web/src/lib/services/space.ts | 228 +- chat/apps/web/src/lib/services/template.ts | 157 +- chat/apps/web/src/lib/stores/auth.svelte.ts | 57 +- .../web/src/routes/(auth)/login/+page.svelte | 6 +- .../src/routes/(protected)/+layout.server.ts | 17 +- .../web/src/routes/(protected)/+layout.svelte | 185 +- chat/backend/.dockerignore | 37 + chat/backend/.env.docker | 20 + chat/backend/.env.example | 5 +- chat/backend/Dockerfile | 63 + chat/backend/docker-compose.yml | 67 + chat/backend/docker-entrypoint.sh | 34 + chat/backend/drizzle.config.ts | 12 + chat/backend/nest-cli.json | 4 +- chat/backend/package.json | 19 +- chat/backend/src/app.module.ts | 10 + chat/backend/src/chat/chat.controller.ts | 2 +- chat/backend/src/chat/chat.service.ts | 117 +- .../conversation/conversation.controller.ts | 140 +- .../src/conversation/conversation.service.ts | 361 +- chat/backend/src/db/connection.ts | 38 + chat/backend/src/db/database.module.ts | 28 + chat/backend/src/db/migrate.ts | 29 + .../src/db/schema/conversations.schema.ts | 43 + .../backend/src/db/schema/documents.schema.ts | 24 + chat/backend/src/db/schema/index.ts | 7 + chat/backend/src/db/schema/messages.schema.ts | 26 + chat/backend/src/db/schema/models.schema.ts | 20 + chat/backend/src/db/schema/spaces.schema.ts | 46 + .../backend/src/db/schema/templates.schema.ts | 28 + .../src/db/schema/usage-logs.schema.ts | 40 + chat/backend/src/db/seed.ts | 100 + .../src/document/document.controller.ts | 129 + chat/backend/src/document/document.module.ts | 10 + chat/backend/src/document/document.service.ts | 239 ++ chat/backend/src/main.ts | 8 +- chat/backend/src/model/model.controller.ts | 33 + chat/backend/src/model/model.module.ts | 10 + chat/backend/src/model/model.service.ts | 55 + chat/backend/src/space/space.controller.ts | 219 ++ chat/backend/src/space/space.module.ts | 10 + chat/backend/src/space/space.service.ts | 449 +++ .../src/template/template.controller.ts | 141 + chat/backend/src/template/template.module.ts | 10 + chat/backend/src/template/template.service.ts | 191 + chat/backend/tsconfig.build.json | 4 + chat/backend/tsconfig.json | 6 +- docker-compose.dev.yml | 116 + docker/init-db/01-create-databases.sql | 9 + maerchenzauber/apps/backend/package.json | 1 - manadeck/backend/package.json | 1 - package.json | 13 +- packages/shared-auth/tsconfig.json | 8 +- packages/shared-errors/package.json | 15 +- packages/shared-errors/tsconfig.build.json | 18 + pnpm-lock.yaml | 3297 +++++++---------- uload/apps/backend/package.json | 1 - 73 files changed, 9093 insertions(+), 3877 deletions(-) create mode 100644 .dockerignore create mode 100644 chat/TESTING_GUIDE.md create mode 100644 chat/apps/mobile/services/api.ts create mode 100644 chat/backend/.dockerignore create mode 100644 chat/backend/.env.docker create mode 100644 chat/backend/Dockerfile create mode 100644 chat/backend/docker-compose.yml create mode 100644 chat/backend/docker-entrypoint.sh create mode 100644 chat/backend/drizzle.config.ts create mode 100644 chat/backend/src/db/connection.ts create mode 100644 chat/backend/src/db/database.module.ts create mode 100644 chat/backend/src/db/migrate.ts create mode 100644 chat/backend/src/db/schema/conversations.schema.ts create mode 100644 chat/backend/src/db/schema/documents.schema.ts create mode 100644 chat/backend/src/db/schema/index.ts create mode 100644 chat/backend/src/db/schema/messages.schema.ts create mode 100644 chat/backend/src/db/schema/models.schema.ts create mode 100644 chat/backend/src/db/schema/spaces.schema.ts create mode 100644 chat/backend/src/db/schema/templates.schema.ts create mode 100644 chat/backend/src/db/schema/usage-logs.schema.ts create mode 100644 chat/backend/src/db/seed.ts create mode 100644 chat/backend/src/document/document.controller.ts create mode 100644 chat/backend/src/document/document.module.ts create mode 100644 chat/backend/src/document/document.service.ts create mode 100644 chat/backend/src/model/model.controller.ts create mode 100644 chat/backend/src/model/model.module.ts create mode 100644 chat/backend/src/model/model.service.ts create mode 100644 chat/backend/src/space/space.controller.ts create mode 100644 chat/backend/src/space/space.module.ts create mode 100644 chat/backend/src/space/space.service.ts create mode 100644 chat/backend/src/template/template.controller.ts create mode 100644 chat/backend/src/template/template.module.ts create mode 100644 chat/backend/src/template/template.service.ts create mode 100644 chat/backend/tsconfig.build.json create mode 100644 docker-compose.dev.yml create mode 100644 docker/init-db/01-create-databases.sql create mode 100644 packages/shared-errors/tsconfig.build.json diff --git a/.claude-flow/metrics/system-metrics.json b/.claude-flow/metrics/system-metrics.json index 2dde4bf2a..9a9dc2b0a 100644 --- a/.claude-flow/metrics/system-metrics.json +++ b/.claude-flow/metrics/system-metrics.json @@ -3214,5 +3214,1973 @@ "cpuLoad": 0.18436686197916666, "platform": "darwin", "uptime": 1402935 + }, + { + "timestamp": 1764093410329, + "memoryTotal": 34359738368, + "memoryUsed": 34285469696, + "memoryFree": 74268672, + "memoryUsagePercent": 99.78384971618652, + "memoryEfficiency": 0.21615028381347656, + "cpuCount": 12, + "cpuLoad": 0.24772135416666666, + "platform": "darwin", + "uptime": 1402965 + }, + { + "timestamp": 1764093440330, + "memoryTotal": 34359738368, + "memoryUsed": 34234236928, + "memoryFree": 125501440, + "memoryUsagePercent": 99.6347427368164, + "memoryEfficiency": 0.36525726318359375, + "cpuCount": 12, + "cpuLoad": 0.23836263020833334, + "platform": "darwin", + "uptime": 1402995 + }, + { + "timestamp": 1764093470330, + "memoryTotal": 34359738368, + "memoryUsed": 34054012928, + "memoryFree": 305725440, + "memoryUsagePercent": 99.11022186279297, + "memoryEfficiency": 0.8897781372070312, + "cpuCount": 12, + "cpuLoad": 0.3022867838541667, + "platform": "darwin", + "uptime": 1403025 + }, + { + "timestamp": 1764093500331, + "memoryTotal": 34359738368, + "memoryUsed": 34092777472, + "memoryFree": 266960896, + "memoryUsagePercent": 99.22304153442383, + "memoryEfficiency": 0.7769584655761719, + "cpuCount": 12, + "cpuLoad": 0.4145914713541667, + "platform": "darwin", + "uptime": 1403055 + }, + { + "timestamp": 1764093530333, + "memoryTotal": 34359738368, + "memoryUsed": 34026864640, + "memoryFree": 332873728, + "memoryUsagePercent": 99.03120994567871, + "memoryEfficiency": 0.9687900543212891, + "cpuCount": 12, + "cpuLoad": 0.2869873046875, + "platform": "darwin", + "uptime": 1403085 + }, + { + "timestamp": 1764093560334, + "memoryTotal": 34359738368, + "memoryUsed": 34295365632, + "memoryFree": 64372736, + "memoryUsagePercent": 99.81265068054199, + "memoryEfficiency": 0.1873493194580078, + "cpuCount": 12, + "cpuLoad": 0.411865234375, + "platform": "darwin", + "uptime": 1403115 + }, + { + "timestamp": 1764093590335, + "memoryTotal": 34359738368, + "memoryUsed": 34210742272, + "memoryFree": 148996096, + "memoryUsagePercent": 99.56636428833008, + "memoryEfficiency": 0.4336357116699219, + "cpuCount": 12, + "cpuLoad": 0.3538004557291667, + "platform": "darwin", + "uptime": 1403145 + }, + { + "timestamp": 1764093620336, + "memoryTotal": 34359738368, + "memoryUsed": 34290745344, + "memoryFree": 68993024, + "memoryUsagePercent": 99.79920387268066, + "memoryEfficiency": 0.20079612731933594, + "cpuCount": 12, + "cpuLoad": 0.2711588541666667, + "platform": "darwin", + "uptime": 1403175 + }, + { + "timestamp": 1764093650336, + "memoryTotal": 34359738368, + "memoryUsed": 34285830144, + "memoryFree": 73908224, + "memoryUsagePercent": 99.78489875793457, + "memoryEfficiency": 0.2151012420654297, + "cpuCount": 12, + "cpuLoad": 0.2781575520833333, + "platform": "darwin", + "uptime": 1403205 + }, + { + "timestamp": 1764093680337, + "memoryTotal": 34359738368, + "memoryUsed": 34217082880, + "memoryFree": 142655488, + "memoryUsagePercent": 99.58481788635254, + "memoryEfficiency": 0.41518211364746094, + "cpuCount": 12, + "cpuLoad": 0.24654134114583334, + "platform": "darwin", + "uptime": 1403235 + }, + { + "timestamp": 1764093710338, + "memoryTotal": 34359738368, + "memoryUsed": 34236973056, + "memoryFree": 122765312, + "memoryUsagePercent": 99.6427059173584, + "memoryEfficiency": 0.35729408264160156, + "cpuCount": 12, + "cpuLoad": 0.2996419270833333, + "platform": "darwin", + "uptime": 1403265 + }, + { + "timestamp": 1764093740349, + "memoryTotal": 34359738368, + "memoryUsed": 34023882752, + "memoryFree": 335855616, + "memoryUsagePercent": 99.02253150939941, + "memoryEfficiency": 0.9774684906005859, + "cpuCount": 12, + "cpuLoad": 0.3340657552083333, + "platform": "darwin", + "uptime": 1403295 + }, + { + "timestamp": 1764093770358, + "memoryTotal": 34359738368, + "memoryUsed": 34150793216, + "memoryFree": 208945152, + "memoryUsagePercent": 99.39188957214355, + "memoryEfficiency": 0.6081104278564453, + "cpuCount": 12, + "cpuLoad": 0.2558186848958333, + "platform": "darwin", + "uptime": 1403325 + }, + { + "timestamp": 1764093800360, + "memoryTotal": 34359738368, + "memoryUsed": 33265778688, + "memoryFree": 1093959680, + "memoryUsagePercent": 96.81615829467773, + "memoryEfficiency": 3.1838417053222656, + "cpuCount": 12, + "cpuLoad": 0.216064453125, + "platform": "darwin", + "uptime": 1403355 + }, + { + "timestamp": 1764093830360, + "memoryTotal": 34359738368, + "memoryUsed": 32099958784, + "memoryFree": 2259779584, + "memoryUsagePercent": 93.42317581176758, + "memoryEfficiency": 6.576824188232422, + "cpuCount": 12, + "cpuLoad": 0.2083740234375, + "platform": "darwin", + "uptime": 1403385 + }, + { + "timestamp": 1764093860362, + "memoryTotal": 34359738368, + "memoryUsed": 33142063104, + "memoryFree": 1217675264, + "memoryUsagePercent": 96.45609855651855, + "memoryEfficiency": 3.5439014434814453, + "cpuCount": 12, + "cpuLoad": 0.24812825520833334, + "platform": "darwin", + "uptime": 1403415 + }, + { + "timestamp": 1764093890364, + "memoryTotal": 34359738368, + "memoryUsed": 33829224448, + "memoryFree": 530513920, + "memoryUsagePercent": 98.45600128173828, + "memoryEfficiency": 1.5439987182617188, + "cpuCount": 12, + "cpuLoad": 0.505126953125, + "platform": "darwin", + "uptime": 1403445 + }, + { + "timestamp": 1764093920365, + "memoryTotal": 34359738368, + "memoryUsed": 33940340736, + "memoryFree": 419397632, + "memoryUsagePercent": 98.77939224243164, + "memoryEfficiency": 1.2206077575683594, + "cpuCount": 12, + "cpuLoad": 1.3014322916666667, + "platform": "darwin", + "uptime": 1403475 + }, + { + "timestamp": 1764093950368, + "memoryTotal": 34359738368, + "memoryUsed": 33190035456, + "memoryFree": 1169702912, + "memoryUsagePercent": 96.59571647644043, + "memoryEfficiency": 3.4042835235595703, + "cpuCount": 12, + "cpuLoad": 1.4837646484375, + "platform": "darwin", + "uptime": 1403505 + }, + { + "timestamp": 1764093980369, + "memoryTotal": 34359738368, + "memoryUsed": 34220097536, + "memoryFree": 139640832, + "memoryUsagePercent": 99.59359169006348, + "memoryEfficiency": 0.40640830993652344, + "cpuCount": 12, + "cpuLoad": 1.0686848958333333, + "platform": "darwin", + "uptime": 1403535 + }, + { + "timestamp": 1764094010369, + "memoryTotal": 34359738368, + "memoryUsed": 34009890816, + "memoryFree": 349847552, + "memoryUsagePercent": 98.98180961608887, + "memoryEfficiency": 1.0181903839111328, + "cpuCount": 12, + "cpuLoad": 0.7806396484375, + "platform": "darwin", + "uptime": 1403565 + }, + { + "timestamp": 1764094040370, + "memoryTotal": 34359738368, + "memoryUsed": 34165899264, + "memoryFree": 193839104, + "memoryUsagePercent": 99.43585395812988, + "memoryEfficiency": 0.5641460418701172, + "cpuCount": 12, + "cpuLoad": 0.6533610026041666, + "platform": "darwin", + "uptime": 1403595 + }, + { + "timestamp": 1764094070372, + "memoryTotal": 34359738368, + "memoryUsed": 34274918400, + "memoryFree": 84819968, + "memoryUsagePercent": 99.75314140319824, + "memoryEfficiency": 0.2468585968017578, + "cpuCount": 12, + "cpuLoad": 0.6412760416666666, + "platform": "darwin", + "uptime": 1403625 + }, + { + "timestamp": 1764094100372, + "memoryTotal": 34359738368, + "memoryUsed": 34276311040, + "memoryFree": 83427328, + "memoryUsagePercent": 99.75719451904297, + "memoryEfficiency": 0.24280548095703125, + "cpuCount": 12, + "cpuLoad": 0.5965169270833334, + "platform": "darwin", + "uptime": 1403655 + }, + { + "timestamp": 1764094130373, + "memoryTotal": 34359738368, + "memoryUsed": 34280636416, + "memoryFree": 79101952, + "memoryUsagePercent": 99.76978302001953, + "memoryEfficiency": 0.23021697998046875, + "cpuCount": 12, + "cpuLoad": 0.555908203125, + "platform": "darwin", + "uptime": 1403685 + }, + { + "timestamp": 1764094160375, + "memoryTotal": 34359738368, + "memoryUsed": 34290679808, + "memoryFree": 69058560, + "memoryUsagePercent": 99.79901313781738, + "memoryEfficiency": 0.2009868621826172, + "cpuCount": 12, + "cpuLoad": 0.3932698567708333, + "platform": "darwin", + "uptime": 1403715 + }, + { + "timestamp": 1764094190376, + "memoryTotal": 34359738368, + "memoryUsed": 34274050048, + "memoryFree": 85688320, + "memoryUsagePercent": 99.75061416625977, + "memoryEfficiency": 0.24938583374023438, + "cpuCount": 12, + "cpuLoad": 0.2818603515625, + "platform": "darwin", + "uptime": 1403745 + }, + { + "timestamp": 1764094220377, + "memoryTotal": 34359738368, + "memoryUsed": 34297151488, + "memoryFree": 62586880, + "memoryUsagePercent": 99.8178482055664, + "memoryEfficiency": 0.18215179443359375, + "cpuCount": 12, + "cpuLoad": 0.20914713541666666, + "platform": "darwin", + "uptime": 1403775 + }, + { + "timestamp": 1764094250378, + "memoryTotal": 34359738368, + "memoryUsed": 34289713152, + "memoryFree": 70025216, + "memoryUsagePercent": 99.79619979858398, + "memoryEfficiency": 0.20380020141601562, + "cpuCount": 12, + "cpuLoad": 0.19364420572916666, + "platform": "darwin", + "uptime": 1403805 + }, + { + "timestamp": 1764094280378, + "memoryTotal": 34359738368, + "memoryUsed": 34279407616, + "memoryFree": 80330752, + "memoryUsagePercent": 99.76620674133301, + "memoryEfficiency": 0.2337932586669922, + "cpuCount": 12, + "cpuLoad": 0.17179361979166666, + "platform": "darwin", + "uptime": 1403835 + }, + { + "timestamp": 1764094310379, + "memoryTotal": 34359738368, + "memoryUsed": 34037334016, + "memoryFree": 322404352, + "memoryUsagePercent": 99.06167984008789, + "memoryEfficiency": 0.9383201599121094, + "cpuCount": 12, + "cpuLoad": 0.19722493489583334, + "platform": "darwin", + "uptime": 1403865 + }, + { + "timestamp": 1764094340379, + "memoryTotal": 34359738368, + "memoryUsed": 33889697792, + "memoryFree": 470040576, + "memoryUsagePercent": 98.63200187683105, + "memoryEfficiency": 1.3679981231689453, + "cpuCount": 12, + "cpuLoad": 0.18583170572916666, + "platform": "darwin", + "uptime": 1403895 + }, + { + "timestamp": 1764094370380, + "memoryTotal": 34359738368, + "memoryUsed": 33813970944, + "memoryFree": 545767424, + "memoryUsagePercent": 98.41160774230957, + "memoryEfficiency": 1.5883922576904297, + "cpuCount": 12, + "cpuLoad": 0.22819010416666666, + "platform": "darwin", + "uptime": 1403925 + }, + { + "timestamp": 1764094400381, + "memoryTotal": 34359738368, + "memoryUsed": 34254209024, + "memoryFree": 105529344, + "memoryUsagePercent": 99.69286918640137, + "memoryEfficiency": 0.3071308135986328, + "cpuCount": 12, + "cpuLoad": 0.2915852864583333, + "platform": "darwin", + "uptime": 1403955 + }, + { + "timestamp": 1764094430381, + "memoryTotal": 34359738368, + "memoryUsed": 34292383744, + "memoryFree": 67354624, + "memoryUsagePercent": 99.8039722442627, + "memoryEfficiency": 0.1960277557373047, + "cpuCount": 12, + "cpuLoad": 0.20662434895833334, + "platform": "darwin", + "uptime": 1403985 + }, + { + "timestamp": 1764094460382, + "memoryTotal": 34359738368, + "memoryUsed": 34264219648, + "memoryFree": 95518720, + "memoryUsagePercent": 99.72200393676758, + "memoryEfficiency": 0.2779960632324219, + "cpuCount": 12, + "cpuLoad": 0.22054036458333334, + "platform": "darwin", + "uptime": 1404015 + }, + { + "timestamp": 1764094490384, + "memoryTotal": 34359738368, + "memoryUsed": 34168373248, + "memoryFree": 191365120, + "memoryUsagePercent": 99.44305419921875, + "memoryEfficiency": 0.55694580078125, + "cpuCount": 12, + "cpuLoad": 0.21419270833333334, + "platform": "darwin", + "uptime": 1404045 + }, + { + "timestamp": 1764094520384, + "memoryTotal": 34359738368, + "memoryUsed": 34295808000, + "memoryFree": 63930368, + "memoryUsagePercent": 99.81393814086914, + "memoryEfficiency": 0.18606185913085938, + "cpuCount": 12, + "cpuLoad": 0.16841634114583334, + "platform": "darwin", + "uptime": 1404075 + }, + { + "timestamp": 1764094550385, + "memoryTotal": 34359738368, + "memoryUsed": 34295054336, + "memoryFree": 64684032, + "memoryUsagePercent": 99.8117446899414, + "memoryEfficiency": 0.18825531005859375, + "cpuCount": 12, + "cpuLoad": 0.1163330078125, + "platform": "darwin", + "uptime": 1404105 + }, + { + "timestamp": 1764094580386, + "memoryTotal": 34359738368, + "memoryUsed": 34289942528, + "memoryFree": 69795840, + "memoryUsagePercent": 99.79686737060547, + "memoryEfficiency": 0.20313262939453125, + "cpuCount": 12, + "cpuLoad": 0.1495361328125, + "platform": "darwin", + "uptime": 1404135 + }, + { + "timestamp": 1764094610389, + "memoryTotal": 34359738368, + "memoryUsed": 34219982848, + "memoryFree": 139755520, + "memoryUsagePercent": 99.59325790405273, + "memoryEfficiency": 0.4067420959472656, + "cpuCount": 12, + "cpuLoad": 0.2848714192708333, + "platform": "darwin", + "uptime": 1404165 + }, + { + "timestamp": 1764094640389, + "memoryTotal": 34359738368, + "memoryUsed": 34287009792, + "memoryFree": 72728576, + "memoryUsagePercent": 99.78833198547363, + "memoryEfficiency": 0.2116680145263672, + "cpuCount": 12, + "cpuLoad": 0.6092936197916666, + "platform": "darwin", + "uptime": 1404195 + }, + { + "timestamp": 1764094670391, + "memoryTotal": 34359738368, + "memoryUsed": 34290024448, + "memoryFree": 69713920, + "memoryUsagePercent": 99.79710578918457, + "memoryEfficiency": 0.2028942108154297, + "cpuCount": 12, + "cpuLoad": 0.7731526692708334, + "platform": "darwin", + "uptime": 1404225 + }, + { + "timestamp": 1764094700391, + "memoryTotal": 34359738368, + "memoryUsed": 34297544704, + "memoryFree": 62193664, + "memoryUsagePercent": 99.8189926147461, + "memoryEfficiency": 0.18100738525390625, + "cpuCount": 12, + "cpuLoad": 0.76416015625, + "platform": "darwin", + "uptime": 1404255 + }, + { + "timestamp": 1764094730393, + "memoryTotal": 34359738368, + "memoryUsed": 34285830144, + "memoryFree": 73908224, + "memoryUsagePercent": 99.78489875793457, + "memoryEfficiency": 0.2151012420654297, + "cpuCount": 12, + "cpuLoad": 0.5943196614583334, + "platform": "darwin", + "uptime": 1404285 + }, + { + "timestamp": 1764094760394, + "memoryTotal": 34359738368, + "memoryUsed": 34158985216, + "memoryFree": 200753152, + "memoryUsagePercent": 99.41573143005371, + "memoryEfficiency": 0.5842685699462891, + "cpuCount": 12, + "cpuLoad": 0.4160563151041667, + "platform": "darwin", + "uptime": 1404315 + }, + { + "timestamp": 1764094790395, + "memoryTotal": 34359738368, + "memoryUsed": 34292744192, + "memoryFree": 66994176, + "memoryUsagePercent": 99.80502128601074, + "memoryEfficiency": 0.1949787139892578, + "cpuCount": 12, + "cpuLoad": 0.3221842447916667, + "platform": "darwin", + "uptime": 1404345 + }, + { + "timestamp": 1764094820396, + "memoryTotal": 34359738368, + "memoryUsed": 34262040576, + "memoryFree": 97697792, + "memoryUsagePercent": 99.71566200256348, + "memoryEfficiency": 0.28433799743652344, + "cpuCount": 12, + "cpuLoad": 0.23551432291666666, + "platform": "darwin", + "uptime": 1404375 + }, + { + "timestamp": 1764094850396, + "memoryTotal": 34359738368, + "memoryUsed": 34293956608, + "memoryFree": 65781760, + "memoryUsagePercent": 99.80854988098145, + "memoryEfficiency": 0.1914501190185547, + "cpuCount": 12, + "cpuLoad": 0.2015380859375, + "platform": "darwin", + "uptime": 1404405 + }, + { + "timestamp": 1764094880397, + "memoryTotal": 34359738368, + "memoryUsed": 34284929024, + "memoryFree": 74809344, + "memoryUsagePercent": 99.78227615356445, + "memoryEfficiency": 0.21772384643554688, + "cpuCount": 12, + "cpuLoad": 0.15486653645833334, + "platform": "darwin", + "uptime": 1404435 + }, + { + "timestamp": 1764094910398, + "memoryTotal": 34359738368, + "memoryUsed": 34173911040, + "memoryFree": 185827328, + "memoryUsagePercent": 99.45917129516602, + "memoryEfficiency": 0.5408287048339844, + "cpuCount": 12, + "cpuLoad": 0.1400146484375, + "platform": "darwin", + "uptime": 1404465 + }, + { + "timestamp": 1764094940399, + "memoryTotal": 34359738368, + "memoryUsed": 33881669632, + "memoryFree": 478068736, + "memoryUsagePercent": 98.6086368560791, + "memoryEfficiency": 1.3913631439208984, + "cpuCount": 12, + "cpuLoad": 0.19685872395833334, + "platform": "darwin", + "uptime": 1404495 + }, + { + "timestamp": 1764094970399, + "memoryTotal": 34359738368, + "memoryUsed": 34287435776, + "memoryFree": 72302592, + "memoryUsagePercent": 99.78957176208496, + "memoryEfficiency": 0.21042823791503906, + "cpuCount": 12, + "cpuLoad": 0.16507975260416666, + "platform": "darwin", + "uptime": 1404525 + }, + { + "timestamp": 1764095000400, + "memoryTotal": 34359738368, + "memoryUsed": 34270494720, + "memoryFree": 89243648, + "memoryUsagePercent": 99.74026679992676, + "memoryEfficiency": 0.2597332000732422, + "cpuCount": 12, + "cpuLoad": 0.1473388671875, + "platform": "darwin", + "uptime": 1404555 + }, + { + "timestamp": 1764095030400, + "memoryTotal": 34359738368, + "memoryUsed": 34274738176, + "memoryFree": 85000192, + "memoryUsagePercent": 99.75261688232422, + "memoryEfficiency": 0.24738311767578125, + "cpuCount": 12, + "cpuLoad": 0.2941487630208333, + "platform": "darwin", + "uptime": 1404585 + }, + { + "timestamp": 1764095060401, + "memoryTotal": 34359738368, + "memoryUsed": 34279014400, + "memoryFree": 80723968, + "memoryUsagePercent": 99.76506233215332, + "memoryEfficiency": 0.2349376678466797, + "cpuCount": 12, + "cpuLoad": 0.2832438151041667, + "platform": "darwin", + "uptime": 1404615 + }, + { + "timestamp": 1764095090402, + "memoryTotal": 34359738368, + "memoryUsed": 34257305600, + "memoryFree": 102432768, + "memoryUsagePercent": 99.7018814086914, + "memoryEfficiency": 0.29811859130859375, + "cpuCount": 12, + "cpuLoad": 0.2222900390625, + "platform": "darwin", + "uptime": 1404645 + }, + { + "timestamp": 1764095120403, + "memoryTotal": 34359738368, + "memoryUsed": 34274213888, + "memoryFree": 85524480, + "memoryUsagePercent": 99.75109100341797, + "memoryEfficiency": 0.24890899658203125, + "cpuCount": 12, + "cpuLoad": 0.271240234375, + "platform": "darwin", + "uptime": 1404675 + }, + { + "timestamp": 1764095150403, + "memoryTotal": 34359738368, + "memoryUsed": 34228617216, + "memoryFree": 131121152, + "memoryUsagePercent": 99.61838722229004, + "memoryEfficiency": 0.38161277770996094, + "cpuCount": 12, + "cpuLoad": 0.3594563802083333, + "platform": "darwin", + "uptime": 1404705 + }, + { + "timestamp": 1764095180403, + "memoryTotal": 34359738368, + "memoryUsed": 34234630144, + "memoryFree": 125108224, + "memoryUsagePercent": 99.6358871459961, + "memoryEfficiency": 0.36411285400390625, + "cpuCount": 12, + "cpuLoad": 0.5423583984375, + "platform": "darwin", + "uptime": 1404735 + }, + { + "timestamp": 1764095210405, + "memoryTotal": 34359738368, + "memoryUsed": 34128855040, + "memoryFree": 230883328, + "memoryUsagePercent": 99.32804107666016, + "memoryEfficiency": 0.6719589233398438, + "cpuCount": 12, + "cpuLoad": 0.4071858723958333, + "platform": "darwin", + "uptime": 1404765 + }, + { + "timestamp": 1764095240406, + "memoryTotal": 34359738368, + "memoryUsed": 34184429568, + "memoryFree": 175308800, + "memoryUsagePercent": 99.48978424072266, + "memoryEfficiency": 0.5102157592773438, + "cpuCount": 12, + "cpuLoad": 0.3553466796875, + "platform": "darwin", + "uptime": 1404795 + }, + { + "timestamp": 1764095270408, + "memoryTotal": 34359738368, + "memoryUsed": 34293202944, + "memoryFree": 66535424, + "memoryUsagePercent": 99.80635643005371, + "memoryEfficiency": 0.19364356994628906, + "cpuCount": 12, + "cpuLoad": 0.24287923177083334, + "platform": "darwin", + "uptime": 1404825 + }, + { + "timestamp": 1764095300408, + "memoryTotal": 34359738368, + "memoryUsed": 34288271360, + "memoryFree": 71467008, + "memoryUsagePercent": 99.7920036315918, + "memoryEfficiency": 0.20799636840820312, + "cpuCount": 12, + "cpuLoad": 0.23465983072916666, + "platform": "darwin", + "uptime": 1404855 + }, + { + "timestamp": 1764095330410, + "memoryTotal": 34359738368, + "memoryUsed": 34292695040, + "memoryFree": 67043328, + "memoryUsagePercent": 99.80487823486328, + "memoryEfficiency": 0.19512176513671875, + "cpuCount": 12, + "cpuLoad": 0.1900634765625, + "platform": "darwin", + "uptime": 1404885 + }, + { + "timestamp": 1764095360411, + "memoryTotal": 34359738368, + "memoryUsed": 34193129472, + "memoryFree": 166608896, + "memoryUsagePercent": 99.51510429382324, + "memoryEfficiency": 0.4848957061767578, + "cpuCount": 12, + "cpuLoad": 0.18595377604166666, + "platform": "darwin", + "uptime": 1404915 + }, + { + "timestamp": 1764095390412, + "memoryTotal": 34359738368, + "memoryUsed": 34287206400, + "memoryFree": 72531968, + "memoryUsagePercent": 99.78890419006348, + "memoryEfficiency": 0.21109580993652344, + "cpuCount": 12, + "cpuLoad": 0.1435546875, + "platform": "darwin", + "uptime": 1404945 + }, + { + "timestamp": 1764095420414, + "memoryTotal": 34359738368, + "memoryUsed": 34274967552, + "memoryFree": 84770816, + "memoryUsagePercent": 99.7532844543457, + "memoryEfficiency": 0.24671554565429688, + "cpuCount": 12, + "cpuLoad": 0.18290201822916666, + "platform": "darwin", + "uptime": 1404975 + }, + { + "timestamp": 1764095450414, + "memoryTotal": 34359738368, + "memoryUsed": 34263744512, + "memoryFree": 95993856, + "memoryUsagePercent": 99.72062110900879, + "memoryEfficiency": 0.27937889099121094, + "cpuCount": 12, + "cpuLoad": 0.2875162760416667, + "platform": "darwin", + "uptime": 1405005 + }, + { + "timestamp": 1764095480416, + "memoryTotal": 34359738368, + "memoryUsed": 34292531200, + "memoryFree": 67207168, + "memoryUsagePercent": 99.80440139770508, + "memoryEfficiency": 0.19559860229492188, + "cpuCount": 12, + "cpuLoad": 0.195556640625, + "platform": "darwin", + "uptime": 1405035 + }, + { + "timestamp": 1764095510416, + "memoryTotal": 34359738368, + "memoryUsed": 34170355712, + "memoryFree": 189382656, + "memoryUsagePercent": 99.44882392883301, + "memoryEfficiency": 0.5511760711669922, + "cpuCount": 12, + "cpuLoad": 0.16068522135416666, + "platform": "darwin", + "uptime": 1405065 + }, + { + "timestamp": 1764095540418, + "memoryTotal": 34359738368, + "memoryUsed": 34003632128, + "memoryFree": 356106240, + "memoryUsagePercent": 98.96359443664551, + "memoryEfficiency": 1.0364055633544922, + "cpuCount": 12, + "cpuLoad": 0.23225911458333334, + "platform": "darwin", + "uptime": 1405095 + }, + { + "timestamp": 1764095570417, + "memoryTotal": 34359738368, + "memoryUsed": 34276491264, + "memoryFree": 83247104, + "memoryUsagePercent": 99.75771903991699, + "memoryEfficiency": 0.2422809600830078, + "cpuCount": 12, + "cpuLoad": 0.2598876953125, + "platform": "darwin", + "uptime": 1405125 + }, + { + "timestamp": 1764095600419, + "memoryTotal": 34359738368, + "memoryUsed": 34197504000, + "memoryFree": 162234368, + "memoryUsagePercent": 99.52783584594727, + "memoryEfficiency": 0.4721641540527344, + "cpuCount": 12, + "cpuLoad": 0.22566731770833334, + "platform": "darwin", + "uptime": 1405155 + }, + { + "timestamp": 1764095630420, + "memoryTotal": 34359738368, + "memoryUsed": 34294693888, + "memoryFree": 65044480, + "memoryUsagePercent": 99.81069564819336, + "memoryEfficiency": 0.18930435180664062, + "cpuCount": 12, + "cpuLoad": 0.18221028645833334, + "platform": "darwin", + "uptime": 1405185 + }, + { + "timestamp": 1764095660420, + "memoryTotal": 34359738368, + "memoryUsed": 34255536128, + "memoryFree": 104202240, + "memoryUsagePercent": 99.69673156738281, + "memoryEfficiency": 0.3032684326171875, + "cpuCount": 12, + "cpuLoad": 0.14961751302083334, + "platform": "darwin", + "uptime": 1405215 + }, + { + "timestamp": 1764095690422, + "memoryTotal": 34359738368, + "memoryUsed": 33934032896, + "memoryFree": 425705472, + "memoryUsagePercent": 98.76103401184082, + "memoryEfficiency": 1.2389659881591797, + "cpuCount": 12, + "cpuLoad": 0.2637125651041667, + "platform": "darwin", + "uptime": 1405245 + }, + { + "timestamp": 1764095720423, + "memoryTotal": 34359738368, + "memoryUsed": 34278883328, + "memoryFree": 80855040, + "memoryUsagePercent": 99.76468086242676, + "memoryEfficiency": 0.2353191375732422, + "cpuCount": 12, + "cpuLoad": 0.3084309895833333, + "platform": "darwin", + "uptime": 1405275 + }, + { + "timestamp": 1764095750423, + "memoryTotal": 34359738368, + "memoryUsed": 34277310464, + "memoryFree": 82427904, + "memoryUsagePercent": 99.76010322570801, + "memoryEfficiency": 0.2398967742919922, + "cpuCount": 12, + "cpuLoad": 0.32275390625, + "platform": "darwin", + "uptime": 1405305 + }, + { + "timestamp": 1764095780423, + "memoryTotal": 34359738368, + "memoryUsed": 34276720640, + "memoryFree": 83017728, + "memoryUsagePercent": 99.75838661193848, + "memoryEfficiency": 0.24161338806152344, + "cpuCount": 12, + "cpuLoad": 0.2916259765625, + "platform": "darwin", + "uptime": 1405335 + }, + { + "timestamp": 1764095810425, + "memoryTotal": 34359738368, + "memoryUsed": 34186002432, + "memoryFree": 173735936, + "memoryUsagePercent": 99.4943618774414, + "memoryEfficiency": 0.5056381225585938, + "cpuCount": 12, + "cpuLoad": 0.239013671875, + "platform": "darwin", + "uptime": 1405365 + }, + { + "timestamp": 1764095840426, + "memoryTotal": 34359738368, + "memoryUsed": 34211332096, + "memoryFree": 148406272, + "memoryUsagePercent": 99.56808090209961, + "memoryEfficiency": 0.4319190979003906, + "cpuCount": 12, + "cpuLoad": 0.2715657552083333, + "platform": "darwin", + "uptime": 1405395 + }, + { + "timestamp": 1764095870427, + "memoryTotal": 34359738368, + "memoryUsed": 34281652224, + "memoryFree": 78086144, + "memoryUsagePercent": 99.77273941040039, + "memoryEfficiency": 0.22726058959960938, + "cpuCount": 12, + "cpuLoad": 0.19673665364583334, + "platform": "darwin", + "uptime": 1405425 + }, + { + "timestamp": 1764095900429, + "memoryTotal": 34359738368, + "memoryUsed": 34293923840, + "memoryFree": 65814528, + "memoryUsagePercent": 99.8084545135498, + "memoryEfficiency": 0.1915454864501953, + "cpuCount": 12, + "cpuLoad": 0.19921875, + "platform": "darwin", + "uptime": 1405455 + }, + { + "timestamp": 1764095930429, + "memoryTotal": 34359738368, + "memoryUsed": 34288107520, + "memoryFree": 71630848, + "memoryUsagePercent": 99.7915267944336, + "memoryEfficiency": 0.20847320556640625, + "cpuCount": 12, + "cpuLoad": 0.3436686197916667, + "platform": "darwin", + "uptime": 1405485 + }, + { + "timestamp": 1764095960431, + "memoryTotal": 34359738368, + "memoryUsed": 34282504192, + "memoryFree": 77234176, + "memoryUsagePercent": 99.77521896362305, + "memoryEfficiency": 0.22478103637695312, + "cpuCount": 12, + "cpuLoad": 0.2886555989583333, + "platform": "darwin", + "uptime": 1405515 + }, + { + "timestamp": 1764095990431, + "memoryTotal": 34359738368, + "memoryUsed": 34268233728, + "memoryFree": 91504640, + "memoryUsagePercent": 99.73368644714355, + "memoryEfficiency": 0.2663135528564453, + "cpuCount": 12, + "cpuLoad": 0.2580159505208333, + "platform": "darwin", + "uptime": 1405545 + }, + { + "timestamp": 1764096020434, + "memoryTotal": 34359738368, + "memoryUsed": 34220474368, + "memoryFree": 139264000, + "memoryUsagePercent": 99.59468841552734, + "memoryEfficiency": 0.40531158447265625, + "cpuCount": 12, + "cpuLoad": 0.242431640625, + "platform": "darwin", + "uptime": 1405575 + }, + { + "timestamp": 1764096050433, + "memoryTotal": 34359738368, + "memoryUsed": 34269364224, + "memoryFree": 90374144, + "memoryUsagePercent": 99.73697662353516, + "memoryEfficiency": 0.26302337646484375, + "cpuCount": 12, + "cpuLoad": 0.21695963541666666, + "platform": "darwin", + "uptime": 1405605 + }, + { + "timestamp": 1764096080434, + "memoryTotal": 34359738368, + "memoryUsed": 34230321152, + "memoryFree": 129417216, + "memoryUsagePercent": 99.62334632873535, + "memoryEfficiency": 0.37665367126464844, + "cpuCount": 12, + "cpuLoad": 0.3234049479166667, + "platform": "darwin", + "uptime": 1405635 + }, + { + "timestamp": 1764096110436, + "memoryTotal": 34359738368, + "memoryUsed": 34169356288, + "memoryFree": 190382080, + "memoryUsagePercent": 99.44591522216797, + "memoryEfficiency": 0.5540847778320312, + "cpuCount": 12, + "cpuLoad": 0.3006591796875, + "platform": "darwin", + "uptime": 1405665 + }, + { + "timestamp": 1764096140436, + "memoryTotal": 34359738368, + "memoryUsed": 34284601344, + "memoryFree": 75137024, + "memoryUsagePercent": 99.78132247924805, + "memoryEfficiency": 0.21867752075195312, + "cpuCount": 12, + "cpuLoad": 0.2710367838541667, + "platform": "darwin", + "uptime": 1405695 + }, + { + "timestamp": 1764096170437, + "memoryTotal": 34359738368, + "memoryUsed": 34286157824, + "memoryFree": 73580544, + "memoryUsagePercent": 99.78585243225098, + "memoryEfficiency": 0.21414756774902344, + "cpuCount": 12, + "cpuLoad": 0.21756998697916666, + "platform": "darwin", + "uptime": 1405725 + }, + { + "timestamp": 1764096200438, + "memoryTotal": 34359738368, + "memoryUsed": 34261762048, + "memoryFree": 97976320, + "memoryUsagePercent": 99.71485137939453, + "memoryEfficiency": 0.28514862060546875, + "cpuCount": 12, + "cpuLoad": 0.17069498697916666, + "platform": "darwin", + "uptime": 1405755 + }, + { + "timestamp": 1764096230438, + "memoryTotal": 34359738368, + "memoryUsed": 34277097472, + "memoryFree": 82640896, + "memoryUsagePercent": 99.75948333740234, + "memoryEfficiency": 0.24051666259765625, + "cpuCount": 12, + "cpuLoad": 0.18046061197916666, + "platform": "darwin", + "uptime": 1405785 + }, + { + "timestamp": 1764096260437, + "memoryTotal": 34359738368, + "memoryUsed": 34267283456, + "memoryFree": 92454912, + "memoryUsagePercent": 99.73092079162598, + "memoryEfficiency": 0.26907920837402344, + "cpuCount": 12, + "cpuLoad": 0.17411295572916666, + "platform": "darwin", + "uptime": 1405815 + }, + { + "timestamp": 1764096290439, + "memoryTotal": 34359738368, + "memoryUsed": 34286698496, + "memoryFree": 73039872, + "memoryUsagePercent": 99.78742599487305, + "memoryEfficiency": 0.21257400512695312, + "cpuCount": 12, + "cpuLoad": 0.12089029947916667, + "platform": "darwin", + "uptime": 1405845 + }, + { + "timestamp": 1764096320439, + "memoryTotal": 34359738368, + "memoryUsed": 34206547968, + "memoryFree": 153190400, + "memoryUsagePercent": 99.55415725708008, + "memoryEfficiency": 0.4458427429199219, + "cpuCount": 12, + "cpuLoad": 0.3882649739583333, + "platform": "darwin", + "uptime": 1405875 + }, + { + "timestamp": 1764096350440, + "memoryTotal": 34359738368, + "memoryUsed": 34287501312, + "memoryFree": 72237056, + "memoryUsagePercent": 99.78976249694824, + "memoryEfficiency": 0.2102375030517578, + "cpuCount": 12, + "cpuLoad": 0.2962239583333333, + "platform": "darwin", + "uptime": 1405905 + }, + { + "timestamp": 1764096380440, + "memoryTotal": 34359738368, + "memoryUsed": 34293301248, + "memoryFree": 66437120, + "memoryUsagePercent": 99.80664253234863, + "memoryEfficiency": 0.1933574676513672, + "cpuCount": 12, + "cpuLoad": 0.3089599609375, + "platform": "darwin", + "uptime": 1405935 + }, + { + "timestamp": 1764096410441, + "memoryTotal": 34359738368, + "memoryUsed": 34184593408, + "memoryFree": 175144960, + "memoryUsagePercent": 99.49026107788086, + "memoryEfficiency": 0.5097389221191406, + "cpuCount": 12, + "cpuLoad": 0.2837320963541667, + "platform": "darwin", + "uptime": 1405965 + }, + { + "timestamp": 1764096440442, + "memoryTotal": 34359738368, + "memoryUsed": 34252800000, + "memoryFree": 106938368, + "memoryUsagePercent": 99.68876838684082, + "memoryEfficiency": 0.3112316131591797, + "cpuCount": 12, + "cpuLoad": 0.2565104166666667, + "platform": "darwin", + "uptime": 1405995 + }, + { + "timestamp": 1764096470443, + "memoryTotal": 34359738368, + "memoryUsed": 34276163584, + "memoryFree": 83574784, + "memoryUsagePercent": 99.75676536560059, + "memoryEfficiency": 0.24323463439941406, + "cpuCount": 12, + "cpuLoad": 0.19490559895833334, + "platform": "darwin", + "uptime": 1406025 + }, + { + "timestamp": 1764096500444, + "memoryTotal": 34359738368, + "memoryUsed": 34285436928, + "memoryFree": 74301440, + "memoryUsagePercent": 99.78375434875488, + "memoryEfficiency": 0.2162456512451172, + "cpuCount": 12, + "cpuLoad": 0.22932942708333334, + "platform": "darwin", + "uptime": 1406055 + }, + { + "timestamp": 1764096530445, + "memoryTotal": 34359738368, + "memoryUsed": 34268233728, + "memoryFree": 91504640, + "memoryUsagePercent": 99.73368644714355, + "memoryEfficiency": 0.2663135528564453, + "cpuCount": 12, + "cpuLoad": 0.388916015625, + "platform": "darwin", + "uptime": 1406085 + }, + { + "timestamp": 1764096560447, + "memoryTotal": 34359738368, + "memoryUsed": 34291204096, + "memoryFree": 68534272, + "memoryUsagePercent": 99.80053901672363, + "memoryEfficiency": 0.1994609832763672, + "cpuCount": 12, + "cpuLoad": 0.3090413411458333, + "platform": "darwin", + "uptime": 1406115 + }, + { + "timestamp": 1764096590448, + "memoryTotal": 34359738368, + "memoryUsed": 34277933056, + "memoryFree": 81805312, + "memoryUsagePercent": 99.76191520690918, + "memoryEfficiency": 0.2380847930908203, + "cpuCount": 12, + "cpuLoad": 0.2938232421875, + "platform": "darwin", + "uptime": 1406145 + }, + { + "timestamp": 1764096620449, + "memoryTotal": 34359738368, + "memoryUsed": 34281750528, + "memoryFree": 77987840, + "memoryUsagePercent": 99.77302551269531, + "memoryEfficiency": 0.2269744873046875, + "cpuCount": 12, + "cpuLoad": 0.529052734375, + "platform": "darwin", + "uptime": 1406175 + }, + { + "timestamp": 1764096650450, + "memoryTotal": 34359738368, + "memoryUsed": 34291400704, + "memoryFree": 68337664, + "memoryUsagePercent": 99.80111122131348, + "memoryEfficiency": 0.19888877868652344, + "cpuCount": 12, + "cpuLoad": 0.4219563802083333, + "platform": "darwin", + "uptime": 1406205 + }, + { + "timestamp": 1764096680451, + "memoryTotal": 34359738368, + "memoryUsed": 34276442112, + "memoryFree": 83296256, + "memoryUsagePercent": 99.75757598876953, + "memoryEfficiency": 0.24242401123046875, + "cpuCount": 12, + "cpuLoad": 0.3659261067708333, + "platform": "darwin", + "uptime": 1406235 + }, + { + "timestamp": 1764096710452, + "memoryTotal": 34359738368, + "memoryUsed": 34205532160, + "memoryFree": 154206208, + "memoryUsagePercent": 99.55120086669922, + "memoryEfficiency": 0.44879913330078125, + "cpuCount": 12, + "cpuLoad": 0.2870686848958333, + "platform": "darwin", + "uptime": 1406265 + }, + { + "timestamp": 1764096740440, + "memoryTotal": 34359738368, + "memoryUsed": 34268577792, + "memoryFree": 91160576, + "memoryUsagePercent": 99.73468780517578, + "memoryEfficiency": 0.26531219482421875, + "cpuCount": 12, + "cpuLoad": 0.24650065104166666, + "platform": "darwin", + "uptime": 1406295 + }, + { + "timestamp": 1764096770433, + "memoryTotal": 34359738368, + "memoryUsed": 34282176512, + "memoryFree": 77561856, + "memoryUsagePercent": 99.77426528930664, + "memoryEfficiency": 0.22573471069335938, + "cpuCount": 12, + "cpuLoad": 0.3543294270833333, + "platform": "darwin", + "uptime": 1406325 + }, + { + "timestamp": 1764096800434, + "memoryTotal": 34359738368, + "memoryUsed": 34291351552, + "memoryFree": 68386816, + "memoryUsagePercent": 99.80096817016602, + "memoryEfficiency": 0.19903182983398438, + "cpuCount": 12, + "cpuLoad": 0.3053385416666667, + "platform": "darwin", + "uptime": 1406355 + }, + { + "timestamp": 1764096830435, + "memoryTotal": 34359738368, + "memoryUsed": 34283077632, + "memoryFree": 76660736, + "memoryUsagePercent": 99.77688789367676, + "memoryEfficiency": 0.2231121063232422, + "cpuCount": 12, + "cpuLoad": 0.2605387369791667, + "platform": "darwin", + "uptime": 1406385 + }, + { + "timestamp": 1764096860434, + "memoryTotal": 34359738368, + "memoryUsed": 34253029376, + "memoryFree": 106708992, + "memoryUsagePercent": 99.6894359588623, + "memoryEfficiency": 0.3105640411376953, + "cpuCount": 12, + "cpuLoad": 0.2540283203125, + "platform": "darwin", + "uptime": 1406415 + }, + { + "timestamp": 1764096890435, + "memoryTotal": 34359738368, + "memoryUsed": 34268332032, + "memoryFree": 91406336, + "memoryUsagePercent": 99.73397254943848, + "memoryEfficiency": 0.26602745056152344, + "cpuCount": 12, + "cpuLoad": 0.2232666015625, + "platform": "darwin", + "uptime": 1406445 + }, + { + "timestamp": 1764096920437, + "memoryTotal": 34359738368, + "memoryUsed": 34277654528, + "memoryFree": 82083840, + "memoryUsagePercent": 99.76110458374023, + "memoryEfficiency": 0.23889541625976562, + "cpuCount": 12, + "cpuLoad": 0.1912841796875, + "platform": "darwin", + "uptime": 1406475 + }, + { + "timestamp": 1764096950438, + "memoryTotal": 34359738368, + "memoryUsed": 34273542144, + "memoryFree": 86196224, + "memoryUsagePercent": 99.74913597106934, + "memoryEfficiency": 0.25086402893066406, + "cpuCount": 12, + "cpuLoad": 0.2139892578125, + "platform": "darwin", + "uptime": 1406505 + }, + { + "timestamp": 1764096980439, + "memoryTotal": 34359738368, + "memoryUsed": 34234957824, + "memoryFree": 124780544, + "memoryUsagePercent": 99.6368408203125, + "memoryEfficiency": 0.3631591796875, + "cpuCount": 12, + "cpuLoad": 0.17557779947916666, + "platform": "darwin", + "uptime": 1406535 + }, + { + "timestamp": 1764097010439, + "memoryTotal": 34359738368, + "memoryUsed": 34122448896, + "memoryFree": 237289472, + "memoryUsagePercent": 99.30939674377441, + "memoryEfficiency": 0.6906032562255859, + "cpuCount": 12, + "cpuLoad": 0.4293619791666667, + "platform": "darwin", + "uptime": 1406565 + }, + { + "timestamp": 1764097040441, + "memoryTotal": 34359738368, + "memoryUsed": 34291171328, + "memoryFree": 68567040, + "memoryUsagePercent": 99.80044364929199, + "memoryEfficiency": 0.1995563507080078, + "cpuCount": 12, + "cpuLoad": 0.2848714192708333, + "platform": "darwin", + "uptime": 1406595 + }, + { + "timestamp": 1764097070442, + "memoryTotal": 34359738368, + "memoryUsed": 34286403584, + "memoryFree": 73334784, + "memoryUsagePercent": 99.78656768798828, + "memoryEfficiency": 0.21343231201171875, + "cpuCount": 12, + "cpuLoad": 0.2517496744791667, + "platform": "darwin", + "uptime": 1406625 + }, + { + "timestamp": 1764097100443, + "memoryTotal": 34359738368, + "memoryUsed": 34253127680, + "memoryFree": 106610688, + "memoryUsagePercent": 99.68972206115723, + "memoryEfficiency": 0.31027793884277344, + "cpuCount": 12, + "cpuLoad": 0.4106852213541667, + "platform": "darwin", + "uptime": 1406655 + }, + { + "timestamp": 1764097130444, + "memoryTotal": 34359738368, + "memoryUsed": 34244886528, + "memoryFree": 114851840, + "memoryUsagePercent": 99.66573715209961, + "memoryEfficiency": 0.3342628479003906, + "cpuCount": 12, + "cpuLoad": 0.8642171223958334, + "platform": "darwin", + "uptime": 1406685 + }, + { + "timestamp": 1764097160444, + "memoryTotal": 34359738368, + "memoryUsed": 34267217920, + "memoryFree": 92520448, + "memoryUsagePercent": 99.7307300567627, + "memoryEfficiency": 0.2692699432373047, + "cpuCount": 12, + "cpuLoad": 3.2634684244791665, + "platform": "darwin", + "uptime": 1406715 + }, + { + "timestamp": 1764097190444, + "memoryTotal": 34359738368, + "memoryUsed": 34263367680, + "memoryFree": 96370688, + "memoryUsagePercent": 99.71952438354492, + "memoryEfficiency": 0.2804756164550781, + "cpuCount": 12, + "cpuLoad": 3.0285237630208335, + "platform": "darwin", + "uptime": 1406745 + }, + { + "timestamp": 1764097220445, + "memoryTotal": 34359738368, + "memoryUsed": 34243280896, + "memoryFree": 116457472, + "memoryUsagePercent": 99.66106414794922, + "memoryEfficiency": 0.33893585205078125, + "cpuCount": 12, + "cpuLoad": 1.9490152994791667, + "platform": "darwin", + "uptime": 1406775 + }, + { + "timestamp": 1764097250447, + "memoryTotal": 34359738368, + "memoryUsed": 34119188480, + "memoryFree": 240549888, + "memoryUsagePercent": 99.29990768432617, + "memoryEfficiency": 0.7000923156738281, + "cpuCount": 12, + "cpuLoad": 1.6121419270833333, + "platform": "darwin", + "uptime": 1406805 + }, + { + "timestamp": 1764097280447, + "memoryTotal": 34359738368, + "memoryUsed": 34235678720, + "memoryFree": 124059648, + "memoryUsagePercent": 99.6389389038086, + "memoryEfficiency": 0.36106109619140625, + "cpuCount": 12, + "cpuLoad": 1.1004638671875, + "platform": "darwin", + "uptime": 1406835 + }, + { + "timestamp": 1764097310447, + "memoryTotal": 34359738368, + "memoryUsed": 34204434432, + "memoryFree": 155303936, + "memoryUsagePercent": 99.54800605773926, + "memoryEfficiency": 0.4519939422607422, + "cpuCount": 12, + "cpuLoad": 0.9708658854166666, + "platform": "darwin", + "uptime": 1406865 + }, + { + "timestamp": 1764097340448, + "memoryTotal": 34359738368, + "memoryUsed": 34260271104, + "memoryFree": 99467264, + "memoryUsagePercent": 99.71051216125488, + "memoryEfficiency": 0.2894878387451172, + "cpuCount": 12, + "cpuLoad": 1.0231526692708333, + "platform": "darwin", + "uptime": 1406895 + }, + { + "timestamp": 1764097370448, + "memoryTotal": 34359738368, + "memoryUsed": 34294972416, + "memoryFree": 64765952, + "memoryUsagePercent": 99.8115062713623, + "memoryEfficiency": 0.1884937286376953, + "cpuCount": 12, + "cpuLoad": 0.9033610026041666, + "platform": "darwin", + "uptime": 1406925 + }, + { + "timestamp": 1764097400451, + "memoryTotal": 34359738368, + "memoryUsed": 34284404736, + "memoryFree": 75333632, + "memoryUsagePercent": 99.7807502746582, + "memoryEfficiency": 0.21924972534179688, + "cpuCount": 12, + "cpuLoad": 0.8120930989583334, + "platform": "darwin", + "uptime": 1406955 + }, + { + "timestamp": 1764097430450, + "memoryTotal": 34359738368, + "memoryUsed": 34255929344, + "memoryFree": 103809024, + "memoryUsagePercent": 99.6978759765625, + "memoryEfficiency": 0.3021240234375, + "cpuCount": 12, + "cpuLoad": 1.5324300130208333, + "platform": "darwin", + "uptime": 1406985 + }, + { + "timestamp": 1764097460450, + "memoryTotal": 34359738368, + "memoryUsed": 34290597888, + "memoryFree": 69140480, + "memoryUsagePercent": 99.79877471923828, + "memoryEfficiency": 0.20122528076171875, + "cpuCount": 12, + "cpuLoad": 1.8724365234375, + "platform": "darwin", + "uptime": 1407015 + }, + { + "timestamp": 1764097490451, + "memoryTotal": 34359738368, + "memoryUsed": 34279669760, + "memoryFree": 80068608, + "memoryUsagePercent": 99.76696968078613, + "memoryEfficiency": 0.2330303192138672, + "cpuCount": 12, + "cpuLoad": 2.6695149739583335, + "platform": "darwin", + "uptime": 1407045 + }, + { + "timestamp": 1764097520451, + "memoryTotal": 34359738368, + "memoryUsed": 34271559680, + "memoryFree": 88178688, + "memoryUsagePercent": 99.74336624145508, + "memoryEfficiency": 0.2566337585449219, + "cpuCount": 12, + "cpuLoad": 2.5982666015625, + "platform": "darwin", + "uptime": 1407075 + }, + { + "timestamp": 1764097550453, + "memoryTotal": 34359738368, + "memoryUsed": 34251505664, + "memoryFree": 108232704, + "memoryUsagePercent": 99.68500137329102, + "memoryEfficiency": 0.3149986267089844, + "cpuCount": 12, + "cpuLoad": 2.2987060546875, + "platform": "darwin", + "uptime": 1407105 + }, + { + "timestamp": 1764097580454, + "memoryTotal": 34359738368, + "memoryUsed": 34279129088, + "memoryFree": 80609280, + "memoryUsagePercent": 99.76539611816406, + "memoryEfficiency": 0.2346038818359375, + "cpuCount": 12, + "cpuLoad": 1.9098307291666667, + "platform": "darwin", + "uptime": 1407135 + }, + { + "timestamp": 1764097610454, + "memoryTotal": 34359738368, + "memoryUsed": 34171912192, + "memoryFree": 187826176, + "memoryUsagePercent": 99.45335388183594, + "memoryEfficiency": 0.5466461181640625, + "cpuCount": 12, + "cpuLoad": 1.3437093098958333, + "platform": "darwin", + "uptime": 1407165 + }, + { + "timestamp": 1764097640455, + "memoryTotal": 34359738368, + "memoryUsed": 34189017088, + "memoryFree": 170721280, + "memoryUsagePercent": 99.50313568115234, + "memoryEfficiency": 0.49686431884765625, + "cpuCount": 12, + "cpuLoad": 2.6607259114583335, + "platform": "darwin", + "uptime": 1407195 + }, + { + "timestamp": 1764097670455, + "memoryTotal": 34359738368, + "memoryUsed": 34258468864, + "memoryFree": 101269504, + "memoryUsagePercent": 99.70526695251465, + "memoryEfficiency": 0.29473304748535156, + "cpuCount": 12, + "cpuLoad": 3.6142985026041665, + "platform": "darwin", + "uptime": 1407225 + }, + { + "timestamp": 1764097700457, + "memoryTotal": 34359738368, + "memoryUsed": 34281603072, + "memoryFree": 78135296, + "memoryUsagePercent": 99.77259635925293, + "memoryEfficiency": 0.2274036407470703, + "cpuCount": 12, + "cpuLoad": 3.2880859375, + "platform": "darwin", + "uptime": 1407255 + }, + { + "timestamp": 1764097730456, + "memoryTotal": 34359738368, + "memoryUsed": 34274230272, + "memoryFree": 85508096, + "memoryUsagePercent": 99.75113868713379, + "memoryEfficiency": 0.24886131286621094, + "cpuCount": 12, + "cpuLoad": 2.6459554036458335, + "platform": "darwin", + "uptime": 1407285 + }, + { + "timestamp": 1764097760458, + "memoryTotal": 34359738368, + "memoryUsed": 34295021568, + "memoryFree": 64716800, + "memoryUsagePercent": 99.81164932250977, + "memoryEfficiency": 0.18835067749023438, + "cpuCount": 12, + "cpuLoad": 2.3086751302083335, + "platform": "darwin", + "uptime": 1407315 + }, + { + "timestamp": 1764097790458, + "memoryTotal": 34359738368, + "memoryUsed": 34287091712, + "memoryFree": 72646656, + "memoryUsagePercent": 99.78857040405273, + "memoryEfficiency": 0.21142959594726562, + "cpuCount": 12, + "cpuLoad": 1.6074625651041667, + "platform": "darwin", + "uptime": 1407345 + }, + { + "timestamp": 1764097820459, + "memoryTotal": 34359738368, + "memoryUsed": 34265366528, + "memoryFree": 94371840, + "memoryUsagePercent": 99.725341796875, + "memoryEfficiency": 0.274658203125, + "cpuCount": 12, + "cpuLoad": 1.0528971354166667, + "platform": "darwin", + "uptime": 1407375 + }, + { + "timestamp": 1764097850459, + "memoryTotal": 34359738368, + "memoryUsed": 34287009792, + "memoryFree": 72728576, + "memoryUsagePercent": 99.78833198547363, + "memoryEfficiency": 0.2116680145263672, + "cpuCount": 12, + "cpuLoad": 0.7093912760416666, + "platform": "darwin", + "uptime": 1407405 + }, + { + "timestamp": 1764097880459, + "memoryTotal": 34359738368, + "memoryUsed": 34295349248, + "memoryFree": 64389120, + "memoryUsagePercent": 99.81260299682617, + "memoryEfficiency": 0.18739700317382812, + "cpuCount": 12, + "cpuLoad": 0.5563151041666666, + "platform": "darwin", + "uptime": 1407435 + }, + { + "timestamp": 1764097910460, + "memoryTotal": 34359738368, + "memoryUsed": 34180988928, + "memoryFree": 178749440, + "memoryUsagePercent": 99.47977066040039, + "memoryEfficiency": 0.5202293395996094, + "cpuCount": 12, + "cpuLoad": 0.4529215494791667, + "platform": "darwin", + "uptime": 1407465 + }, + { + "timestamp": 1764097940461, + "memoryTotal": 34359738368, + "memoryUsed": 34184527872, + "memoryFree": 175210496, + "memoryUsagePercent": 99.49007034301758, + "memoryEfficiency": 0.5099296569824219, + "cpuCount": 12, + "cpuLoad": 0.3614908854166667, + "platform": "darwin", + "uptime": 1407495 + }, + { + "timestamp": 1764097970461, + "memoryTotal": 34359738368, + "memoryUsed": 34293497856, + "memoryFree": 66240512, + "memoryUsagePercent": 99.80721473693848, + "memoryEfficiency": 0.19278526306152344, + "cpuCount": 12, + "cpuLoad": 0.2618001302083333, + "platform": "darwin", + "uptime": 1407525 + }, + { + "timestamp": 1764098000464, + "memoryTotal": 34359738368, + "memoryUsed": 34299379712, + "memoryFree": 60358656, + "memoryUsagePercent": 99.82433319091797, + "memoryEfficiency": 0.17566680908203125, + "cpuCount": 12, + "cpuLoad": 0.230224609375, + "platform": "darwin", + "uptime": 1407555 + }, + { + "timestamp": 1764098030472, + "memoryTotal": 34359738368, + "memoryUsed": 34277081088, + "memoryFree": 82657280, + "memoryUsagePercent": 99.75943565368652, + "memoryEfficiency": 0.24056434631347656, + "cpuCount": 12, + "cpuLoad": 0.20316569010416666, + "platform": "darwin", + "uptime": 1407585 + }, + { + "timestamp": 1764098060481, + "memoryTotal": 34359738368, + "memoryUsed": 34285518848, + "memoryFree": 74219520, + "memoryUsagePercent": 99.78399276733398, + "memoryEfficiency": 0.21600723266601562, + "cpuCount": 12, + "cpuLoad": 0.20271809895833334, + "platform": "darwin", + "uptime": 1407615 + }, + { + "timestamp": 1764098090483, + "memoryTotal": 34359738368, + "memoryUsed": 34273460224, + "memoryFree": 86278144, + "memoryUsagePercent": 99.74889755249023, + "memoryEfficiency": 0.2511024475097656, + "cpuCount": 12, + "cpuLoad": 0.1566162109375, + "platform": "darwin", + "uptime": 1407645 + }, + { + "timestamp": 1764098120485, + "memoryTotal": 34359738368, + "memoryUsed": 34277933056, + "memoryFree": 81805312, + "memoryUsagePercent": 99.76191520690918, + "memoryEfficiency": 0.2380847930908203, + "cpuCount": 12, + "cpuLoad": 0.169921875, + "platform": "darwin", + "uptime": 1407675 + }, + { + "timestamp": 1764098150485, + "memoryTotal": 34359738368, + "memoryUsed": 34287484928, + "memoryFree": 72253440, + "memoryUsagePercent": 99.78971481323242, + "memoryEfficiency": 0.21028518676757812, + "cpuCount": 12, + "cpuLoad": 0.20654296875, + "platform": "darwin", + "uptime": 1407705 + }, + { + "timestamp": 1764098180485, + "memoryTotal": 34359738368, + "memoryUsed": 34277752832, + "memoryFree": 81985536, + "memoryUsagePercent": 99.76139068603516, + "memoryEfficiency": 0.23860931396484375, + "cpuCount": 12, + "cpuLoad": 0.19771321614583334, + "platform": "darwin", + "uptime": 1407735 + }, + { + "timestamp": 1764098210486, + "memoryTotal": 34359738368, + "memoryUsed": 34225700864, + "memoryFree": 134037504, + "memoryUsagePercent": 99.60989952087402, + "memoryEfficiency": 0.39010047912597656, + "cpuCount": 12, + "cpuLoad": 0.14595540364583334, + "platform": "darwin", + "uptime": 1407765 + }, + { + "timestamp": 1764098240488, + "memoryTotal": 34359738368, + "memoryUsed": 34288664576, + "memoryFree": 71073792, + "memoryUsagePercent": 99.79314804077148, + "memoryEfficiency": 0.20685195922851562, + "cpuCount": 12, + "cpuLoad": 0.1617431640625, + "platform": "darwin", + "uptime": 1407795 + }, + { + "timestamp": 1764098270488, + "memoryTotal": 34359738368, + "memoryUsed": 34269609984, + "memoryFree": 90128384, + "memoryUsagePercent": 99.73769187927246, + "memoryEfficiency": 0.26230812072753906, + "cpuCount": 12, + "cpuLoad": 0.24190266927083334, + "platform": "darwin", + "uptime": 1407825 + }, + { + "timestamp": 1764098300489, + "memoryTotal": 34359738368, + "memoryUsed": 34266628096, + "memoryFree": 93110272, + "memoryUsagePercent": 99.72901344299316, + "memoryEfficiency": 0.27098655700683594, + "cpuCount": 12, + "cpuLoad": 0.22196451822916666, + "platform": "darwin", + "uptime": 1407855 } ] \ No newline at end of file diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..6d2b9305f --- /dev/null +++ b/.dockerignore @@ -0,0 +1,37 @@ +# TypeScript build cache - must be excluded to prevent incremental build issues +**/*.tsbuildinfo + +# Dependencies +**/node_modules +**/.pnpm-store + +# Build outputs are excluded to force fresh builds +**/dist + +# Development files +**/.env +**/.env.local +**/.env.*.local + +# IDE +**/.idea +**/.vscode +**/*.swp +**/*.swo + +# OS files +**/.DS_Store +**/Thumbs.db + +# Logs +**/*.log +**/npm-debug.log* +**/pnpm-debug.log* + +# Test files +**/coverage +**/.nyc_output + +# Git +.git +.gitignore diff --git a/chat/TESTING_GUIDE.md b/chat/TESTING_GUIDE.md new file mode 100644 index 000000000..2184d7653 --- /dev/null +++ b/chat/TESTING_GUIDE.md @@ -0,0 +1,681 @@ +# Testing Guide - Mana Core Auth Integration + +This guide walks you through testing the Chat project with Mana Core Auth. + +--- + +## Prerequisites + +Before testing, make sure you have: +- ✅ Node.js 20+ +- ✅ pnpm installed +- ✅ All dependencies installed (`pnpm install` from monorepo root) +- ✅ PostgreSQL running (or Docker for Mana Core Auth) + +--- + +## Step 1: Generate JWT Keys for Mana Core Auth + +Mana Core Auth requires RS256 JWT keys. Generate them first: + +```bash +cd mana-core-auth +chmod +x scripts/generate-keys.sh +./scripts/generate-keys.sh +``` + +**You'll see output like:** +``` +Generating RS256 key pair... +Keys generated successfully! + +Private key: private.pem +Public key: public.pem + +Add these to your .env file: + +JWT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKC... +-----END RSA PRIVATE KEY-----" + +JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY----- +MIIBIjANBg... +-----END PUBLIC KEY-----" +``` + +**Copy these keys - you'll need them in the next step!** + +--- + +## Step 2: Configure Environment Variables + +### 2.1 Mana Core Auth + +```bash +cd mana-core-auth +cp .env.example .env +``` + +Edit `mana-core-auth/.env` and add: + +```env +# Database +DATABASE_URL=postgresql://manacore:password@localhost:5432/manacore + +# Paste the keys from Step 1 +JWT_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY----- +YOUR_PRIVATE_KEY_HERE +-----END RSA PRIVATE KEY-----" + +JWT_PUBLIC_KEY="-----BEGIN PUBLIC KEY----- +YOUR_PUBLIC_KEY_HERE +-----END PUBLIC KEY-----" + +# Other settings (use defaults for now) +REDIS_PASSWORD= +CORS_ORIGINS=http://localhost:5173,http://localhost:8081 +PORT=3001 +``` + +### 2.2 Chat Backend + +```bash +cd ../chat/backend +cp .env.example .env +``` + +Edit `chat/backend/.env`: + +```env +# Azure OpenAI (your existing keys) +AZURE_OPENAI_ENDPOINT=https://your-endpoint.openai.azure.com +AZURE_OPENAI_API_KEY=your-api-key +AZURE_OPENAI_API_VERSION=2024-12-01-preview + +# Mana Core Auth (NEW) +MANA_CORE_AUTH_URL=http://localhost:3001 + +# Supabase (for database, not auth) +SUPABASE_URL=https://your-project.supabase.co +SUPABASE_SERVICE_KEY=your-service-key + +# Server +PORT=3002 +``` + +### 2.3 Chat Web App + +```bash +cd ../apps/web +cp .env.example .env +``` + +Edit `chat/apps/web/.env`: + +```env +# Mana Core Auth (NEW) +PUBLIC_MANA_CORE_AUTH_URL=http://localhost:3001 + +# Backend API (NEW PORT) +PUBLIC_BACKEND_URL=http://localhost:3002 + +# Supabase (for database) +PUBLIC_SUPABASE_URL=https://your-project.supabase.co +PUBLIC_SUPABASE_ANON_KEY=your-anon-key +``` + +### 2.4 Chat Mobile App + +```bash +cd ../mobile +cp .env.example .env +``` + +Edit `chat/apps/mobile/.env`: + +```env +# Mana Core Auth (NEW) +EXPO_PUBLIC_MANA_CORE_AUTH_URL=http://localhost:3001 + +# Backend API (NEW PORT) +EXPO_PUBLIC_BACKEND_URL=http://localhost:3002 + +# Supabase (for database) +EXPO_PUBLIC_SUPABASE_URL=https://your-project.supabase.co +EXPO_PUBLIC_SUPABASE_ANON_KEY=your-anon-key +``` + +--- + +## Step 3: Start Services (4 Terminals) + +### Terminal 1: Mana Core Auth + +```bash +cd mana-core-auth + +# Start PostgreSQL (if using Docker) +docker-compose up postgres -d + +# Run migrations +pnpm migration:run + +# Start auth service +pnpm start:dev +``` + +**Expected output:** +``` +🚀 Mana Core Auth running on: http://localhost:3001 +📚 Environment: development +``` + +**Leave this running!** + +### Terminal 2: Chat Backend + +```bash +cd chat/backend +pnpm start:dev +``` + +**Expected output:** +``` +[Nest] LOG [NestApplication] Nest application successfully started +[Nest] LOG Listening on port 3002 +``` + +**Leave this running!** + +### Terminal 3: Chat Web App + +```bash +cd chat/apps/web +pnpm dev +``` + +**Expected output:** +``` + VITE v5.x.x ready in xxx ms + + ➜ Local: http://localhost:5173/ + ➜ Network: use --host to expose +``` + +**Leave this running!** + +### Terminal 4: Chat Mobile App (Optional) + +```bash +cd chat/apps/mobile +pnpm dev +``` + +**Expected output:** +``` +› Metro waiting on exp://localhost:8081 +› Scan the QR code above with Expo Go (Android) or Camera (iOS) +``` + +--- + +## Step 4: Test Web App Authentication + +### 4.1 Open Web App + +Open browser: http://localhost:5173 + +### 4.2 Register New User + +1. Click **"Register"** or go to `/register` +2. Enter test credentials: + - Email: `test@example.com` + - Password: `Test1234!` +3. Click **"Register"** + +**Expected:** +- Registration succeeds +- Automatically redirects to login +- Login happens automatically +- You're redirected to the main app + +### 4.3 Check Authentication + +Open browser console (F12) and run: + +```javascript +// Check if user is authenticated +console.log('Authenticated:', window.localStorage.getItem('@auth/appToken')); +``` + +**Expected:** You should see a JWT token + +### 4.4 Check Credits + +In browser console: + +```javascript +// Get credit balance +const authStore = window.authStore; // If exported globally +// Or navigate to a page that displays credits +``` + +**Expected:** +- 150 initial credits +- API call to `/api/v1/credits/balance` succeeds + +### 4.5 Test Logout + +1. Click **"Logout"** button +2. Check you're redirected to login page +3. Try accessing protected route → Should redirect to login + +--- + +## Step 5: Test Backend API + +### 5.1 Get Access Token + +First, login via web app, then get the token from localStorage: + +**In browser console:** +```javascript +const token = localStorage.getItem('@auth/appToken'); +console.log(token); +// Copy this token! +``` + +### 5.2 Test Protected Endpoints + +Use `curl` or Postman/Insomnia: + +#### Test 1: Get AI Models (Protected) + +```bash +# Without token - Should fail with 401 +curl http://localhost:3002/api/chat/models + +# With token - Should succeed +curl http://localhost:3002/api/chat/models \ + -H "Authorization: Bearer YOUR_TOKEN_HERE" +``` + +**Expected Response:** +```json +[ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "name": "GPT-O3-Mini", + "description": "Azure OpenAI O3-Mini: Effizientes Modell für schnelle Antworten.", + ... + }, + ... +] +``` + +#### Test 2: List Conversations (Protected) + +```bash +curl http://localhost:3002/api/conversations \ + -H "Authorization: Bearer YOUR_TOKEN_HERE" +``` + +**Expected:** Array of conversations (may be empty for new user) + +#### Test 3: Create Conversation (Protected) + +```bash +curl -X POST http://localhost:3002/api/conversations \ + -H "Authorization: Bearer YOUR_TOKEN_HERE" \ + -H "Content-Type: application/json" \ + -d '{ + "modelId": "550e8400-e29b-41d4-a716-446655440000", + "title": "Test Conversation" + }' +``` + +**Expected:** New conversation object + +#### Test 4: Chat Completion (Protected) + +```bash +curl -X POST http://localhost:3002/api/chat/completions \ + -H "Authorization: Bearer YOUR_TOKEN_HERE" \ + -H "Content-Type: application/json" \ + -d '{ + "modelId": "550e8400-e29b-41d4-a716-446655440000", + "messages": [ + {"role": "user", "content": "Say hello!"} + ] + }' +``` + +**Expected:** AI response with content and usage stats + +--- + +## Step 6: Test Mobile App (Optional) + +### 6.1 Install Expo Go + +- **iOS:** Install from App Store +- **Android:** Install from Google Play Store + +### 6.2 Scan QR Code + +1. Look at Terminal 4 (mobile app terminal) +2. Scan the QR code with: + - iOS: Camera app + - Android: Expo Go app + +### 6.3 Register/Login + +1. App opens to login screen +2. Tap **"Register"** +3. Enter credentials: + - Email: `mobile@example.com` + - Password: `Mobile1234!` +4. Tap **"Register"** + +**Expected:** +- Registration succeeds +- Auto-login +- Redirected to chat interface + +### 6.4 Test Chat + +1. Try sending a message +2. Should get AI response +3. Check conversation is saved + +--- + +## Step 7: Test Token Validation + +### 7.1 Test Invalid Token + +```bash +curl http://localhost:3002/api/chat/models \ + -H "Authorization: Bearer invalid-token-here" +``` + +**Expected:** +```json +{ + "statusCode": 401, + "message": "Invalid token" +} +``` + +### 7.2 Test Expired Token + +After 15 minutes, the access token expires. Try using it: + +```bash +curl http://localhost:3002/api/chat/models \ + -H "Authorization: Bearer EXPIRED_TOKEN" +``` + +**Expected:** 401 Unauthorized + +### 7.3 Test Token Refresh + +The `@manacore/shared-auth` package automatically refreshes tokens. To test: + +1. Wait 15+ minutes (or change `JWT_ACCESS_TOKEN_EXPIRY=1m` for testing) +2. Make an API call from web/mobile app +3. Check Network tab - should see automatic refresh +4. Request succeeds with new token + +--- + +## Step 8: Test Credit System + +### 8.1 Check Initial Balance + +```bash +curl http://localhost:3001/api/v1/credits/balance \ + -H "Authorization: Bearer YOUR_TOKEN" +``` + +**Expected:** +```json +{ + "balance": 0, + "freeCreditsRemaining": 150, + "totalEarned": 0, + "totalSpent": 0, + "dailyFreeCredits": 5 +} +``` + +### 8.2 Use Credits + +```bash +curl -X POST http://localhost:3001/api/v1/credits/use \ + -H "Authorization: Bearer YOUR_TOKEN" \ + -H "Content-Type: application/json" \ + -d '{ + "amount": 10, + "appId": "chat", + "description": "Test chat completion", + "idempotencyKey": "test-123" + }' +``` + +**Expected:** +```json +{ + "success": true, + "transaction": { ... }, + "newBalance": { + "balance": 0, + "freeCreditsRemaining": 140, + "totalSpent": 10 + } +} +``` + +### 8.3 Check Transaction History + +```bash +curl http://localhost:3001/api/v1/credits/transactions \ + -H "Authorization: Bearer YOUR_TOKEN" +``` + +**Expected:** Array with signup bonus and usage transactions + +--- + +## Common Issues & Solutions + +### Issue 1: "Connection refused" to port 3001 + +**Problem:** Mana Core Auth not running + +**Solution:** +```bash +cd mana-core-auth +pnpm start:dev +``` + +### Issue 2: "Invalid token" errors + +**Problem:** JWT keys mismatch or token expired + +**Solution:** +1. Clear tokens: `localStorage.clear()` in browser +2. Login again +3. Verify JWT keys are identical in Mana Core Auth .env + +### Issue 3: CORS errors in browser + +**Problem:** Web app URL not in CORS whitelist + +**Solution:** +Edit `mana-core-auth/.env`: +```env +CORS_ORIGINS=http://localhost:5173,http://localhost:8081 +``` + +Restart Mana Core Auth + +### Issue 4: "Database connection failed" + +**Problem:** PostgreSQL not running + +**Solution:** +```bash +# If using Docker +cd mana-core-auth +docker-compose up postgres -d + +# Check it's running +docker-compose ps +``` + +### Issue 5: "Port 3001 already in use" + +**Problem:** Another service using port 3001 + +**Solution:** +```bash +# Find what's using the port +lsof -ti:3001 + +# Kill it +kill -9 $(lsof -ti:3001) +``` + +### Issue 6: Mobile app can't connect + +**Problem:** Using localhost on mobile device + +**Solution:** +Edit `chat/apps/mobile/.env`: +```env +# Replace localhost with your computer's IP +EXPO_PUBLIC_MANA_CORE_AUTH_URL=http://192.168.1.XXX:3001 +EXPO_PUBLIC_BACKEND_URL=http://192.168.1.XXX:3002 +``` + +Get your IP: +```bash +# macOS +ipconfig getifaddr en0 + +# Linux +hostname -I +``` + +--- + +## Quick Test Script + +Save this as `test-auth.sh`: + +```bash +#!/bin/bash + +echo "🧪 Testing Mana Core Auth Integration" +echo "" + +# Test 1: Register user +echo "1️⃣ Testing registration..." +REGISTER_RESPONSE=$(curl -s -X POST http://localhost:3001/api/v1/auth/register \ + -H "Content-Type: application/json" \ + -d '{"email":"test@example.com","password":"Test1234!"}') + +echo "Response: $REGISTER_RESPONSE" +echo "" + +# Test 2: Login +echo "2️⃣ Testing login..." +LOGIN_RESPONSE=$(curl -s -X POST http://localhost:3001/api/v1/auth/login \ + -H "Content-Type: application/json" \ + -d '{"email":"test@example.com","password":"Test1234!"}') + +# Extract token +TOKEN=$(echo $LOGIN_RESPONSE | grep -o '"accessToken":"[^"]*' | cut -d'"' -f4) + +if [ -z "$TOKEN" ]; then + echo "❌ Login failed!" + echo "Response: $LOGIN_RESPONSE" + exit 1 +fi + +echo "✅ Login successful! Token: ${TOKEN:0:50}..." +echo "" + +# Test 3: Get credits +echo "3️⃣ Testing credit balance..." +CREDITS_RESPONSE=$(curl -s http://localhost:3001/api/v1/credits/balance \ + -H "Authorization: Bearer $TOKEN") + +echo "Response: $CREDITS_RESPONSE" +echo "" + +# Test 4: Backend protected endpoint +echo "4️⃣ Testing backend protected endpoint..." +MODELS_RESPONSE=$(curl -s http://localhost:3002/api/chat/models \ + -H "Authorization: Bearer $TOKEN") + +echo "Response: $MODELS_RESPONSE" +echo "" + +echo "✅ All tests complete!" +``` + +Make it executable and run: +```bash +chmod +x test-auth.sh +./test-auth.sh +``` + +--- + +## Testing Checklist + +Use this checklist to verify everything works: + +### Mana Core Auth ✅ +- [ ] Service starts on port 3001 +- [ ] Can register new user +- [ ] Can login with credentials +- [ ] Can refresh access token +- [ ] Can logout +- [ ] Can check credit balance +- [ ] Can use credits + +### Chat Backend ✅ +- [ ] Service starts on port 3002 +- [ ] Protected endpoints return 401 without token +- [ ] Protected endpoints work with valid token +- [ ] Can list AI models +- [ ] Can create conversation +- [ ] Can list conversations +- [ ] Can send messages + +### Web App ✅ +- [ ] App loads on port 5173 +- [ ] Can register new user +- [ ] Can login +- [ ] Can logout +- [ ] Can access protected routes +- [ ] Can send chat messages +- [ ] Can see conversations + +### Mobile App ✅ +- [ ] App loads in Expo Go +- [ ] Can register new user +- [ ] Can login +- [ ] Can logout +- [ ] Can send chat messages +- [ ] Can see conversations +- [ ] Tokens persist after app restart + +--- + +**Status:** Ready for Testing! 🚀 + +Follow these steps and check off items as you test. If you encounter issues, check the "Common Issues" section above. diff --git a/chat/apps/mobile/services/api.ts b/chat/apps/mobile/services/api.ts new file mode 100644 index 000000000..3dfb584b9 --- /dev/null +++ b/chat/apps/mobile/services/api.ts @@ -0,0 +1,633 @@ +/** + * API Client for Chat Mobile App + * Handles all communication with the NestJS backend + */ +import * as SecureStore from 'expo-secure-store'; + +const BACKEND_URL = process.env.EXPO_PUBLIC_BACKEND_URL || 'http://localhost:3001'; + +// Token storage key (must match what @manacore/shared-auth uses) +const APP_TOKEN_KEY = '@manacore/app_token'; + +// ============================================================================ +// Types +// ============================================================================ + +export type Conversation = { + id: string; + userId: string; + modelId: string; + templateId?: string; + spaceId?: string; + conversationMode: 'free' | 'guided' | 'template'; + documentMode: boolean; + title?: string; + isArchived: boolean; + createdAt: string; + updatedAt: string; +}; + +export type Message = { + id: string; + conversationId: string; + sender: 'user' | 'assistant' | 'system'; + messageText: string; + createdAt: string; + updatedAt: string; +}; + +export type Template = { + id: string; + userId: string; + name: string; + description?: string; + systemPrompt: string; + initialQuestion?: string; + modelId?: string; + color: string; + isDefault: boolean; + documentMode: boolean; + createdAt: string; + updatedAt: string; +}; + +export type Space = { + id: string; + name: string; + description?: string; + ownerId: string; + isArchived: boolean; + createdAt: string; + updatedAt: string; +}; + +export type SpaceMember = { + id: string; + spaceId: string; + userId: string; + role: 'owner' | 'admin' | 'member' | 'viewer'; + invitationStatus: 'pending' | 'accepted' | 'declined'; + invitedBy?: string; + invitedAt: string; + joinedAt?: string; + createdAt: string; + updatedAt: string; +}; + +export type Document = { + id: string; + conversationId: string; + version: number; + content: string; + createdAt: string; + updatedAt: string; +}; + +export type AIModel = { + id: string; + name: string; + description?: string; + parameters: { + temperature?: number; + max_tokens?: number; + provider?: string; + deployment?: string; + endpoint?: string; + api_version?: string; + }; + costSettings?: { + prompt_per_1k_tokens?: number; + completion_per_1k_tokens?: number; + }; + isActive: boolean; + createdAt: string; + updatedAt: string; +}; + +export type ChatMessage = { + role: 'system' | 'user' | 'assistant'; + content: string; +}; + +export type TokenUsage = { + prompt_tokens: number; + completion_tokens: number; + total_tokens: number; +}; + +export type ChatCompletionResponse = { + content: string; + usage: TokenUsage; +}; + +// ============================================================================ +// Base API Functions +// ============================================================================ + +async function getAuthToken(): Promise { + try { + return await SecureStore.getItemAsync(APP_TOKEN_KEY); + } catch { + return null; + } +} + +async function apiRequest( + endpoint: string, + options: RequestInit = {} +): Promise<{ data: T | null; error: string | null }> { + try { + const token = await getAuthToken(); + + const headers: HeadersInit = { + 'Content-Type': 'application/json', + ...(options.headers || {}), + }; + + if (token) { + headers['Authorization'] = `Bearer ${token}`; + } + + const response = await fetch(`${BACKEND_URL}${endpoint}`, { + ...options, + headers, + }); + + if (!response.ok) { + const errorText = await response.text(); + console.error(`API Error [${response.status}]: ${errorText}`); + return { data: null, error: `API Error: ${response.status}` }; + } + + // Handle empty responses + const text = await response.text(); + if (!text) { + return { data: null, error: null }; + } + + const data = JSON.parse(text); + return { data, error: null }; + } catch (error) { + console.error('API Request failed:', error); + return { data: null, error: error instanceof Error ? error.message : 'Unknown error' }; + } +} + +// ============================================================================ +// Conversation API +// ============================================================================ + +export const conversationApi = { + async getConversations(spaceId?: string): Promise { + const params = spaceId ? `?spaceId=${spaceId}` : ''; + const { data, error } = await apiRequest(`/api/conversations${params}`); + if (error) { + console.error('Failed to fetch conversations:', error); + return []; + } + return data || []; + }, + + async getArchivedConversations(): Promise { + const { data, error } = await apiRequest('/api/conversations/archived'); + if (error) { + console.error('Failed to fetch archived conversations:', error); + return []; + } + return data || []; + }, + + async getConversation(id: string): Promise { + const { data, error } = await apiRequest(`/api/conversations/${id}`); + if (error) { + console.error('Failed to fetch conversation:', error); + return null; + } + return data; + }, + + async getMessages(conversationId: string): Promise { + const { data, error } = await apiRequest(`/api/conversations/${conversationId}/messages`); + if (error) { + console.error('Failed to fetch messages:', error); + return []; + } + return data || []; + }, + + async createConversation(params: { + modelId: string; + conversationMode?: 'free' | 'guided' | 'template'; + templateId?: string; + documentMode?: boolean; + spaceId?: string; + }): Promise { + const { data, error } = await apiRequest('/api/conversations', { + method: 'POST', + body: JSON.stringify(params), + }); + if (error) { + console.error('Failed to create conversation:', error); + return null; + } + return data; + }, + + async addMessage( + conversationId: string, + sender: 'user' | 'assistant' | 'system', + messageText: string + ): Promise { + const { data, error } = await apiRequest(`/api/conversations/${conversationId}/messages`, { + method: 'POST', + body: JSON.stringify({ sender, messageText }), + }); + if (error) { + console.error('Failed to add message:', error); + return null; + } + return data; + }, + + async updateTitle(conversationId: string, title: string): Promise { + const { error } = await apiRequest(`/api/conversations/${conversationId}/title`, { + method: 'PATCH', + body: JSON.stringify({ title }), + }); + return !error; + }, + + async archiveConversation(conversationId: string): Promise { + const { error } = await apiRequest(`/api/conversations/${conversationId}/archive`, { + method: 'POST', + }); + return !error; + }, + + async unarchiveConversation(conversationId: string): Promise { + const { error } = await apiRequest(`/api/conversations/${conversationId}/unarchive`, { + method: 'POST', + }); + return !error; + }, + + async deleteConversation(conversationId: string): Promise { + const { error } = await apiRequest(`/api/conversations/${conversationId}`, { + method: 'DELETE', + }); + return !error; + }, +}; + +// ============================================================================ +// Template API +// ============================================================================ + +export const templateApi = { + async getTemplates(): Promise { + const { data, error } = await apiRequest('/api/templates'); + if (error) { + console.error('Failed to fetch templates:', error); + return []; + } + return data || []; + }, + + async getTemplate(id: string): Promise