@positronic/cli 0.0.56 → 0.0.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/cli.js +130 -0
- package/dist/src/commands/auth.js +98 -0
- package/dist/src/commands/helpers.js +48 -10
- package/dist/src/commands/project-config-manager.js +119 -0
- package/dist/src/commands/users.js +91 -0
- package/dist/src/components/agent-chat-view.js +125 -0
- package/dist/src/components/auth-list.js +56 -0
- package/dist/src/components/auth-login.js +209 -0
- package/dist/src/components/auth-logout.js +75 -0
- package/dist/src/components/auth-status.js +88 -0
- package/dist/src/components/brain-run.js +287 -254
- package/dist/src/components/brain-top-table.js +4 -0
- package/dist/src/components/event-detail.js +364 -0
- package/dist/src/components/events-view.js +221 -25
- package/dist/src/components/state-view.js +52 -0
- package/dist/src/components/top-navigator.js +80 -6
- package/dist/src/components/types.js +1 -0
- package/dist/src/components/users-create.js +293 -0
- package/dist/src/components/users-delete.js +294 -0
- package/dist/src/components/users-keys-add.js +156 -0
- package/dist/src/components/users-keys-list.js +119 -0
- package/dist/src/components/users-keys-remove.js +299 -0
- package/dist/src/components/users-list.js +109 -0
- package/dist/src/components/watch-keyboard.js +136 -0
- package/dist/src/components/watch-machine.js +573 -0
- package/dist/src/components/watch.js +357 -44
- package/dist/src/hooks/useApi.js +80 -42
- package/dist/src/lib/request-signer.js +208 -0
- package/dist/src/lib/ssh-key-utils.js +212 -0
- package/dist/src/utils/agent-utils.js +107 -0
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/commands/auth.d.ts +36 -0
- package/dist/types/commands/auth.d.ts.map +1 -0
- package/dist/types/commands/helpers.d.ts.map +1 -1
- package/dist/types/commands/project-config-manager.d.ts +43 -0
- package/dist/types/commands/project-config-manager.d.ts.map +1 -1
- package/dist/types/commands/users.d.ts +33 -0
- package/dist/types/commands/users.d.ts.map +1 -0
- package/dist/types/components/agent-chat-view.d.ts +12 -0
- package/dist/types/components/agent-chat-view.d.ts.map +1 -0
- package/dist/types/components/auth-list.d.ts +7 -0
- package/dist/types/components/auth-list.d.ts.map +1 -0
- package/dist/types/components/auth-login.d.ts +9 -0
- package/dist/types/components/auth-login.d.ts.map +1 -0
- package/dist/types/components/auth-logout.d.ts +8 -0
- package/dist/types/components/auth-logout.d.ts.map +1 -0
- package/dist/types/components/auth-status.d.ts +7 -0
- package/dist/types/components/auth-status.d.ts.map +1 -0
- package/dist/types/components/brain-run.d.ts +11 -1
- package/dist/types/components/brain-run.d.ts.map +1 -1
- package/dist/types/components/brain-top-table.d.ts.map +1 -1
- package/dist/types/components/event-detail.d.ts +10 -0
- package/dist/types/components/event-detail.d.ts.map +1 -0
- package/dist/types/components/events-view.d.ts +9 -7
- package/dist/types/components/events-view.d.ts.map +1 -1
- package/dist/types/components/state-view.d.ts +13 -0
- package/dist/types/components/state-view.d.ts.map +1 -0
- package/dist/types/components/top-navigator.d.ts.map +1 -1
- package/dist/types/components/types.d.ts +11 -0
- package/dist/types/components/types.d.ts.map +1 -0
- package/dist/types/components/users-create.d.ts +6 -0
- package/dist/types/components/users-create.d.ts.map +1 -0
- package/dist/types/components/users-delete.d.ts +7 -0
- package/dist/types/components/users-delete.d.ts.map +1 -0
- package/dist/types/components/users-keys-add.d.ts +8 -0
- package/dist/types/components/users-keys-add.d.ts.map +1 -0
- package/dist/types/components/users-keys-list.d.ts +6 -0
- package/dist/types/components/users-keys-list.d.ts.map +1 -0
- package/dist/types/components/users-keys-remove.d.ts +8 -0
- package/dist/types/components/users-keys-remove.d.ts.map +1 -0
- package/dist/types/components/users-list.d.ts +2 -0
- package/dist/types/components/users-list.d.ts.map +1 -0
- package/dist/types/components/watch-keyboard.d.ts +56 -0
- package/dist/types/components/watch-keyboard.d.ts.map +1 -0
- package/dist/types/components/watch-machine.d.ts +171 -0
- package/dist/types/components/watch-machine.d.ts.map +1 -0
- package/dist/types/components/watch.d.ts.map +1 -1
- package/dist/types/hooks/useApi.d.ts.map +1 -1
- package/dist/types/hooks/useBrainMachine.d.ts +9 -3
- package/dist/types/hooks/useBrainMachine.d.ts.map +1 -1
- package/dist/types/lib/request-signer.d.ts +51 -0
- package/dist/types/lib/request-signer.d.ts.map +1 -0
- package/dist/types/lib/ssh-key-utils.d.ts +45 -0
- package/dist/types/lib/ssh-key-utils.d.ts.map +1 -0
- package/dist/types/utils/agent-utils.d.ts +20 -0
- package/dist/types/utils/agent-utils.d.ts.map +1 -0
- package/package.json +7 -4
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_with_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
10
|
+
try {
|
|
11
|
+
var info = gen[key](arg);
|
|
12
|
+
var value = info.value;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
reject(error);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
if (info.done) {
|
|
18
|
+
resolve(value);
|
|
19
|
+
} else {
|
|
20
|
+
Promise.resolve(value).then(_next, _throw);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function _async_to_generator(fn) {
|
|
24
|
+
return function() {
|
|
25
|
+
var self = this, args = arguments;
|
|
26
|
+
return new Promise(function(resolve, reject) {
|
|
27
|
+
var gen = fn.apply(self, args);
|
|
28
|
+
function _next(value) {
|
|
29
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
30
|
+
}
|
|
31
|
+
function _throw(err) {
|
|
32
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
33
|
+
}
|
|
34
|
+
_next(undefined);
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function _iterable_to_array_limit(arr, i) {
|
|
39
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
40
|
+
if (_i == null) return;
|
|
41
|
+
var _arr = [];
|
|
42
|
+
var _n = true;
|
|
43
|
+
var _d = false;
|
|
44
|
+
var _s, _e;
|
|
45
|
+
try {
|
|
46
|
+
for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
|
|
47
|
+
_arr.push(_s.value);
|
|
48
|
+
if (i && _arr.length === i) break;
|
|
49
|
+
}
|
|
50
|
+
} catch (err) {
|
|
51
|
+
_d = true;
|
|
52
|
+
_e = err;
|
|
53
|
+
} finally{
|
|
54
|
+
try {
|
|
55
|
+
if (!_n && _i["return"] != null) _i["return"]();
|
|
56
|
+
} finally{
|
|
57
|
+
if (_d) throw _e;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return _arr;
|
|
61
|
+
}
|
|
62
|
+
function _non_iterable_rest() {
|
|
63
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
64
|
+
}
|
|
65
|
+
function _sliced_to_array(arr, i) {
|
|
66
|
+
return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
|
|
67
|
+
}
|
|
68
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
69
|
+
if (!o) return;
|
|
70
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
71
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
72
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
73
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
74
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
75
|
+
}
|
|
76
|
+
function _ts_generator(thisArg, body) {
|
|
77
|
+
var f, y, t, _ = {
|
|
78
|
+
label: 0,
|
|
79
|
+
sent: function() {
|
|
80
|
+
if (t[0] & 1) throw t[1];
|
|
81
|
+
return t[1];
|
|
82
|
+
},
|
|
83
|
+
trys: [],
|
|
84
|
+
ops: []
|
|
85
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
86
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
87
|
+
return this;
|
|
88
|
+
}), g;
|
|
89
|
+
function verb(n) {
|
|
90
|
+
return function(v) {
|
|
91
|
+
return step([
|
|
92
|
+
n,
|
|
93
|
+
v
|
|
94
|
+
]);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
function step(op) {
|
|
98
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
99
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
100
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
101
|
+
if (y = 0, t) op = [
|
|
102
|
+
op[0] & 2,
|
|
103
|
+
t.value
|
|
104
|
+
];
|
|
105
|
+
switch(op[0]){
|
|
106
|
+
case 0:
|
|
107
|
+
case 1:
|
|
108
|
+
t = op;
|
|
109
|
+
break;
|
|
110
|
+
case 4:
|
|
111
|
+
_.label++;
|
|
112
|
+
return {
|
|
113
|
+
value: op[1],
|
|
114
|
+
done: false
|
|
115
|
+
};
|
|
116
|
+
case 5:
|
|
117
|
+
_.label++;
|
|
118
|
+
y = op[1];
|
|
119
|
+
op = [
|
|
120
|
+
0
|
|
121
|
+
];
|
|
122
|
+
continue;
|
|
123
|
+
case 7:
|
|
124
|
+
op = _.ops.pop();
|
|
125
|
+
_.trys.pop();
|
|
126
|
+
continue;
|
|
127
|
+
default:
|
|
128
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
129
|
+
_ = 0;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
133
|
+
_.label = op[1];
|
|
134
|
+
break;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
137
|
+
_.label = t[1];
|
|
138
|
+
t = op;
|
|
139
|
+
break;
|
|
140
|
+
}
|
|
141
|
+
if (t && _.label < t[2]) {
|
|
142
|
+
_.label = t[2];
|
|
143
|
+
_.ops.push(op);
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
if (t[2]) _.ops.pop();
|
|
147
|
+
_.trys.pop();
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
op = body.call(thisArg, _);
|
|
151
|
+
} catch (e) {
|
|
152
|
+
op = [
|
|
153
|
+
6,
|
|
154
|
+
e
|
|
155
|
+
];
|
|
156
|
+
y = 0;
|
|
157
|
+
} finally{
|
|
158
|
+
f = t = 0;
|
|
159
|
+
}
|
|
160
|
+
if (op[0] & 5) throw op[1];
|
|
161
|
+
return {
|
|
162
|
+
value: op[0] ? op[1] : void 0,
|
|
163
|
+
done: true
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
import React, { useState, useEffect, useCallback } from 'react';
|
|
168
|
+
import { Box, Text, useInput, useApp } from 'ink';
|
|
169
|
+
import { ErrorComponent } from './error.js';
|
|
170
|
+
import { useApiDelete, useApiGet } from '../hooks/useApi.js';
|
|
171
|
+
export var UsersKeysRemove = function(param) {
|
|
172
|
+
var userId = param.userId, fingerprint = param.fingerprint, force = param.force;
|
|
173
|
+
var exit = useApp().exit;
|
|
174
|
+
var _useApiGet = useApiGet("/users/".concat(userId)), user = _useApiGet.data, loadingUser = _useApiGet.loading, userError = _useApiGet.error;
|
|
175
|
+
var _useApiDelete = useApiDelete('key'), deleting = _useApiDelete.loading, deleteError = _useApiDelete.error, execute = _useApiDelete.execute;
|
|
176
|
+
var _useState = _sliced_to_array(useState(force), 2), confirmed = _useState[0], setConfirmed = _useState[1];
|
|
177
|
+
var _useState1 = _sliced_to_array(useState(false), 2), deleted = _useState1[0], setDeleted = _useState1[1];
|
|
178
|
+
var _useState2 = _sliced_to_array(useState(false), 2), deletionStarted = _useState2[0], setDeletionStarted = _useState2[1];
|
|
179
|
+
var handleDelete = useCallback(function() {
|
|
180
|
+
return _async_to_generator(function() {
|
|
181
|
+
var e;
|
|
182
|
+
return _ts_generator(this, function(_state) {
|
|
183
|
+
switch(_state.label){
|
|
184
|
+
case 0:
|
|
185
|
+
if (deletionStarted) return [
|
|
186
|
+
2
|
|
187
|
+
];
|
|
188
|
+
setDeletionStarted(true);
|
|
189
|
+
_state.label = 1;
|
|
190
|
+
case 1:
|
|
191
|
+
_state.trys.push([
|
|
192
|
+
1,
|
|
193
|
+
3,
|
|
194
|
+
,
|
|
195
|
+
4
|
|
196
|
+
]);
|
|
197
|
+
return [
|
|
198
|
+
4,
|
|
199
|
+
execute("/users/".concat(userId, "/keys/").concat(encodeURIComponent(fingerprint)))
|
|
200
|
+
];
|
|
201
|
+
case 2:
|
|
202
|
+
_state.sent();
|
|
203
|
+
setDeleted(true);
|
|
204
|
+
return [
|
|
205
|
+
3,
|
|
206
|
+
4
|
|
207
|
+
];
|
|
208
|
+
case 3:
|
|
209
|
+
e = _state.sent();
|
|
210
|
+
return [
|
|
211
|
+
3,
|
|
212
|
+
4
|
|
213
|
+
];
|
|
214
|
+
case 4:
|
|
215
|
+
return [
|
|
216
|
+
2
|
|
217
|
+
];
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
})();
|
|
221
|
+
}, [
|
|
222
|
+
execute,
|
|
223
|
+
userId,
|
|
224
|
+
fingerprint,
|
|
225
|
+
deletionStarted
|
|
226
|
+
]);
|
|
227
|
+
useEffect(function() {
|
|
228
|
+
if (confirmed && user && !deleted && !deletionStarted) {
|
|
229
|
+
handleDelete();
|
|
230
|
+
}
|
|
231
|
+
}, [
|
|
232
|
+
confirmed,
|
|
233
|
+
user,
|
|
234
|
+
deleted,
|
|
235
|
+
deletionStarted,
|
|
236
|
+
handleDelete
|
|
237
|
+
]);
|
|
238
|
+
useInput(function(input, key) {
|
|
239
|
+
if (!confirmed && !deleting && !deleted) {
|
|
240
|
+
if (input.toLowerCase() === 'y') {
|
|
241
|
+
setConfirmed(true);
|
|
242
|
+
} else if (input.toLowerCase() === 'n' || key.escape) {
|
|
243
|
+
exit();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
if (userError) {
|
|
248
|
+
return /*#__PURE__*/ React.createElement(ErrorComponent, {
|
|
249
|
+
error: userError
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (deleteError) {
|
|
253
|
+
return /*#__PURE__*/ React.createElement(ErrorComponent, {
|
|
254
|
+
error: deleteError
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
if (loadingUser) {
|
|
258
|
+
return /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, null, "Loading user..."));
|
|
259
|
+
}
|
|
260
|
+
if (!user) {
|
|
261
|
+
return /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
|
|
262
|
+
color: "red"
|
|
263
|
+
}, "User not found: ", userId));
|
|
264
|
+
}
|
|
265
|
+
if (deleted) {
|
|
266
|
+
return /*#__PURE__*/ React.createElement(Box, {
|
|
267
|
+
flexDirection: "column",
|
|
268
|
+
paddingTop: 1,
|
|
269
|
+
paddingBottom: 1
|
|
270
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
271
|
+
color: "green"
|
|
272
|
+
}, "Key removed successfully."), /*#__PURE__*/ React.createElement(Box, {
|
|
273
|
+
marginTop: 1
|
|
274
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
275
|
+
dimColor: true
|
|
276
|
+
}, "Fingerprint: ", fingerprint)));
|
|
277
|
+
}
|
|
278
|
+
if (deleting) {
|
|
279
|
+
return /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, null, "Removing key..."));
|
|
280
|
+
}
|
|
281
|
+
if (!confirmed) {
|
|
282
|
+
return /*#__PURE__*/ React.createElement(Box, {
|
|
283
|
+
flexDirection: "column",
|
|
284
|
+
paddingTop: 1,
|
|
285
|
+
paddingBottom: 1
|
|
286
|
+
}, /*#__PURE__*/ React.createElement(Text, null, "Are you sure you want to remove this key from user ", /*#__PURE__*/ React.createElement(Text, {
|
|
287
|
+
bold: true
|
|
288
|
+
}, '"', user.name, '"'), "?"), /*#__PURE__*/ React.createElement(Text, {
|
|
289
|
+
dimColor: true
|
|
290
|
+
}, "Fingerprint: ", fingerprint), /*#__PURE__*/ React.createElement(Box, {
|
|
291
|
+
marginTop: 1
|
|
292
|
+
}, /*#__PURE__*/ React.createElement(Text, null, "Press ", /*#__PURE__*/ React.createElement(Text, {
|
|
293
|
+
bold: true
|
|
294
|
+
}, "y"), " to confirm, ", /*#__PURE__*/ React.createElement(Text, {
|
|
295
|
+
bold: true
|
|
296
|
+
}, "n"), " to cancel")));
|
|
297
|
+
}
|
|
298
|
+
return null;
|
|
299
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
function _array_like_to_array(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _array_without_holes(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
8
|
+
}
|
|
9
|
+
function _iterable_to_array(iter) {
|
|
10
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
11
|
+
}
|
|
12
|
+
function _non_iterable_spread() {
|
|
13
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
14
|
+
}
|
|
15
|
+
function _to_consumable_array(arr) {
|
|
16
|
+
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
17
|
+
}
|
|
18
|
+
function _unsupported_iterable_to_array(o, minLen) {
|
|
19
|
+
if (!o) return;
|
|
20
|
+
if (typeof o === "string") return _array_like_to_array(o, minLen);
|
|
21
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
22
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
23
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
24
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
|
|
25
|
+
}
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { Box, Text } from 'ink';
|
|
28
|
+
import { ErrorComponent } from './error.js';
|
|
29
|
+
import { useApiGet } from '../hooks/useApi.js';
|
|
30
|
+
var formatDate = function(timestamp) {
|
|
31
|
+
var date = new Date(timestamp);
|
|
32
|
+
return date.toLocaleDateString() + ' ' + date.toLocaleTimeString();
|
|
33
|
+
};
|
|
34
|
+
var truncate = function(text, maxWidth) {
|
|
35
|
+
if (text.length <= maxWidth) return text;
|
|
36
|
+
return text.substring(0, maxWidth - 3) + '...';
|
|
37
|
+
};
|
|
38
|
+
var padRight = function(text, width) {
|
|
39
|
+
return text + ' '.repeat(Math.max(0, width - text.length));
|
|
40
|
+
};
|
|
41
|
+
export var UsersList = function() {
|
|
42
|
+
var _useApiGet = useApiGet('/users'), data = _useApiGet.data, loading = _useApiGet.loading, error = _useApiGet.error;
|
|
43
|
+
if (error) {
|
|
44
|
+
return /*#__PURE__*/ React.createElement(ErrorComponent, {
|
|
45
|
+
error: error
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (loading) {
|
|
49
|
+
return /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, null, "Loading users..."));
|
|
50
|
+
}
|
|
51
|
+
if (!data || data.users.length === 0) {
|
|
52
|
+
return /*#__PURE__*/ React.createElement(Box, {
|
|
53
|
+
flexDirection: "column"
|
|
54
|
+
}, /*#__PURE__*/ React.createElement(Text, null, "No users found."), /*#__PURE__*/ React.createElement(Box, {
|
|
55
|
+
marginTop: 1
|
|
56
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
57
|
+
dimColor: true
|
|
58
|
+
}, 'Tip: Create a user with "px users create <name>"')));
|
|
59
|
+
}
|
|
60
|
+
var sortedUsers = _to_consumable_array(data.users).sort(function(a, b) {
|
|
61
|
+
return b.createdAt - a.createdAt;
|
|
62
|
+
});
|
|
63
|
+
var columns = {
|
|
64
|
+
name: {
|
|
65
|
+
header: 'Name',
|
|
66
|
+
width: 20
|
|
67
|
+
},
|
|
68
|
+
id: {
|
|
69
|
+
header: 'ID',
|
|
70
|
+
width: 36
|
|
71
|
+
},
|
|
72
|
+
created: {
|
|
73
|
+
header: 'Created',
|
|
74
|
+
width: 20
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var totalWidth = Object.values(columns).reduce(function(sum, col) {
|
|
78
|
+
return sum + col.width + 2;
|
|
79
|
+
}, 0) - 2;
|
|
80
|
+
return /*#__PURE__*/ React.createElement(Box, {
|
|
81
|
+
flexDirection: "column",
|
|
82
|
+
paddingTop: 1,
|
|
83
|
+
paddingBottom: 1
|
|
84
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
85
|
+
bold: true
|
|
86
|
+
}, "Found ", data.count, " user", data.count === 1 ? '' : 's', ":"), /*#__PURE__*/ React.createElement(Box, {
|
|
87
|
+
marginTop: 1,
|
|
88
|
+
flexDirection: "column"
|
|
89
|
+
}, /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
|
|
90
|
+
bold: true,
|
|
91
|
+
color: "cyan"
|
|
92
|
+
}, padRight(columns.name.header, columns.name.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
|
|
93
|
+
bold: true,
|
|
94
|
+
color: "cyan"
|
|
95
|
+
}, padRight(columns.id.header, columns.id.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
|
|
96
|
+
bold: true,
|
|
97
|
+
color: "cyan"
|
|
98
|
+
}, padRight(columns.created.header, columns.created.width))), /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
|
|
99
|
+
dimColor: true
|
|
100
|
+
}, '─'.repeat(totalWidth))), sortedUsers.map(function(user) {
|
|
101
|
+
return /*#__PURE__*/ React.createElement(Box, {
|
|
102
|
+
key: user.id
|
|
103
|
+
}, /*#__PURE__*/ React.createElement(Text, null, padRight(truncate(user.name, columns.name.width), columns.name.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
|
|
104
|
+
dimColor: true
|
|
105
|
+
}, padRight(user.id, columns.id.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
|
|
106
|
+
dimColor: true
|
|
107
|
+
}, padRight(formatDate(user.createdAt), columns.created.width)));
|
|
108
|
+
})));
|
|
109
|
+
};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Keyboard handler for the Watch component.
|
|
3
|
+
* Maps keyboard input to watch events that the state machine can process.
|
|
4
|
+
*
|
|
5
|
+
* This is a pure function that takes the current view state and keyboard input,
|
|
6
|
+
* and returns an event object (or null if no event should be triggered).
|
|
7
|
+
*/ /**
|
|
8
|
+
* Handle keyboard input and return the appropriate event.
|
|
9
|
+
* Returns null if no event should be triggered.
|
|
10
|
+
*/ export function handleKeyboardInput(input, key, ctx) {
|
|
11
|
+
var viewMode = ctx.viewMode, eventsViewMode = ctx.eventsViewMode, confirmingKill = ctx.confirmingKill, isKilling = ctx.isKilling, isKilled = ctx.isKilled, isComplete = ctx.isComplete, isPaused = ctx.isPaused, isPausing = ctx.isPausing, isResuming = ctx.isResuming, hasAgents = ctx.hasAgents, manageScreenBuffer = ctx.manageScreenBuffer;
|
|
12
|
+
// Kill confirmation mode takes priority
|
|
13
|
+
if (confirmingKill) {
|
|
14
|
+
if (input === 'y') {
|
|
15
|
+
return {
|
|
16
|
+
type: 'CONFIRM_KILL'
|
|
17
|
+
};
|
|
18
|
+
} else if (input === 'n' || key.escape) {
|
|
19
|
+
return {
|
|
20
|
+
type: 'CANCEL_KILL'
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// Block all other input during kill confirmation
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
// View-specific handling
|
|
27
|
+
switch(viewMode){
|
|
28
|
+
case 'state':
|
|
29
|
+
// State view: 'b' goes back to previous view
|
|
30
|
+
// j/k scrolling is handled by StateView component
|
|
31
|
+
if (input === 'b') {
|
|
32
|
+
return {
|
|
33
|
+
type: 'GO_BACK'
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
case 'agent-chat':
|
|
38
|
+
// Agent chat view: 'b' or escape goes back to previous view
|
|
39
|
+
// j/k scrolling is handled by AgentChatView component
|
|
40
|
+
if (input === 'b' || key.escape) {
|
|
41
|
+
return {
|
|
42
|
+
type: 'GO_BACK'
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
case 'agent-picker':
|
|
47
|
+
// Agent picker: 'b' or escape goes back to previous view
|
|
48
|
+
// SelectList handles its own navigation (up/down/enter)
|
|
49
|
+
if (input === 'b' || key.escape) {
|
|
50
|
+
return {
|
|
51
|
+
type: 'GO_BACK'
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
case 'message-input':
|
|
56
|
+
// Message input mode: Escape cancels
|
|
57
|
+
// TextInput handles its own input and Enter (onSubmit)
|
|
58
|
+
if (key.escape) {
|
|
59
|
+
return {
|
|
60
|
+
type: 'CANCEL_MESSAGE_INPUT'
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
return null;
|
|
64
|
+
case 'events':
|
|
65
|
+
case 'progress':
|
|
66
|
+
default:
|
|
67
|
+
// Progress and events views share most keyboard handling
|
|
68
|
+
return handleProgressAndEventsKeys(input, key, ctx);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Handle keyboard input when in progress or events view mode.
|
|
73
|
+
*/ function handleProgressAndEventsKeys(input, key, ctx) {
|
|
74
|
+
var viewMode = ctx.viewMode, eventsViewMode = ctx.eventsViewMode, isKilling = ctx.isKilling, isKilled = ctx.isKilled, isComplete = ctx.isComplete, isPaused = ctx.isPaused, isPausing = ctx.isPausing, isResuming = ctx.isResuming, hasAgents = ctx.hasAgents, manageScreenBuffer = ctx.manageScreenBuffer;
|
|
75
|
+
// View toggle
|
|
76
|
+
if (input === 'e') {
|
|
77
|
+
return {
|
|
78
|
+
type: 'GO_TO_EVENTS'
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
if (input === 'w') {
|
|
82
|
+
return {
|
|
83
|
+
type: 'GO_TO_PROGRESS'
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
// 'b' in events list mode goes back to progress view
|
|
87
|
+
// 'b' in events detail mode is handled by EventsView to go back to list
|
|
88
|
+
if (input === 'b' && viewMode === 'events' && eventsViewMode !== 'detail') {
|
|
89
|
+
return {
|
|
90
|
+
type: 'GO_TO_PROGRESS'
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
// 's' from progress view: show current state
|
|
94
|
+
if (input === 's' && viewMode === 'progress') {
|
|
95
|
+
return {
|
|
96
|
+
type: 'GO_TO_STATE'
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// 'x' initiates kill (only when brain is running)
|
|
100
|
+
if (input === 'x' && !isKilling && !isKilled && !isComplete) {
|
|
101
|
+
return {
|
|
102
|
+
type: 'INITIATE_KILL'
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// 'a' or 'A' shows agent view (if agents exist)
|
|
106
|
+
if ((input === 'a' || input === 'A') && hasAgents) {
|
|
107
|
+
return {
|
|
108
|
+
type: 'GO_TO_AGENTS'
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// 'm' enters message input mode (only when brain is running and has agents)
|
|
112
|
+
if (input === 'm' && !isComplete && hasAgents) {
|
|
113
|
+
return {
|
|
114
|
+
type: 'GO_TO_MESSAGE_INPUT'
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
// 'p' pauses the brain (only when running and not already paused/pausing)
|
|
118
|
+
if (input === 'p' && !isComplete && !isPaused && !isPausing) {
|
|
119
|
+
return {
|
|
120
|
+
type: 'PAUSE'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
// 'r' resumes the brain (only when paused and not already resuming)
|
|
124
|
+
if (input === 'r' && isPaused && !isResuming) {
|
|
125
|
+
return {
|
|
126
|
+
type: 'RESUME'
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// 'q' or escape quits (only when standalone with manageScreenBuffer=true)
|
|
130
|
+
if ((input === 'q' || key.escape) && manageScreenBuffer) {
|
|
131
|
+
return {
|
|
132
|
+
type: 'QUIT'
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return null;
|
|
136
|
+
}
|