@alwaysai/device-agent 0.0.9 → 0.0.11-internal

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 (55) hide show
  1. package/lib/application-control/backup.d.ts.map +1 -1
  2. package/lib/application-control/backup.js +4 -3
  3. package/lib/application-control/backup.js.map +1 -1
  4. package/lib/application-control/install.d.ts.map +1 -1
  5. package/lib/application-control/install.js +6 -5
  6. package/lib/application-control/install.js.map +1 -1
  7. package/lib/application-control/models.d.ts.map +1 -1
  8. package/lib/application-control/models.js +3 -2
  9. package/lib/application-control/models.js.map +1 -1
  10. package/lib/application-control/status.d.ts.map +1 -1
  11. package/lib/application-control/status.js +6 -5
  12. package/lib/application-control/status.js.map +1 -1
  13. package/lib/application-control/utils.d.ts.map +1 -1
  14. package/lib/application-control/utils.js +3 -2
  15. package/lib/application-control/utils.js.map +1 -1
  16. package/lib/cloud-connection/device-agent-cloud-connection.d.ts +0 -1
  17. package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
  18. package/lib/cloud-connection/device-agent-cloud-connection.js +20 -21
  19. package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
  20. package/lib/environment.d.ts +1 -0
  21. package/lib/environment.d.ts.map +1 -1
  22. package/lib/environment.js +2 -1
  23. package/lib/environment.js.map +1 -1
  24. package/lib/index.js +2 -1
  25. package/lib/index.js.map +1 -1
  26. package/lib/infrastructure/certificates-and-tokens.d.ts.map +1 -1
  27. package/lib/infrastructure/certificates-and-tokens.js +3 -2
  28. package/lib/infrastructure/certificates-and-tokens.js.map +1 -1
  29. package/lib/subcommands/app/app.d.ts.map +1 -1
  30. package/lib/subcommands/app/app.js +6 -5
  31. package/lib/subcommands/app/app.js.map +1 -1
  32. package/lib/subcommands/device/device.d.ts.map +1 -1
  33. package/lib/subcommands/device/device.js +3 -2
  34. package/lib/subcommands/device/device.js.map +1 -1
  35. package/lib/subcommands/get-model-package.d.ts.map +1 -1
  36. package/lib/subcommands/get-model-package.js +2 -1
  37. package/lib/subcommands/get-model-package.js.map +1 -1
  38. package/lib/util/logger.d.ts +4 -0
  39. package/lib/util/logger.d.ts.map +1 -0
  40. package/lib/util/logger.js +25 -0
  41. package/lib/util/logger.js.map +1 -0
  42. package/package.json +3 -2
  43. package/src/application-control/backup.ts +4 -3
  44. package/src/application-control/install.ts +6 -5
  45. package/src/application-control/models.ts +4 -3
  46. package/src/application-control/status.ts +6 -5
  47. package/src/application-control/utils.ts +3 -2
  48. package/src/cloud-connection/device-agent-cloud-connection.ts +15 -12
  49. package/src/environment.ts +1 -0
  50. package/src/index.ts +2 -1
  51. package/src/infrastructure/certificates-and-tokens.ts +3 -2
  52. package/src/subcommands/app/app.ts +6 -5
  53. package/src/subcommands/device/device.ts +3 -2
  54. package/src/subcommands/get-model-package.ts +2 -1
  55. package/src/util/logger.ts +28 -0
@@ -24,6 +24,7 @@ import {
24
24
  updateModels,
25
25
  } from '../../application-control';
26
26
  import { AgentConfigFile } from '../../infrastructure/agent-config';
27
+ import { logger } from '../../util/logger';
27
28
 
28
29
  export const listAppsCliLeaf = CliLeaf({
29
30
  name: 'list',
@@ -47,7 +48,7 @@ export const listAppReleasesCliLeaf = CliLeaf({
47
48
  async action(_, opts) {
48
49
  const { project } = opts;
49
50
  const releaseHistory = await listAppReleases({ projectId: project });
50
- console.log(releaseHistory);
51
+ logger.info(releaseHistory);
51
52
  },
52
53
  });
53
54
 
@@ -66,7 +67,7 @@ export const listAppLatestReleaseCliLeaf = CliLeaf({
66
67
  if (latestReleaseHash === undefined) {
67
68
  throw new CliTerseError('This application has not been published yet');
68
69
  }
69
- console.log(latestReleaseHash);
70
+ logger.info(latestReleaseHash);
70
71
  },
71
72
  });
72
73
 
@@ -107,7 +108,7 @@ export const getAppStatusCliLeaf = CliLeaf({
107
108
  async action(_, opts) {
108
109
  const { project } = opts;
109
110
  const appStatus = await getAppStatus({ projectId: project });
110
- console.log(appStatus);
111
+ logger.info(appStatus);
111
112
  },
112
113
  });
113
114
 
@@ -143,7 +144,7 @@ export const getAppLogsCliLeaf = CliLeaf({
143
144
  const readable = await getAppLogs({ projectId: project });
144
145
  readable.setEncoding('utf8');
145
146
  for await (const chunk of readable) {
146
- console.log(chunk);
147
+ logger.info(chunk);
147
148
  }
148
149
  },
149
150
  });
