@alwaysai/device-agent 0.0.11 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/application-control/backup.d.ts.map +1 -1
- package/lib/application-control/backup.js +8 -2
- package/lib/application-control/backup.js.map +1 -1
- package/lib/application-control/config.d.ts +12 -4
- package/lib/application-control/config.d.ts.map +1 -1
- package/lib/application-control/config.js +59 -16
- package/lib/application-control/config.js.map +1 -1
- package/lib/application-control/environment-variables.d.ts.map +1 -1
- package/lib/application-control/environment-variables.js.map +1 -1
- package/lib/application-control/index.d.ts +4 -4
- package/lib/application-control/index.d.ts.map +1 -1
- package/lib/application-control/index.js +4 -3
- package/lib/application-control/index.js.map +1 -1
- package/lib/application-control/install.d.ts.map +1 -1
- package/lib/application-control/install.js +28 -14
- package/lib/application-control/install.js.map +1 -1
- package/lib/application-control/models.d.ts +7 -1
- package/lib/application-control/models.d.ts.map +1 -1
- package/lib/application-control/models.js +69 -39
- package/lib/application-control/models.js.map +1 -1
- package/lib/application-control/status.d.ts.map +1 -1
- package/lib/application-control/status.js +18 -14
- package/lib/application-control/status.js.map +1 -1
- package/lib/application-control/utils.d.ts +0 -2
- package/lib/application-control/utils.d.ts.map +1 -1
- package/lib/application-control/utils.js +7 -16
- package/lib/application-control/utils.js.map +1 -1
- package/lib/cloud-connection/app-install-status.d.ts +16 -0
- package/lib/cloud-connection/app-install-status.d.ts.map +1 -0
- package/lib/cloud-connection/app-install-status.js +53 -0
- package/lib/cloud-connection/app-install-status.js.map +1 -0
- package/lib/cloud-connection/bootstrap-provision.d.ts +2 -0
- package/lib/cloud-connection/bootstrap-provision.d.ts.map +1 -0
- package/lib/cloud-connection/bootstrap-provision.js +34 -0
- package/lib/cloud-connection/bootstrap-provision.js.map +1 -0
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts +12 -35
- package/lib/cloud-connection/device-agent-cloud-connection.d.ts.map +1 -1
- package/lib/cloud-connection/device-agent-cloud-connection.js +170 -387
- package/lib/cloud-connection/device-agent-cloud-connection.js.map +1 -1
- package/lib/cloud-connection/device-agent.d.ts.map +1 -1
- package/lib/cloud-connection/device-agent.js +22 -26
- package/lib/cloud-connection/device-agent.js.map +1 -1
- package/lib/cloud-connection/live-updates-handler.d.ts +34 -0
- package/lib/cloud-connection/live-updates-handler.d.ts.map +1 -0
- package/lib/cloud-connection/live-updates-handler.js +167 -0
- package/lib/cloud-connection/live-updates-handler.js.map +1 -0
- package/lib/cloud-connection/messages.d.ts +14 -0
- package/lib/cloud-connection/messages.d.ts.map +1 -0
- package/lib/cloud-connection/messages.js +38 -0
- package/lib/cloud-connection/messages.js.map +1 -0
- package/lib/cloud-connection/publisher.d.ts +14 -0
- package/lib/cloud-connection/publisher.d.ts.map +1 -0
- package/lib/cloud-connection/publisher.js +44 -0
- package/lib/cloud-connection/publisher.js.map +1 -0
- package/lib/cloud-connection/shadow-handler.d.ts +34 -0
- package/lib/cloud-connection/shadow-handler.d.ts.map +1 -0
- package/lib/cloud-connection/shadow-handler.js +94 -0
- package/lib/cloud-connection/shadow-handler.js.map +1 -0
- package/lib/cloud-connection/shadow.d.ts +16 -0
- package/lib/cloud-connection/shadow.d.ts.map +1 -0
- package/lib/cloud-connection/shadow.js +36 -0
- package/lib/cloud-connection/shadow.js.map +1 -0
- package/lib/device-control/device-control.d.ts.map +1 -1
- package/lib/device-control/device-control.js +1 -0
- package/lib/device-control/device-control.js.map +1 -1
- package/lib/docker/docker-cmd.js +1 -1
- package/lib/docker/docker-compose-cmd.d.ts.map +1 -1
- package/lib/docker/docker-compose-cmd.js +1 -1
- package/lib/docker/docker-compose-cmd.js.map +1 -1
- package/lib/endpoints.js +10 -10
- package/lib/endpoints.js.map +1 -1
- package/lib/environment.d.ts.map +1 -1
- package/lib/environment.js.map +1 -1
- package/lib/infrastructure/agent-config.d.ts +4 -14
- package/lib/infrastructure/agent-config.d.ts.map +1 -1
- package/lib/infrastructure/agent-config.js +22 -15
- package/lib/infrastructure/agent-config.js.map +1 -1
- package/lib/infrastructure/agent-config.test.js +26 -18
- package/lib/infrastructure/agent-config.test.js.map +1 -1
- package/lib/infrastructure/system-id.d.ts +2 -0
- package/lib/infrastructure/system-id.d.ts.map +1 -0
- package/lib/infrastructure/system-id.js +21 -0
- package/lib/infrastructure/system-id.js.map +1 -0
- package/lib/infrastructure/tokens-and-device-cfg.d.ts +4 -0
- package/lib/infrastructure/tokens-and-device-cfg.d.ts.map +1 -0
- package/lib/infrastructure/tokens-and-device-cfg.js +31 -0
- package/lib/infrastructure/tokens-and-device-cfg.js.map +1 -0
- package/lib/infrastructure/urls.d.ts.map +1 -1
- package/lib/infrastructure/urls.js +3 -3
- package/lib/infrastructure/urls.js.map +1 -1
- package/lib/root.d.ts.map +1 -1
- package/lib/root.js +2 -7
- package/lib/root.js.map +1 -1
- package/lib/subcommands/app/app.d.ts.map +1 -1
- package/lib/subcommands/app/app.js +62 -60
- package/lib/subcommands/app/app.js.map +1 -1
- package/lib/subcommands/app/index.js +2 -2
- package/lib/subcommands/device/clean.d.ts +2 -0
- package/lib/subcommands/device/clean.d.ts.map +1 -0
- package/lib/subcommands/device/clean.js +29 -0
- package/lib/subcommands/device/clean.js.map +1 -0
- package/lib/subcommands/device/device.d.ts.map +1 -1
- package/lib/subcommands/device/device.js +40 -27
- package/lib/subcommands/device/device.js.map +1 -1
- package/lib/subcommands/device/index.d.ts.map +1 -1
- package/lib/subcommands/device/index.js +2 -1
- package/lib/subcommands/device/index.js.map +1 -1
- package/lib/subcommands/get-model-package.js +5 -5
- package/lib/subcommands/index.js +1 -1
- package/lib/subcommands/login.js +8 -8
- package/lib/subcommands/login.js.map +1 -1
- package/lib/util/clean-certs.d.ts +2 -0
- package/lib/util/clean-certs.d.ts.map +1 -0
- package/lib/util/clean-certs.js +16 -0
- package/lib/util/clean-certs.js.map +1 -0
- package/lib/util/directories.d.ts +16 -15
- package/lib/util/directories.d.ts.map +1 -1
- package/lib/util/directories.js +45 -26
- package/lib/util/directories.js.map +1 -1
- package/lib/util/get-device-id.d.ts +1 -1
- package/lib/util/get-device-id.d.ts.map +1 -1
- package/lib/util/get-device-id.js +14 -19
- package/lib/util/get-device-id.js.map +1 -1
- package/lib/util/http-client.d.ts +1 -1
- package/lib/util/http-client.d.ts.map +1 -1
- package/lib/util/http-client.js +10 -8
- package/lib/util/http-client.js.map +1 -1
- package/lib/util/logger.d.ts.map +1 -1
- package/lib/util/logger.js +4 -5
- package/lib/util/logger.js.map +1 -1
- package/lib/util/run-in-dir.d.ts.map +1 -1
- package/lib/util/run-in-dir.js +1 -0
- package/lib/util/run-in-dir.js.map +1 -1
- package/package.json +18 -8
- package/src/application-control/backup.ts +8 -3
- package/src/application-control/config.ts +75 -13
- package/src/application-control/environment-variables.ts +3 -3
- package/src/application-control/index.ts +19 -6
- package/src/application-control/install.ts +52 -28
- package/src/application-control/models.ts +100 -56
- package/src/application-control/status.ts +26 -21
- package/src/application-control/utils.ts +9 -20
- package/src/cloud-connection/app-install-status.ts +62 -0
- package/src/cloud-connection/bootstrap-provision.ts +40 -0
- package/src/cloud-connection/device-agent-cloud-connection.ts +258 -527
- package/src/cloud-connection/device-agent.ts +31 -38
- package/src/cloud-connection/live-updates-handler.ts +226 -0
- package/src/cloud-connection/messages.ts +39 -0
- package/src/cloud-connection/publisher.ts +65 -0
- package/src/cloud-connection/shadow-handler.ts +154 -0
- package/src/cloud-connection/shadow.ts +50 -0
- package/src/device-control/device-control.ts +1 -0
- package/src/docker/docker-cmd.ts +1 -1
- package/src/docker/docker-compose-cmd.ts +5 -2
- package/src/endpoints.ts +9 -9
- package/src/environment.ts +8 -3
- package/src/infrastructure/agent-config.test.ts +34 -23
- package/src/infrastructure/agent-config.ts +33 -20
- package/src/infrastructure/system-id.ts +18 -0
- package/src/infrastructure/tokens-and-device-cfg.ts +39 -0
- package/src/infrastructure/urls.ts +4 -2
- package/src/root.ts +2 -8
- package/src/subcommands/app/app.ts +64 -62
- package/src/subcommands/app/index.ts +3 -3
- package/src/subcommands/device/clean.ts +26 -0
- package/src/subcommands/device/device.ts +66 -50
- package/src/subcommands/device/index.ts +2 -1
- package/src/subcommands/get-model-package.ts +5 -5
- package/src/subcommands/index.ts +1 -1
- package/src/subcommands/login.ts +8 -8
- package/src/util/clean-certs.ts +12 -0
- package/src/util/directories.ts +68 -52
- package/src/util/get-device-id.ts +16 -18
- package/src/util/http-client.ts +18 -13
- package/src/util/logger.ts +6 -6
- package/src/util/run-in-dir.ts +2 -1
- package/lib/infrastructure/certificates-and-tokens.d.ts +0 -6
- package/lib/infrastructure/certificates-and-tokens.d.ts.map +0 -1
- package/lib/infrastructure/certificates-and-tokens.js +0 -43
- package/lib/infrastructure/certificates-and-tokens.js.map +0 -1
- package/src/infrastructure/certificates-and-tokens.ts +0 -53
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
CliLeaf,
|
|
3
3
|
CliStringArrayInput,
|
|
4
4
|
CliStringInput,
|
|
5
|
-
CliTerseError
|
|
5
|
+
CliTerseError
|
|
6
6
|
} from '@alwaysai/alwayscli';
|
|
7
7
|
import {
|
|
8
8
|
addModel,
|
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
startApp,
|
|
22
22
|
stopApp,
|
|
23
23
|
uninstallApp,
|
|
24
|
-
updateModels
|
|
24
|
+
updateModels
|
|
25
25
|
} from '../../application-control';
|
|
26
26
|
import { AgentConfigFile } from '../../infrastructure/agent-config';
|
|
27
27
|
import { logger } from '../../util/logger';
|
|
@@ -33,7 +33,7 @@ export const listAppsCliLeaf = CliLeaf({
|
|
|
33
33
|
async action(_, opts) {
|
|
34
34
|
const apps = await AgentConfigFile().getApps();
|
|
35
35
|
console.table(apps);
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
37
|
});
|
|
38
38
|
|
|
39
39
|
export const listAppReleasesCliLeaf = CliLeaf({
|
|
@@ -42,14 +42,14 @@ export const listAppReleasesCliLeaf = CliLeaf({
|
|
|
42
42
|
namedInputs: {
|
|
43
43
|
project: CliStringInput({
|
|
44
44
|
description: 'Project ID',
|
|
45
|
-
required: true
|
|
46
|
-
})
|
|
45
|
+
required: true
|
|
46
|
+
})
|
|
47
47
|
},
|
|
48
48
|
async action(_, opts) {
|
|
49
49
|
const { project } = opts;
|
|
50
50
|
const releaseHistory = await listAppReleases({ projectId: project });
|
|
51
51
|
logger.info(releaseHistory);
|
|
52
|
-
}
|
|
52
|
+
}
|
|
53
53
|
});
|
|
54
54
|
|
|
55
55
|
export const listAppLatestReleaseCliLeaf = CliLeaf({
|
|
@@ -58,17 +58,19 @@ export const listAppLatestReleaseCliLeaf = CliLeaf({
|
|
|
58
58
|
namedInputs: {
|
|
59
59
|
project: CliStringInput({
|
|
60
60
|
description: 'Project ID',
|
|
61
|
-
required: true
|
|
62
|
-
})
|
|
61
|
+
required: true
|
|
62
|
+
})
|
|
63
63
|
},
|
|
64
64
|
async action(_, opts) {
|
|
65
65
|
const { project } = opts;
|
|
66
|
-
const latestReleaseHash = await listAppLatestRelease({
|
|
66
|
+
const latestReleaseHash = await listAppLatestRelease({
|
|
67
|
+
projectId: project
|
|
68
|
+
});
|
|
67
69
|
if (latestReleaseHash === undefined) {
|
|
68
70
|
throw new CliTerseError('This application has not been published yet');
|
|
69
71
|
}
|
|
70
72
|
logger.info(latestReleaseHash);
|
|
71
|
-
}
|
|
73
|
+
}
|
|
72
74
|
});
|
|
73
75
|
|
|
74
76
|
export const installAppCliLeaf = CliLeaf({
|
|
@@ -77,11 +79,11 @@ export const installAppCliLeaf = CliLeaf({
|
|
|
77
79
|
namedInputs: {
|
|
78
80
|
project: CliStringInput({
|
|
79
81
|
description: 'Project ID',
|
|
80
|
-
required: true
|
|
82
|
+
required: true
|
|
81
83
|
}),
|
|
82
84
|
releaseHash: CliStringInput({
|
|
83
|
-
description: 'Release Hash'
|
|
84
|
-
})
|
|
85
|
+
description: 'Release Hash'
|
|
86
|
+
})
|
|
85
87
|
},
|
|
86
88
|
async action(_, opts) {
|
|
87
89
|
const project = opts.project;
|
|
@@ -93,7 +95,7 @@ export const installAppCliLeaf = CliLeaf({
|
|
|
93
95
|
throw new CliTerseError('This application has not been published yet');
|
|
94
96
|
}
|
|
95
97
|
await installApp({ projectId: project, appReleaseHash: releaseHash });
|
|
96
|
-
}
|
|
98
|
+
}
|
|
97
99
|
});
|
|
98
100
|
|
|
99
101
|
export const getAppStatusCliLeaf = CliLeaf({
|
|
@@ -102,14 +104,14 @@ export const getAppStatusCliLeaf = CliLeaf({
|
|
|
102
104
|
namedInputs: {
|
|
103
105
|
project: CliStringInput({
|
|
104
106
|
description: 'Project ID',
|
|
105
|
-
required: true
|
|
106
|
-
})
|
|
107
|
+
required: true
|
|
108
|
+
})
|
|
107
109
|
},
|
|
108
110
|
async action(_, opts) {
|
|
109
111
|
const { project } = opts;
|
|
110
112
|
const appStatus = await getAppStatus({ projectId: project });
|
|
111
113
|
logger.info(appStatus);
|
|
112
|
-
}
|
|
114
|
+
}
|
|
113
115
|
});
|
|
114
116
|
|
|
115
117
|
export const startAppCliLeaf = CliLeaf({
|
|
@@ -118,16 +120,16 @@ export const startAppCliLeaf = CliLeaf({
|
|
|
118
120
|
namedInputs: {
|
|
119
121
|
project: CliStringInput({
|
|
120
122
|
description: 'Project ID',
|
|
121
|
-
required: true
|
|
123
|
+
required: true
|
|
122
124
|
}),
|
|
123
125
|
dockerLoginToken: CliStringInput({
|
|
124
|
-
description: 'Docker login token'
|
|
125
|
-
})
|
|
126
|
+
description: 'Docker login token'
|
|
127
|
+
})
|
|
126
128
|
},
|
|
127
129
|
async action(_, opts) {
|
|
128
130
|
const { project, dockerLoginToken } = opts;
|
|
129
131
|
await startApp({ projectId: project, dockerLoginToken });
|
|
130
|
-
}
|
|
132
|
+
}
|
|
131
133
|
});
|
|
132
134
|
|
|
133
135
|
export const getAppLogsCliLeaf = CliLeaf({
|
|
@@ -136,8 +138,8 @@ export const getAppLogsCliLeaf = CliLeaf({
|
|
|
136
138
|
namedInputs: {
|
|
137
139
|
project: CliStringInput({
|
|
138
140
|
description: 'Project ID',
|
|
139
|
-
required: true
|
|
140
|
-
})
|
|
141
|
+
required: true
|
|
142
|
+
})
|
|
141
143
|
},
|
|
142
144
|
async action(_, opts) {
|
|
143
145
|
const { project } = opts;
|
|
@@ -146,7 +148,7 @@ export const getAppLogsCliLeaf = CliLeaf({
|
|
|
146
148
|
for await (const chunk of readable) {
|
|
147
149
|
logger.info(chunk);
|
|
148
150
|
}
|
|
149
|
-
}
|
|
151
|
+
}
|
|
150
152
|
});
|
|
151
153
|
|
|
152
154
|
export const stopAppCliLeaf = CliLeaf({
|
|
@@ -155,13 +157,13 @@ export const stopAppCliLeaf = CliLeaf({
|
|
|
155
157
|
namedInputs: {
|
|
156
158
|
project: CliStringInput({
|
|
157
159
|
description: 'Project ID',
|
|
158
|
-
required: true
|
|
159
|
-
})
|
|
160
|
+
required: true
|
|
161
|
+
})
|
|
160
162
|
},
|
|
161
163
|
async action(_, opts) {
|
|
162
164
|
const { project } = opts;
|
|
163
165
|
await stopApp({ projectId: project });
|
|
164
|
-
}
|
|
166
|
+
}
|
|
165
167
|
});
|
|
166
168
|
|
|
167
169
|
export const restartAppCliLeaf = CliLeaf({
|
|
@@ -170,13 +172,13 @@ export const restartAppCliLeaf = CliLeaf({
|
|
|
170
172
|
namedInputs: {
|
|
171
173
|
project: CliStringInput({
|
|
172
174
|
description: 'Project ID',
|
|
173
|
-
required: true
|
|
174
|
-
})
|
|
175
|
+
required: true
|
|
176
|
+
})
|
|
175
177
|
},
|
|
176
178
|
async action(_, opts) {
|
|
177
179
|
const { project } = opts;
|
|
178
180
|
await restartApp({ projectId: project });
|
|
179
|
-
}
|
|
181
|
+
}
|
|
180
182
|
});
|
|
181
183
|
|
|
182
184
|
export const uninstallAppCliLeaf = CliLeaf({
|
|
@@ -185,13 +187,13 @@ export const uninstallAppCliLeaf = CliLeaf({
|
|
|
185
187
|
namedInputs: {
|
|
186
188
|
project: CliStringInput({
|
|
187
189
|
description: 'Project ID',
|
|
188
|
-
required: true
|
|
189
|
-
})
|
|
190
|
+
required: true
|
|
191
|
+
})
|
|
190
192
|
},
|
|
191
193
|
async action(_, opts) {
|
|
192
194
|
const { project } = opts;
|
|
193
195
|
await uninstallApp({ projectId: project });
|
|
194
|
-
}
|
|
196
|
+
}
|
|
195
197
|
});
|
|
196
198
|
|
|
197
199
|
export const rollbackAppCliLeaf = CliLeaf({
|
|
@@ -200,13 +202,13 @@ export const rollbackAppCliLeaf = CliLeaf({
|
|
|
200
202
|
namedInputs: {
|
|
201
203
|
project: CliStringInput({
|
|
202
204
|
description: 'Project ID',
|
|
203
|
-
required: true
|
|
204
|
-
})
|
|
205
|
+
required: true
|
|
206
|
+
})
|
|
205
207
|
},
|
|
206
208
|
async action(_, opts) {
|
|
207
209
|
const { project } = opts;
|
|
208
210
|
await rollbackApp({ projectId: project });
|
|
209
|
-
}
|
|
211
|
+
}
|
|
210
212
|
});
|
|
211
213
|
|
|
212
214
|
export const showAppModelsCliLeaf = CliLeaf({
|
|
@@ -215,14 +217,14 @@ export const showAppModelsCliLeaf = CliLeaf({
|
|
|
215
217
|
namedInputs: {
|
|
216
218
|
project: CliStringInput({
|
|
217
219
|
description: 'Project ID',
|
|
218
|
-
required: true
|
|
219
|
-
})
|
|
220
|
+
required: true
|
|
221
|
+
})
|
|
220
222
|
},
|
|
221
223
|
async action(_, opts) {
|
|
222
224
|
const { project } = opts;
|
|
223
225
|
const appModels = await getAppModels({ projectId: project });
|
|
224
226
|
console.table(appModels);
|
|
225
|
-
}
|
|
227
|
+
}
|
|
226
228
|
});
|
|
227
229
|
|
|
228
230
|
export const addModelCliLeaf = CliLeaf({
|
|
@@ -231,17 +233,17 @@ export const addModelCliLeaf = CliLeaf({
|
|
|
231
233
|
namedInputs: {
|
|
232
234
|
project: CliStringInput({
|
|
233
235
|
description: 'Project ID',
|
|
234
|
-
required: true
|
|
236
|
+
required: true
|
|
235
237
|
}),
|
|
236
238
|
model: CliStringInput({
|
|
237
239
|
description: 'Model ID',
|
|
238
|
-
required: true
|
|
239
|
-
})
|
|
240
|
+
required: true
|
|
241
|
+
})
|
|
240
242
|
},
|
|
241
243
|
async action(_, opts) {
|
|
242
244
|
const { project, model } = opts;
|
|
243
245
|
await addModel({ projectId: project, modelId: model });
|
|
244
|
-
}
|
|
246
|
+
}
|
|
245
247
|
});
|
|
246
248
|
|
|
247
249
|
export const removeModelCliLeaf = CliLeaf({
|
|
@@ -250,17 +252,17 @@ export const removeModelCliLeaf = CliLeaf({
|
|
|
250
252
|
namedInputs: {
|
|
251
253
|
project: CliStringInput({
|
|
252
254
|
description: 'Project ID',
|
|
253
|
-
required: true
|
|
255
|
+
required: true
|
|
254
256
|
}),
|
|
255
257
|
model: CliStringInput({
|
|
256
258
|
description: 'Model ID',
|
|
257
|
-
required: true
|
|
258
|
-
})
|
|
259
|
+
required: true
|
|
260
|
+
})
|
|
259
261
|
},
|
|
260
262
|
async action(_, opts) {
|
|
261
263
|
const { project, model } = opts;
|
|
262
264
|
await removeModel({ projectId: project, modelId: model });
|
|
263
|
-
}
|
|
265
|
+
}
|
|
264
266
|
});
|
|
265
267
|
|
|
266
268
|
export const replaceModelsCliLeaf = CliLeaf({
|
|
@@ -269,17 +271,17 @@ export const replaceModelsCliLeaf = CliLeaf({
|
|
|
269
271
|
namedInputs: {
|
|
270
272
|
project: CliStringInput({
|
|
271
273
|
description: 'Project Id',
|
|
272
|
-
required: true
|
|
274
|
+
required: true
|
|
273
275
|
}),
|
|
274
276
|
models: CliStringArrayInput({
|
|
275
277
|
description: 'One or more model IDs',
|
|
276
|
-
required: true
|
|
277
|
-
})
|
|
278
|
+
required: true
|
|
279
|
+
})
|
|
278
280
|
},
|
|
279
281
|
async action(_, opts) {
|
|
280
282
|
const { project, models } = opts;
|
|
281
283
|
await replaceModels({ projectId: project, modelIds: models });
|
|
282
|
-
}
|
|
284
|
+
}
|
|
283
285
|
});
|
|
284
286
|
|
|
285
287
|
export const updateModelsCliLeaf = CliLeaf({
|
|
@@ -288,13 +290,13 @@ export const updateModelsCliLeaf = CliLeaf({
|
|
|
288
290
|
namedInputs: {
|
|
289
291
|
project: CliStringInput({
|
|
290
292
|
description: 'Project Id',
|
|
291
|
-
required: true
|
|
292
|
-
})
|
|
293
|
+
required: true
|
|
294
|
+
})
|
|
293
295
|
},
|
|
294
296
|
async action(_, opts) {
|
|
295
297
|
const { project } = opts;
|
|
296
298
|
await updateModels({ projectId: project });
|
|
297
|
-
}
|
|
299
|
+
}
|
|
298
300
|
});
|
|
299
301
|
|
|
300
302
|
export const getAllEnvsCLiLeaf = CliLeaf({
|
|
@@ -303,13 +305,13 @@ export const getAllEnvsCLiLeaf = CliLeaf({
|
|
|
303
305
|
namedInputs: {
|
|
304
306
|
project: CliStringInput({
|
|
305
307
|
description: 'Project Id',
|
|
306
|
-
required: true
|
|
307
|
-
})
|
|
308
|
+
required: true
|
|
309
|
+
})
|
|
308
310
|
},
|
|
309
311
|
async action(_, opts) {
|
|
310
312
|
const { project } = opts;
|
|
311
313
|
logger.info(await getAllEnvs({ projectId: project }));
|
|
312
|
-
}
|
|
314
|
+
}
|
|
313
315
|
});
|
|
314
316
|
|
|
315
317
|
export const setEnvCLiLeaf = CliLeaf({
|
|
@@ -317,21 +319,21 @@ export const setEnvCLiLeaf = CliLeaf({
|
|
|
317
319
|
description: 'Set environment variables for a service',
|
|
318
320
|
positionalInput: CliStringArrayInput({
|
|
319
321
|
placeholder: '<NAME=VALUE> [<NAME=VALUE> ...]',
|
|
320
|
-
required: true
|
|
322
|
+
required: true
|
|
321
323
|
}),
|
|
322
324
|
namedInputs: {
|
|
323
325
|
project: CliStringInput({
|
|
324
326
|
description: 'Project Id',
|
|
325
|
-
required: true
|
|
327
|
+
required: true
|
|
326
328
|
}),
|
|
327
329
|
service: CliStringInput({
|
|
328
330
|
description:
|
|
329
331
|
'The name of the docker-compose service to apply environment variable to',
|
|
330
|
-
required: false
|
|
331
|
-
})
|
|
332
|
+
required: false
|
|
333
|
+
})
|
|
332
334
|
},
|
|
333
335
|
async action(args, opts) {
|
|
334
336
|
const { project, service } = opts;
|
|
335
337
|
await setEnv({ projectId: project, vars: args, service });
|
|
336
|
-
}
|
|
338
|
+
}
|
|
337
339
|
});
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
replaceModelsCliLeaf,
|
|
18
18
|
showAppModelsCliLeaf,
|
|
19
19
|
getAllEnvsCLiLeaf,
|
|
20
|
-
setEnvCLiLeaf
|
|
20
|
+
setEnvCLiLeaf
|
|
21
21
|
} from './app';
|
|
22
22
|
|
|
23
23
|
export const appCliBranch = CliBranch({
|
|
@@ -41,6 +41,6 @@ export const appCliBranch = CliBranch({
|
|
|
41
41
|
replaceModelsCliLeaf,
|
|
42
42
|
updateModelsCliLeaf,
|
|
43
43
|
getAllEnvsCLiLeaf,
|
|
44
|
-
setEnvCLiLeaf
|
|
45
|
-
]
|
|
44
|
+
setEnvCLiLeaf
|
|
45
|
+
]
|
|
46
46
|
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { CliLeaf } from '@alwaysai/alwayscli';
|
|
2
|
+
import * as rimraf from 'rimraf';
|
|
3
|
+
import { LOCAL_CERT_AND_KEY_DIR } from 'alwaysai/lib/constants';
|
|
4
|
+
import { logger } from '../../util/logger';
|
|
5
|
+
import { AgentConfigFile } from '../../infrastructure/agent-config';
|
|
6
|
+
import { DeviceConfigFile } from 'alwaysai/lib/core/device';
|
|
7
|
+
import { APP_ROOT, CREDENTIALS_FILE_PATH } from '../../util/directories';
|
|
8
|
+
|
|
9
|
+
export const cleanCliLeaf = CliLeaf({
|
|
10
|
+
name: 'clean',
|
|
11
|
+
description: 'Remove all provisioning files',
|
|
12
|
+
async action(_, opts) {
|
|
13
|
+
logger.info('Cleaning device configuration');
|
|
14
|
+
logger.debug(`Removing ${LOCAL_CERT_AND_KEY_DIR}`);
|
|
15
|
+
rimraf.sync(LOCAL_CERT_AND_KEY_DIR);
|
|
16
|
+
logger.debug(`Removing ${AgentConfigFile().path}`);
|
|
17
|
+
AgentConfigFile().remove();
|
|
18
|
+
logger.debug(`Removing ${DeviceConfigFile().path}`);
|
|
19
|
+
DeviceConfigFile().remove();
|
|
20
|
+
logger.debug(`Removing ${CREDENTIALS_FILE_PATH}`);
|
|
21
|
+
rimraf.sync(CREDENTIALS_FILE_PATH);
|
|
22
|
+
logger.debug(`Removing ${APP_ROOT}`);
|
|
23
|
+
rimraf.sync(APP_ROOT);
|
|
24
|
+
logger.info('Device configuration cleaned');
|
|
25
|
+
}
|
|
26
|
+
});
|
|
@@ -1,45 +1,49 @@
|
|
|
1
|
-
import { CliLeaf, CliStringInput } from
|
|
2
|
-
import { checkUserIsLoggedInComponent } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
import {
|
|
1
|
+
import { CliLeaf, CliStringInput } from '@alwaysai/alwayscli';
|
|
2
|
+
import { checkUserIsLoggedInComponent } from 'alwaysai/lib/components/user';
|
|
3
|
+
import { getTargetHardwareUuid } from 'alwaysai/lib/core/app';
|
|
4
|
+
import { checkPaidPlan } from 'alwaysai/lib/core/project';
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
6
|
+
import { CliAuthenticationClient } from 'alwaysai/lib/infrastructure';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { httpClient, microServiceHttpClient } from '../../util/http-client';
|
|
8
9
|
import {
|
|
9
10
|
AWS_ROOT_CERTIFICATE_FILE_NAME,
|
|
10
11
|
BOOTSTRAP_CERTIFICATES_DIR_PATH,
|
|
11
|
-
|
|
12
|
+
getPrivateKeyFilePath
|
|
13
|
+
} from '../../util/directories';
|
|
12
14
|
|
|
13
|
-
import { LOCAL_CERT_AND_KEY_DIR } from
|
|
14
|
-
import
|
|
15
|
-
import { JsSpawner } from "alwaysai/lib/util";
|
|
15
|
+
import { LOCAL_CERT_AND_KEY_DIR } from 'alwaysai/lib/constants';
|
|
16
|
+
import { JsSpawner } from 'alwaysai/lib/util';
|
|
16
17
|
import {
|
|
17
18
|
getCpuUtil,
|
|
18
19
|
getDiskUtil,
|
|
19
|
-
getMemUtil
|
|
20
|
-
} from
|
|
21
|
-
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
} from "../../infrastructure/certificates-and-tokens";
|
|
25
|
-
import { logger } from "../../util/logger";
|
|
20
|
+
getMemUtil
|
|
21
|
+
} from '../../device-control/device-control';
|
|
22
|
+
import { writeTokenAndDeviceCfg } from '../../infrastructure/tokens-and-device-cfg';
|
|
23
|
+
import { logger } from '../../util/logger';
|
|
24
|
+
import { DeviceConfigFile } from 'alwaysai/lib/core/device';
|
|
26
25
|
|
|
27
26
|
export const initCliLeaf = CliLeaf({
|
|
28
|
-
name:
|
|
29
|
-
description:
|
|
27
|
+
name: 'init',
|
|
28
|
+
description: 'Initialize device',
|
|
30
29
|
namedInputs: {
|
|
31
30
|
name: CliStringInput({
|
|
32
|
-
description:
|
|
33
|
-
required: true
|
|
31
|
+
description: 'Device name',
|
|
32
|
+
required: true
|
|
34
33
|
}),
|
|
35
34
|
description: CliStringInput({
|
|
36
|
-
description:
|
|
37
|
-
required: false
|
|
38
|
-
})
|
|
35
|
+
description: 'Device description',
|
|
36
|
+
required: false
|
|
37
|
+
})
|
|
39
38
|
},
|
|
40
39
|
async action(_, opts) {
|
|
41
40
|
const { name, description } = opts;
|
|
42
|
-
|
|
41
|
+
if (DeviceConfigFile().exists() || existsSync(getPrivateKeyFilePath())) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
"Device has been previously provisioned. Run 'aai-agent device clean' to re-provision"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
logger.info(`Initializing device ${name}`);
|
|
43
47
|
await checkUserIsLoggedInComponent({ yes: true });
|
|
44
48
|
if (!(await checkPaidPlan())) {
|
|
45
49
|
throw new Error(
|
|
@@ -47,54 +51,66 @@ export const initCliLeaf = CliLeaf({
|
|
|
47
51
|
);
|
|
48
52
|
}
|
|
49
53
|
const { username } = await CliAuthenticationClient().getInfo();
|
|
50
|
-
const
|
|
51
|
-
const hardwareId = await getTargetHardwareUuid(spawner);
|
|
54
|
+
const hardwareId = await getTargetHardwareUuid(JsSpawner());
|
|
52
55
|
const device = {
|
|
53
|
-
deviceMode:
|
|
56
|
+
deviceMode: 'production',
|
|
54
57
|
hardwareId,
|
|
55
58
|
txId: uuidv4(),
|
|
56
59
|
userName: username,
|
|
57
|
-
friendlyName: name
|
|
60
|
+
friendlyName: name
|
|
58
61
|
};
|
|
59
62
|
|
|
60
|
-
const response
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
const response: { deviceUuid: string; claimCertificate: string[] } =
|
|
64
|
+
await microServiceHttpClient(
|
|
65
|
+
'fleet-provision',
|
|
66
|
+
'addDevice',
|
|
67
|
+
'POST',
|
|
68
|
+
JSON.stringify(device)
|
|
69
|
+
);
|
|
70
|
+
logger.debug(`addDevice Response: ${JSON.stringify(response, null, 2)}`);
|
|
66
71
|
|
|
72
|
+
if (!Object.hasOwn(response, 'claimCertificate')) {
|
|
73
|
+
throw new Error(
|
|
74
|
+
"Device cannot be provisioned. Run 'aai-agent device clean' and retry."
|
|
75
|
+
);
|
|
76
|
+
}
|
|
67
77
|
const ROOT_CERT_AWS = await httpClient(
|
|
68
|
-
|
|
69
|
-
|
|
78
|
+
'https://www.amazontrust.com/repository/AmazonRootCA1.pem',
|
|
79
|
+
'GET',
|
|
80
|
+
{}
|
|
70
81
|
);
|
|
71
82
|
|
|
72
|
-
await
|
|
83
|
+
await writeTokenAndDeviceCfg({
|
|
84
|
+
deviceUuid: response.deviceUuid
|
|
85
|
+
});
|
|
73
86
|
|
|
74
|
-
await JsSpawner().mkdirp(BOOTSTRAP_CERTIFICATES_DIR_PATH);
|
|
75
|
-
|
|
87
|
+
await JsSpawner().mkdirp(BOOTSTRAP_CERTIFICATES_DIR_PATH());
|
|
88
|
+
|
|
89
|
+
await JsSpawner({ path: LOCAL_CERT_AND_KEY_DIR }).writeFile(
|
|
76
90
|
AWS_ROOT_CERTIFICATE_FILE_NAME,
|
|
77
91
|
ROOT_CERT_AWS
|
|
78
92
|
);
|
|
79
|
-
const certSpawner = JsSpawner({
|
|
93
|
+
const certSpawner = JsSpawner({
|
|
94
|
+
path: BOOTSTRAP_CERTIFICATES_DIR_PATH()
|
|
95
|
+
});
|
|
80
96
|
for (const key in response.claimCertificate) {
|
|
81
97
|
await certSpawner.writeFile(key, response.claimCertificate[key]);
|
|
82
98
|
}
|
|
83
99
|
|
|
84
|
-
logger.info(`Initialized device
|
|
85
|
-
}
|
|
100
|
+
logger.info(`Initialized device ${name}: UUID=${response.deviceUuid}`);
|
|
101
|
+
}
|
|
86
102
|
});
|
|
87
103
|
|
|
88
104
|
export const getInfoCliLeaf = CliLeaf({
|
|
89
|
-
name:
|
|
90
|
-
description:
|
|
105
|
+
name: 'get-info',
|
|
106
|
+
description: 'Get device info',
|
|
91
107
|
namedInputs: {},
|
|
92
108
|
async action(_, opts) {
|
|
93
109
|
const deviceInfo = [
|
|
94
|
-
[
|
|
95
|
-
[
|
|
96
|
-
[
|
|
110
|
+
['CPU Utilization', `${String(await getCpuUtil())} %`],
|
|
111
|
+
['Disk Utilization', `${String(await getDiskUtil())} %`],
|
|
112
|
+
['Memory Utilization', `${String(await getMemUtil())} %`]
|
|
97
113
|
];
|
|
98
114
|
console.table(deviceInfo);
|
|
99
|
-
}
|
|
115
|
+
}
|
|
100
116
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { CliBranch } from '@alwaysai/alwayscli';
|
|
2
2
|
import { getInfoCliLeaf, initCliLeaf } from './device';
|
|
3
|
+
import { cleanCliLeaf } from './clean';
|
|
3
4
|
|
|
4
5
|
export const deviceCliBranch = CliBranch({
|
|
5
6
|
name: 'device',
|
|
6
7
|
description: 'Manage current device',
|
|
7
|
-
subcommands: [initCliLeaf, getInfoCliLeaf]
|
|
8
|
+
subcommands: [initCliLeaf, getInfoCliLeaf, cleanCliLeaf]
|
|
8
9
|
});
|
|
@@ -10,17 +10,17 @@ export const getModelPackageCliLeaf = CliLeaf({
|
|
|
10
10
|
positionalInput: CliStringInput({
|
|
11
11
|
description: 'For example, "alwaysai/mobilenet_ssd"',
|
|
12
12
|
required: true,
|
|
13
|
-
placeholder: '<id>'
|
|
13
|
+
placeholder: '<id>'
|
|
14
14
|
}),
|
|
15
15
|
namedInputs: {
|
|
16
16
|
version: CliNumberInput({
|
|
17
17
|
description: 'The version number of the model',
|
|
18
|
-
required: false
|
|
18
|
+
required: false
|
|
19
19
|
}),
|
|
20
20
|
path: CliStringInput({
|
|
21
21
|
description: 'The output path to write model package to',
|
|
22
|
-
required: false
|
|
23
|
-
})
|
|
22
|
+
required: false
|
|
23
|
+
})
|
|
24
24
|
},
|
|
25
25
|
async action(id, opts) {
|
|
26
26
|
const path = opts.path || process.cwd();
|
|
@@ -29,5 +29,5 @@ export const getModelPackageCliLeaf = CliLeaf({
|
|
|
29
29
|
opts.version || (await CliRpcClient().getModelVersion({ id })).version;
|
|
30
30
|
await appInstallModel(spawner, id, version);
|
|
31
31
|
logger.info(`Completed downloading ${id} to ${path}`);
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
});
|
package/src/subcommands/index.ts
CHANGED
package/src/subcommands/login.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CliLeaf, CliStringInput } from '@alwaysai/alwayscli';
|
|
2
2
|
import { alwaysaiUserLoginYesComponent } from 'alwaysai/lib/components/user';
|
|
3
|
-
import {
|
|
3
|
+
import { writeTokenAndDeviceCfg } from '../infrastructure/tokens-and-device-cfg';
|
|
4
4
|
|
|
5
5
|
export const loginCliLeaf = CliLeaf({
|
|
6
6
|
name: 'login',
|
|
@@ -8,26 +8,26 @@ export const loginCliLeaf = CliLeaf({
|
|
|
8
8
|
namedInputs: {
|
|
9
9
|
email: CliStringInput({
|
|
10
10
|
description: 'alwaysAI email',
|
|
11
|
-
required: true
|
|
11
|
+
required: true
|
|
12
12
|
}),
|
|
13
13
|
password: CliStringInput({
|
|
14
14
|
description: 'Account password',
|
|
15
|
-
required: true
|
|
15
|
+
required: true
|
|
16
16
|
}),
|
|
17
17
|
device: CliStringInput({
|
|
18
18
|
description: 'The device UUID',
|
|
19
|
-
required: false
|
|
20
|
-
})
|
|
19
|
+
required: false
|
|
20
|
+
})
|
|
21
21
|
},
|
|
22
22
|
async action(_, opts) {
|
|
23
23
|
const { email, password, device } = opts;
|
|
24
24
|
|
|
25
25
|
await alwaysaiUserLoginYesComponent({
|
|
26
26
|
alwaysaiUserEmail: email,
|
|
27
|
-
alwaysaiUserPassword: password
|
|
27
|
+
alwaysaiUserPassword: password
|
|
28
28
|
});
|
|
29
29
|
if (device) {
|
|
30
|
-
await
|
|
30
|
+
await writeTokenAndDeviceCfg({ deviceUuid: device });
|
|
31
31
|
}
|
|
32
|
-
}
|
|
32
|
+
}
|
|
33
33
|
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsSpawner } from 'alwaysai/lib/util';
|
|
2
|
+
import { logger } from '../util/logger';
|
|
3
|
+
import { LOCAL_CERT_AND_KEY_DIR } from 'alwaysai/lib/constants';
|
|
4
|
+
import { BOOTSTRAP_CERTIFICATES_DIR_PATH } from '../util/directories';
|
|
5
|
+
|
|
6
|
+
export const rmBootstrapCertsAndClose = async () => {
|
|
7
|
+
const spawner = JsSpawner();
|
|
8
|
+
await spawner.rimraf(BOOTSTRAP_CERTIFICATES_DIR_PATH());
|
|
9
|
+
await spawner.rimraf(LOCAL_CERT_AND_KEY_DIR);
|
|
10
|
+
logger.error('Could not provision device. Try again.');
|
|
11
|
+
process.exit(1);
|
|
12
|
+
};
|