@intflow/sentinelctl 0.6.0 → 0.7.1
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/README.md +29 -4
- package/package.json +2 -2
- package/src/commands.mjs +71 -14
- package/src/main.mjs +4 -1
package/README.md
CHANGED
|
@@ -25,12 +25,37 @@ sentinelctl login
|
|
|
25
25
|
|
|
26
26
|
```bash
|
|
27
27
|
sentinelctl whoami
|
|
28
|
-
sentinelctl sessions list # your web sessions and
|
|
28
|
+
sentinelctl sessions list # your web sessions, CLI tokens and access keys
|
|
29
29
|
sentinelctl logout # revoke on the server and delete local credentials
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
Credentials live in `~/.config/sentinelctl/credentials.json` (Linux/macOS) or `%APPDATA%\sentinelctl\credentials.json` (Windows); override with `SENTINELCTL_CONFIG`. The server is taken from `--server`, then `SENTINEL_URL`, then the saved profile, then the default. Automation can pass `SENTINEL_TOKEN` instead of a credentials file.
|
|
33
33
|
|
|
34
|
+
## Access keys and MCP
|
|
35
|
+
|
|
36
|
+
An access key is a long-lived credential for MCP clients and scripts. It carries your account and your current role, and it keeps working without any browser or CLI login: logging out, an expired web session or a revoked CLI token do not affect it.
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
sentinelctl access create "work laptop" # prints the key once
|
|
40
|
+
sentinelctl access list
|
|
41
|
+
sentinelctl access revoke <key-id>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
- A key lasts 30 days. Each time it is used a week or more after its last extension it gains 7 days, so a key in regular use does not expire. An unused key expires after 30 days.
|
|
45
|
+
- Up to 10 keys per person. Keys are created and revoked only from a web or CLI login, never with another key.
|
|
46
|
+
- The key stops working when you revoke it or an admin disables your account. A role change applies on the next request.
|
|
47
|
+
|
|
48
|
+
The console serves every command of this CLI as a remote MCP tool at `/api/mcp/` (Streamable HTTP). Nothing is installed on the client, and new server releases update the tools. Any MCP client that supports Streamable HTTP with custom headers can connect:
|
|
49
|
+
|
|
50
|
+
- URL: `https://monitor.intflow.dev/api/mcp/`
|
|
51
|
+
- Header: `Authorization: Bearer <access key>`
|
|
52
|
+
|
|
53
|
+
```json
|
|
54
|
+
{ "mcpServers": { "sentinel": { "type": "http", "url": "https://monitor.intflow.dev/api/mcp/", "headers": { "Authorization": "Bearer sentinel_..." } } } }
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Clients that register servers by command take the same two values, for example `claude mcp add --transport http sentinel https://monitor.intflow.dev/api/mcp/ --header "Authorization: Bearer sentinel_..."`. Tools are named `sentinel_<group>_<command>` (for example `sentinel_logs_stats`) and take the same options; the tool list contains only what your role may run. The same key also works as `SENTINEL_TOKEN` for this CLI.
|
|
58
|
+
|
|
34
59
|
## Getting help
|
|
35
60
|
|
|
36
61
|
```bash
|
|
@@ -114,8 +139,8 @@ sentinelctl metadata import backup.json --dry-run
|
|
|
114
139
|
sentinelctl admin users
|
|
115
140
|
sentinelctl admin grant kim@intflow.ai --role editor # works before the first login
|
|
116
141
|
sentinelctl admin reset kim@intflow.ai # back to the default viewer
|
|
117
|
-
sentinelctl admin disable kim@intflow.ai # block access and end all sessions now
|
|
118
|
-
sentinelctl admin sessions --kind cli
|
|
142
|
+
sentinelctl admin disable kim@intflow.ai # block access and end all sessions, tokens and keys now
|
|
143
|
+
sentinelctl admin sessions --kind access # web, cli or access
|
|
119
144
|
sentinelctl admin revoke <session-id>
|
|
120
145
|
sentinelctl admin audit --cleanup
|
|
121
146
|
sentinelctl admin operations -r 7d
|
|
@@ -139,7 +164,7 @@ The server tells the CLI the latest version; when a newer one exists the CLI pri
|
|
|
139
164
|
GitHub Actions publishes both packages (`.github/workflows/publish-cli.yml`) with npm trusted publishing, so no npm token is stored.
|
|
140
165
|
|
|
141
166
|
1. Bump `cli/package.json`, `cli/unscoped/package.json` (version and its `@intflow/sentinelctl` dependency) and `cliLatestVersion` in `config/dashboard.json` to the same version; `node scripts/check-cli-release.mjs` checks this.
|
|
142
|
-
2. Commit, then push a tag: `git tag cli-v0.
|
|
167
|
+
2. Commit, then push a tag: `git tag cli-v0.7.1 && git push origin cli-v0.7.1`.
|
|
143
168
|
3. The workflow runs the CLI checks and tests, publishes `@intflow/sentinelctl`, waits for the registry, then publishes the `sentinelctl` alias. Versions already on npm are skipped. Run it manually (Actions → publish-cli) to verify and pack without publishing.
|
|
144
169
|
|
|
145
170
|
One-time setup on npmjs.com, for each of the two packages: Settings → Trusted Publisher → GitHub Actions, organization or user `yeon3724`, repository `sentinel-fleet-console`, workflow `publish-cli.yml`, environment `npm`.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intflow/sentinelctl",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Sentinel Fleet Console CLI: search device logs, inspect status and metrics, edit metadata and
|
|
3
|
+
"version": "0.7.1",
|
|
4
|
+
"description": "Sentinel Fleet Console CLI: search device logs, inspect status and metrics, edit metadata, manage roles and create access keys for MCP",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"sentinelctl": "bin/sentinelctl.mjs"
|
package/src/commands.mjs
CHANGED
|
@@ -740,16 +740,19 @@ async function metadataExport(context, { options }) {
|
|
|
740
740
|
context.note(`Saved metadata for ${body.devices?.length ?? 0} devices to ${options.file}.`);
|
|
741
741
|
return;
|
|
742
742
|
}
|
|
743
|
-
context
|
|
743
|
+
emit(context, body, () => JSON.stringify(body, null, 2));
|
|
744
744
|
}
|
|
745
745
|
|
|
746
746
|
async function metadataImport(context, { options, positionals }) {
|
|
747
|
-
if (!positionals[0]
|
|
747
|
+
if (!positionals[0] && options.data === undefined) {
|
|
748
|
+
throw new UsageError('A JSON file path or --data is required.', { hint: 'Use the format produced by `sentinelctl metadata export`.' });
|
|
749
|
+
}
|
|
750
|
+
if (positionals[0] && options.data !== undefined) throw new UsageError('Give either a file or --data, not both.');
|
|
748
751
|
let payload;
|
|
749
752
|
try {
|
|
750
|
-
payload = JSON.parse(await readFile(positionals[0], 'utf8'));
|
|
753
|
+
payload = JSON.parse(options.data ?? await readFile(positionals[0], 'utf8'));
|
|
751
754
|
} catch {
|
|
752
|
-
throw new UsageError(`Cannot read JSON file: ${positionals[0]}`);
|
|
755
|
+
throw new UsageError(options.data === undefined ? `Cannot read JSON file: ${positionals[0]}` : '--data must be JSON in export format.');
|
|
753
756
|
}
|
|
754
757
|
const path = options['dry-run'] ? '/api/metadata/import/validate' : '/api/metadata/import';
|
|
755
758
|
const body = (await context.client.request('POST', path, { query: { conflictPolicy: options.conflict }, body: payload })).body;
|
|
@@ -759,7 +762,7 @@ async function metadataImport(context, { options, positionals }) {
|
|
|
759
762
|
|
|
760
763
|
const sessionColumns = [
|
|
761
764
|
{ header: 'ID', value: (session) => session.id },
|
|
762
|
-
{ header: 'KIND', value: (session) => (
|
|
765
|
+
{ header: 'KIND', value: (session) => ({ cli: 'cli', access: 'key' })[session.kind] ?? 'web' },
|
|
763
766
|
{ header: 'USER', value: (session) => session.user, max: 32 },
|
|
764
767
|
{ header: 'CLIENT', value: (session) => session.clientName ?? '-', max: 28 },
|
|
765
768
|
{ header: 'LAST USED', value: (session) => localTime(session.lastSeenAt) },
|
|
@@ -779,13 +782,47 @@ async function sessionsRevoke(context, { positionals }) {
|
|
|
779
782
|
context.out(`Revoked session ${positionals[0]}.`);
|
|
780
783
|
}
|
|
781
784
|
|
|
785
|
+
const accessKeyColumns = [
|
|
786
|
+
{ header: 'ID', value: (key) => key.id },
|
|
787
|
+
{ header: 'NAME', value: (key) => key.name, max: 32 },
|
|
788
|
+
{ header: 'CREATED', value: (key) => localTime(key.createdAt) },
|
|
789
|
+
{ header: 'LAST USED', value: (key) => (key.lastUsedAt ? localTime(key.lastUsedAt) : 'never') },
|
|
790
|
+
{ header: 'EXPIRES', value: (key) => localTime(key.expiresAt) },
|
|
791
|
+
];
|
|
792
|
+
|
|
793
|
+
async function accessList(context) {
|
|
794
|
+
const body = await context.client.get('/api/access');
|
|
795
|
+
emit(context, context.global.output === 'ndjson' ? body.keys : body, () => (body.keys.length
|
|
796
|
+
? renderTable(body.keys, accessKeyColumns, { width: context.width })
|
|
797
|
+
: 'No access keys. Create one with `sentinelctl access create <name>`.'));
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
async function accessCreate(context, { positionals }) {
|
|
801
|
+
const name = positionals.join(' ').trim();
|
|
802
|
+
if (!name) throw new UsageError('A key name is required.', { hint: 'Example: sentinelctl access create "work laptop"' });
|
|
803
|
+
const key = await context.client.post('/api/access', { name });
|
|
804
|
+
const mcpUrl = new URL('/api/mcp/', context.client.server).href;
|
|
805
|
+
emit(context, { ...key, mcpUrl }, () => [
|
|
806
|
+
renderKeyValues([['Name', key.name], ['ID', key.id], ['Expires', localTime(key.expiresAt)], ['MCP URL', mcpUrl]]),
|
|
807
|
+
'',
|
|
808
|
+
key.token,
|
|
809
|
+
].join('\n'));
|
|
810
|
+
context.hint(`Shown once; store it now. Any MCP client that speaks Streamable HTTP connects with URL ${mcpUrl} and header "Authorization: Bearer <key>".`);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
async function accessRevoke(context, { positionals }) {
|
|
814
|
+
if (!positionals[0]) throw new UsageError('A key ID is required.', { hint: 'List them with `sentinelctl access list`.' });
|
|
815
|
+
await context.client.request('DELETE', `/api/access/${encodeURIComponent(positionals[0])}`);
|
|
816
|
+
context.out(`Revoked access key ${positionals[0]}.`);
|
|
817
|
+
}
|
|
818
|
+
|
|
782
819
|
async function adminUsers(context) {
|
|
783
820
|
const body = await context.client.get('/api/admin/users');
|
|
784
821
|
emit(context, context.global.output === 'ndjson' ? body.users : body, () => renderTable(body.users, [
|
|
785
822
|
{ header: 'EMAIL', value: (user) => user.email, max: 36 },
|
|
786
823
|
{ header: 'ROLE', value: (user) => (user.disabled ? 'disabled' : user.effectiveRole) },
|
|
787
824
|
{ header: 'SOURCE', value: (user) => ({ bootstrap: 'bootstrap admin', grant: 'granted', default: 'default', disabled: 'disabled', intflow_app_admin: 'intflow app admin' })[user.roleSource] ?? user.roleSource },
|
|
788
|
-
{ header: 'WEB/CLI', value: (user) => `${user.sessions.web}/${user.sessions.cli}` },
|
|
825
|
+
{ header: 'WEB/CLI/KEY', value: (user) => `${user.sessions.web}/${user.sessions.cli}/${user.sessions.access ?? 0}` },
|
|
789
826
|
{ header: 'LAST LOGIN', value: (user) => localTime(user.lastLoginAt) },
|
|
790
827
|
], { width: context.width }));
|
|
791
828
|
}
|
|
@@ -1150,8 +1187,9 @@ const commands = [
|
|
|
1150
1187
|
{
|
|
1151
1188
|
group: 'metadata', name: 'import', run: metadataImport, role: 'admin', mutates: true,
|
|
1152
1189
|
summary: 'Import metadata in export format',
|
|
1153
|
-
args: [{ name: 'file' }],
|
|
1190
|
+
args: [{ name: 'file', optional: true, description: 'JSON file from metadata export.' }],
|
|
1154
1191
|
options: {
|
|
1192
|
+
data: { type: 'string', placeholder: 'json', description: 'Export-format JSON given inline instead of a file.' },
|
|
1155
1193
|
'dry-run': { type: 'boolean', description: 'Validate only.' },
|
|
1156
1194
|
conflict: { type: 'string', choices: ['error', 'skip', 'overwrite'], default: 'error', description: 'What to do with devices that already have metadata.' },
|
|
1157
1195
|
},
|
|
@@ -1160,19 +1198,37 @@ const commands = [
|
|
|
1160
1198
|
},
|
|
1161
1199
|
{
|
|
1162
1200
|
group: 'sessions', name: 'list', run: sessionsList, role: 'viewer', mutates: false,
|
|
1163
|
-
summary: 'Your web sessions and
|
|
1201
|
+
summary: 'Your web sessions, CLI tokens and access keys', options: {},
|
|
1164
1202
|
examples: ['sentinelctl sessions list'], output: '{sessions[]: {id, kind, user, clientName, createdAt, lastSeenAt, expiresAt, current}}.',
|
|
1165
1203
|
},
|
|
1166
1204
|
{
|
|
1167
1205
|
group: 'sessions', name: 'revoke', run: sessionsRevoke, role: 'viewer', mutates: true,
|
|
1168
|
-
summary: 'Revoke one of your sessions or
|
|
1206
|
+
summary: 'Revoke one of your sessions, CLI tokens or access keys', args: [{ name: 'session-id' }], options: {},
|
|
1169
1207
|
examples: ['sentinelctl sessions revoke <session-id>'], output: 'Confirmation message.',
|
|
1170
1208
|
},
|
|
1209
|
+
{
|
|
1210
|
+
group: 'access', name: 'create', run: accessCreate, role: 'viewer', mutates: true, mcp: false,
|
|
1211
|
+
summary: 'Create an access key for MCP clients and scripts (shown once)',
|
|
1212
|
+
description: 'The key carries your account and role, works without a browser or CLI login, lasts 30 days and gains 7 more days whenever it is used a week or more after the last extension. Up to 10 keys per person.',
|
|
1213
|
+
args: [{ name: 'name', description: 'A label to recognise the key by, 1-80 characters.' }], options: {},
|
|
1214
|
+
examples: ['sentinelctl access create "work laptop"', 'sentinelctl access create ci -o json --select token'],
|
|
1215
|
+
output: '{id, name, createdAt, lastUsedAt, expiresAt, token, mcpUrl}. The token is never shown again.',
|
|
1216
|
+
},
|
|
1217
|
+
{
|
|
1218
|
+
group: 'access', name: 'list', run: accessList, role: 'viewer', mutates: false, mcp: false,
|
|
1219
|
+
summary: 'Your access keys', options: {},
|
|
1220
|
+
examples: ['sentinelctl access list'], output: '{keys[]: {id, name, createdAt, lastUsedAt, expiresAt}}.',
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
group: 'access', name: 'revoke', run: accessRevoke, role: 'viewer', mutates: true, mcp: false,
|
|
1224
|
+
summary: 'Revoke one of your access keys now', args: [{ name: 'key-id' }], options: {},
|
|
1225
|
+
examples: ['sentinelctl access revoke <key-id>'], output: 'Confirmation message.',
|
|
1226
|
+
},
|
|
1171
1227
|
{
|
|
1172
1228
|
group: 'admin', name: 'users', run: adminUsers, role: 'admin', mutates: false,
|
|
1173
1229
|
summary: 'Users with their role, where it comes from, and session counts', options: {},
|
|
1174
1230
|
examples: ['sentinelctl admin users -o json'],
|
|
1175
|
-
output: '{users[]: {email, name, effectiveRole, roleSource, grantedRole, disabled, bootstrapAdmin, sessions{web, cli}, lastLoginAt}}.',
|
|
1231
|
+
output: '{users[]: {email, name, effectiveRole, roleSource, grantedRole, disabled, bootstrapAdmin, sessions{web, cli, access}, lastLoginAt}}.',
|
|
1176
1232
|
},
|
|
1177
1233
|
{
|
|
1178
1234
|
group: 'admin', name: 'grant', run: adminGrantCommand({}), role: 'admin', mutates: true,
|
|
@@ -1187,18 +1243,18 @@ const commands = [
|
|
|
1187
1243
|
},
|
|
1188
1244
|
{
|
|
1189
1245
|
group: 'admin', name: 'disable', run: adminGrantCommand({ role: null, disabled: true }), role: 'admin', mutates: true,
|
|
1190
|
-
summary: 'Block access and end all of the user\'s sessions
|
|
1246
|
+
summary: 'Block access and end all of the user\'s sessions, CLI tokens and access keys now', args: [{ name: 'email' }], options: {},
|
|
1191
1247
|
examples: ['sentinelctl admin disable kim@intflow.ai'], output: 'The updated user row. Undo with admin reset.',
|
|
1192
1248
|
},
|
|
1193
1249
|
{
|
|
1194
1250
|
group: 'admin', name: 'sessions', run: adminSessions, role: 'admin', mutates: false,
|
|
1195
|
-
summary: 'All web sessions and
|
|
1196
|
-
options: { kind: { type: 'string', choices: ['web', 'cli'], description: 'Filter by kind.' } },
|
|
1251
|
+
summary: 'All web sessions, CLI tokens and access keys',
|
|
1252
|
+
options: { kind: { type: 'string', choices: ['web', 'cli', 'access'], description: 'Filter by kind.' } },
|
|
1197
1253
|
examples: ['sentinelctl admin sessions --kind cli'], output: '{sessions[]}.',
|
|
1198
1254
|
},
|
|
1199
1255
|
{
|
|
1200
1256
|
group: 'admin', name: 'revoke', run: adminRevokeSession, role: 'admin', mutates: true,
|
|
1201
|
-
summary: 'Revoke anyone\'s session or
|
|
1257
|
+
summary: 'Revoke anyone\'s session, CLI token or access key', args: [{ name: 'session-id' }], options: {},
|
|
1202
1258
|
examples: ['sentinelctl admin revoke <session-id>'], output: 'Confirmation message.',
|
|
1203
1259
|
},
|
|
1204
1260
|
{
|
|
@@ -1241,6 +1297,7 @@ export const groups = {
|
|
|
1241
1297
|
devices: 'Device list, details, reception history, metric-log correlation',
|
|
1242
1298
|
metadata: 'Device metadata: read, edit (editor), import/export (admin)',
|
|
1243
1299
|
sessions: 'Your sessions and CLI tokens',
|
|
1300
|
+
access: 'Access keys for MCP clients and scripts',
|
|
1244
1301
|
admin: 'Roles, all sessions, audit clean-up, capacity (admin)',
|
|
1245
1302
|
};
|
|
1246
1303
|
|
package/src/main.mjs
CHANGED
|
@@ -132,7 +132,10 @@ function overviewHelp() {
|
|
|
132
132
|
|
|
133
133
|
const agentGuide = `sentinelctl for AI agents
|
|
134
134
|
|
|
135
|
-
Setup A human runs \`sentinelctl login\` once (30 days), or set
|
|
135
|
+
Setup A human runs \`sentinelctl login\` once (30 days), or set SENTINEL_URL and SENTINEL_TOKEN
|
|
136
|
+
(an access key from \`sentinelctl access create <name>\` works and renews itself while used).
|
|
137
|
+
MCP The same commands are remote MCP tools for any Streamable HTTP client: URL <server>/api/mcp/,
|
|
138
|
+
header Authorization: Bearer <access key>. Nothing to install; the server updates the tools.
|
|
136
139
|
Output Use -o json. stdout is data; notes, hints and errors go to stderr (--quiet drops notes).
|
|
137
140
|
Errors One stderr line {"error":{status,code,message,hint,exitCode}}; messages are Korean, hints English.
|
|
138
141
|
Exit 0 ok · 1 server/network (retry later) · 2 usage (fix arguments) · 3 login/role/too old (stop).
|