@@ -307,7 +308,7 @@ export const getAllEnvsCLiLeaf = CliLeaf({
307
308
  },
308
309
  async action(_, opts) {
309
310
  const { project } = opts;
310
- console.log(await getAllEnvs({ projectId: project }));
311
+ logger.info(await getAllEnvs({ projectId: project }));
311
312
  },
312
313
  });
313
314
 
@@ -8,6 +8,7 @@ import {
8
8
  getTargetHardwareUuid,
9
9
  writeCertificateAndToken,
10
10
  } from '../../infrastructure/certificates-and-tokens';
11
+ import { logger } from '../../util/logger';
11
12
 
12
13
  export const initCliLeaf = CliLeaf({
13
14
  name: 'init',
@@ -24,7 +25,7 @@ export const initCliLeaf = CliLeaf({
24
25
  },
25
26
  async action(_, opts) {
26
27
  const { name, description } = opts;
27
- console.log('Initializing device');
28
+ logger.info('Initializing device');
28
29
  await checkUserIsLoggedInComponent({ yes: true });
29
30
  if (!(await checkPaidPlan())) {
30
31
  throw new Error(`This action only supported for Enterprise alwaysAI accounts!`);
@@ -44,7 +45,7 @@ export const initCliLeaf = CliLeaf({
44
45
  };
45
46
  const response = await addDevice(deviceToAdd, 'production');
46
47
  await writeCertificateAndToken({ deviceUuid: response.deviceUUID });
47
- console.log(`Initialized device as ${response.deviceUUID}`);
48
+ logger.info(`Initialized device as ${response.deviceUUID}`);
48
49
  },
49
50
  });
50
51
 
@@ -2,6 +2,7 @@ import { CliLeaf, CliNumberInput, CliStringInput } from '@alwaysai/alwayscli';
2
2
  import { appInstallModel } from 'alwaysai/lib/core/app';
3
3
  import { CliRpcClient } from 'alwaysai/lib/infrastructure';
4
4
  import { JsSpawner } from 'alwaysai/lib/util';
5
+ import { logger } from '../util/logger';
5
6
 
6
7
  export const getModelPackageCliLeaf = CliLeaf({
7
8
  name: 'get-model-package',
@@ -27,6 +28,6 @@ export const getModelPackageCliLeaf = CliLeaf({
27
28
  const version =
28
29
  opts.version || (await CliRpcClient().getModelVersion({ id })).version;
29
30
  await appInstallModel(spawner, id, version);
30
- console.log(`Completed downloading ${id} to ${path}`);
31
+ logger.info(`Completed downloading ${id} to ${path}`);
31
32
  },
32
33
  });
@@ -0,0 +1,28 @@
1
+ import * as winston from 'winston';
2
+ import 'winston-daily-rotate-file';
3
+ import * as path from 'path';
4
+ import { AAI_DIR } from 'alwaysai/lib/constants';
5
+ import { ALWAYSAI_LOG_LEVEL, ALWAYSAI_LOG_TO_CONSOLE } from '../environment';
6
+
7
+ const LOG_LEVEL = ALWAYSAI_LOG_LEVEL || 'info';
8
+ const transports = ALWAYSAI_LOG_TO_CONSOLE
9
+ ? [new winston.transports.Console({ level: LOG_LEVEL })]
10
+ : [
11
+ new winston.transports.DailyRotateFile({
12
+ filename: path.join(AAI_DIR, 'agent-logs', 'agent-logs.txt'),
13
+ maxSize: '5m',
14
+ maxFiles: '2d',
15
+ }),
16
+ ];
17
+
18
+ export const logger = winston.createLogger({
19
+ level: LOG_LEVEL,
20
+ format: winston.format.combine(
21
+ winston.format.errors({ stack: true }),
22
+ winston.format.splat(),
23
+ winston.format.simple(),
24
+ ),
25
+ transports,
26
+ });
27
+
28
+ logger.info(`Initialized logger with log level: ${LOG_LEVEL}`);