@positronic/cli 0.0.56 → 0.0.58
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 +139 -0
- package/dist/src/commands/auth.js +111 -0
- package/dist/src/commands/helpers.js +68 -8
- 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-format-jwk-key.js +457 -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 +217 -45
- 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 +44 -0
- package/dist/types/commands/auth.d.ts.map +1 -0
- package/dist/types/commands/helpers.d.ts +4 -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-format-jwk-key.d.ts +6 -0
- package/dist/types/components/auth-format-jwk-key.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
package/dist/src/cli.js
CHANGED
|
@@ -160,6 +160,8 @@ import { ResourcesCommand } from './commands/resources.js';
|
|
|
160
160
|
import { ScheduleCommand } from './commands/schedule.js';
|
|
161
161
|
import { SecretCommand } from './commands/secret.js';
|
|
162
162
|
import { PagesCommand } from './commands/pages.js';
|
|
163
|
+
import { UsersCommand } from './commands/users.js';
|
|
164
|
+
import { AuthCommand } from './commands/auth.js';
|
|
163
165
|
import { readFileSync } from 'fs';
|
|
164
166
|
import { fileURLToPath } from 'url';
|
|
165
167
|
import { dirname, join } from 'path';
|
|
@@ -215,6 +217,7 @@ export function buildCli(options) {
|
|
|
215
217
|
var scheduleCommand = new ScheduleCommand();
|
|
216
218
|
var secretCommand = new SecretCommand();
|
|
217
219
|
var pagesCommand = new PagesCommand();
|
|
220
|
+
var usersCommand = new UsersCommand();
|
|
218
221
|
// Main CLI definition
|
|
219
222
|
var cli = yargs(argv).scriptName('positronic').usage('Usage: $0 <command> [options]').version(version).alias('v', 'version').help('h').alias('h', 'help').wrap(null).strictCommands().exitProcess(exitProcess);
|
|
220
223
|
// --- Project Management Commands (Global Mode Only) ---
|
|
@@ -864,6 +867,142 @@ export function buildCli(options) {
|
|
|
864
867
|
}).demandCommand(1, 'You need to specify a subcommand');
|
|
865
868
|
return yargsSecret;
|
|
866
869
|
});
|
|
870
|
+
// --- User Management Commands ---
|
|
871
|
+
cli = cli.command('users', 'Manage users and SSH keys for authentication\n', function(yargsUsers) {
|
|
872
|
+
yargsUsers.command('list', 'List all users\n', {}, function() {
|
|
873
|
+
var element = usersCommand.list();
|
|
874
|
+
render(element);
|
|
875
|
+
}).command('create <name>', 'Create a new user\n', function(yargsCreate) {
|
|
876
|
+
return yargsCreate.positional('name', {
|
|
877
|
+
describe: 'Name of the user',
|
|
878
|
+
type: 'string',
|
|
879
|
+
demandOption: true
|
|
880
|
+
}).example('$0 users create admin', 'Create a user named admin');
|
|
881
|
+
}, function(argv) {
|
|
882
|
+
var element = usersCommand.create(argv);
|
|
883
|
+
render(element);
|
|
884
|
+
}).command('delete <id>', 'Delete a user\n', function(yargsDelete) {
|
|
885
|
+
return yargsDelete.positional('id', {
|
|
886
|
+
describe: 'ID of the user to delete',
|
|
887
|
+
type: 'string',
|
|
888
|
+
demandOption: true
|
|
889
|
+
}).option('force', {
|
|
890
|
+
describe: 'Skip confirmation prompt',
|
|
891
|
+
type: 'boolean',
|
|
892
|
+
alias: 'f',
|
|
893
|
+
default: false
|
|
894
|
+
}).example('$0 users delete abc123', 'Delete a user').example('$0 users delete abc123 --force', 'Delete without confirmation');
|
|
895
|
+
}, function(argv) {
|
|
896
|
+
var element = usersCommand.delete(argv);
|
|
897
|
+
render(element);
|
|
898
|
+
}).command('keys', 'Manage SSH keys for users\n', function(yargsKeys) {
|
|
899
|
+
return yargsKeys.command('list <user-id>', 'List keys for a user\n', function(yargsKeysList) {
|
|
900
|
+
return yargsKeysList.positional('user-id', {
|
|
901
|
+
describe: 'User ID',
|
|
902
|
+
type: 'string',
|
|
903
|
+
demandOption: true
|
|
904
|
+
}).example('$0 users keys list abc123', 'List keys for a user');
|
|
905
|
+
}, function(argv) {
|
|
906
|
+
var element = usersCommand.keysList({
|
|
907
|
+
id: argv.userId
|
|
908
|
+
});
|
|
909
|
+
render(element);
|
|
910
|
+
}).command('add <user-id> <pubkey-path>', 'Add an SSH public key to a user\n', function(yargsAdd) {
|
|
911
|
+
return yargsAdd.positional('user-id', {
|
|
912
|
+
describe: 'User ID',
|
|
913
|
+
type: 'string',
|
|
914
|
+
demandOption: true
|
|
915
|
+
}).positional('pubkey-path', {
|
|
916
|
+
describe: 'Path to the SSH public key file',
|
|
917
|
+
type: 'string',
|
|
918
|
+
demandOption: true
|
|
919
|
+
}).option('label', {
|
|
920
|
+
describe: 'Label for the key (e.g., "laptop", "desktop")',
|
|
921
|
+
type: 'string',
|
|
922
|
+
alias: 'l'
|
|
923
|
+
}).example('$0 users keys add abc123 ~/.ssh/id_rsa.pub', 'Add RSA public key').example('$0 users keys add abc123 ~/.ssh/id_ed25519.pub --label laptop', 'Add key with label');
|
|
924
|
+
}, function(argv) {
|
|
925
|
+
var element = usersCommand.keysAdd({
|
|
926
|
+
id: argv.userId,
|
|
927
|
+
pubkeyPath: argv.pubkeyPath,
|
|
928
|
+
label: argv.label
|
|
929
|
+
});
|
|
930
|
+
render(element);
|
|
931
|
+
}).command('remove <user-id> <fingerprint>', 'Remove a key from a user\n', function(yargsRemove) {
|
|
932
|
+
return yargsRemove.positional('user-id', {
|
|
933
|
+
describe: 'User ID',
|
|
934
|
+
type: 'string',
|
|
935
|
+
demandOption: true
|
|
936
|
+
}).positional('fingerprint', {
|
|
937
|
+
describe: 'Fingerprint of the key to remove',
|
|
938
|
+
type: 'string',
|
|
939
|
+
demandOption: true
|
|
940
|
+
}).option('force', {
|
|
941
|
+
describe: 'Skip confirmation prompt',
|
|
942
|
+
type: 'boolean',
|
|
943
|
+
alias: 'f',
|
|
944
|
+
default: false
|
|
945
|
+
}).example('$0 users keys remove abc123 SHA256:...', 'Remove a key');
|
|
946
|
+
}, function(argv) {
|
|
947
|
+
var element = usersCommand.keysRemove({
|
|
948
|
+
id: argv.userId,
|
|
949
|
+
fingerprint: argv.fingerprint,
|
|
950
|
+
force: argv.force
|
|
951
|
+
});
|
|
952
|
+
render(element);
|
|
953
|
+
}).demandCommand(1, 'You need to specify a keys command (list, add, remove)');
|
|
954
|
+
}).demandCommand(1, 'You need to specify a users command (list, create, delete, keys)');
|
|
955
|
+
return yargsUsers;
|
|
956
|
+
});
|
|
957
|
+
// --- Auth Commands (Global Mode Only) ---
|
|
958
|
+
if (!isLocalDevMode) {
|
|
959
|
+
var authCommand = new AuthCommand();
|
|
960
|
+
cli = cli.command('auth', 'Manage authentication configuration\n', function(yargsAuth) {
|
|
961
|
+
yargsAuth.command('status', 'Show current auth configuration\n', function() {}, function() {
|
|
962
|
+
var element = authCommand.status();
|
|
963
|
+
render(element);
|
|
964
|
+
}).command('login', 'Configure SSH key for authentication\n', function(yargsLogin) {
|
|
965
|
+
return yargsLogin.option('path', {
|
|
966
|
+
describe: 'Path to SSH private key',
|
|
967
|
+
type: 'string',
|
|
968
|
+
alias: 'p'
|
|
969
|
+
}).option('project', {
|
|
970
|
+
describe: 'Set key for current project instead of global',
|
|
971
|
+
type: 'boolean',
|
|
972
|
+
default: false
|
|
973
|
+
}).example('$0 auth login', 'Interactive key selection').example('$0 auth login --path ~/.ssh/id_ed25519', 'Set key directly').example('$0 auth login --project', 'Set key for current project');
|
|
974
|
+
}, function(argv) {
|
|
975
|
+
var element = authCommand.login(argv);
|
|
976
|
+
render(element);
|
|
977
|
+
}).command('logout', 'Clear SSH key configuration\n', function(yargsLogout) {
|
|
978
|
+
return yargsLogout.option('project', {
|
|
979
|
+
describe: 'Clear key for current project only',
|
|
980
|
+
type: 'boolean',
|
|
981
|
+
default: false
|
|
982
|
+
}).example('$0 auth logout', 'Clear global key configuration').example('$0 auth logout --project', 'Clear project-specific key');
|
|
983
|
+
}, function(argv) {
|
|
984
|
+
var element = authCommand.logout(argv);
|
|
985
|
+
render(element);
|
|
986
|
+
}).command('list', 'List available SSH keys\n', function() {}, function() {
|
|
987
|
+
var element = authCommand.list();
|
|
988
|
+
render(element);
|
|
989
|
+
}).command('format-jwk-key', 'Convert an SSH public key to JWK format for ROOT_PUBLIC_KEY\n', function(yargsFormatJwkKey) {
|
|
990
|
+
return yargsFormatJwkKey.option('pubkey', {
|
|
991
|
+
describe: 'Path to SSH public key file',
|
|
992
|
+
type: 'string',
|
|
993
|
+
alias: 'p'
|
|
994
|
+
}).example('$0 auth format-jwk-key', 'Interactive public key selection').example('$0 auth format-jwk-key --pubkey ~/.ssh/id_ed25519.pub', 'Convert specific key');
|
|
995
|
+
}, function(argv) {
|
|
996
|
+
var element = authCommand.formatJwkKey(argv);
|
|
997
|
+
render(element);
|
|
998
|
+
}).command('$0', false, function() {}, function() {
|
|
999
|
+
// Default to status when just 'px auth' is run
|
|
1000
|
+
var element = authCommand.status();
|
|
1001
|
+
render(element);
|
|
1002
|
+
});
|
|
1003
|
+
return yargsAuth;
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
867
1006
|
cli = cli.epilogue('For more information, visit https://positronic.sh');
|
|
868
1007
|
return cli;
|
|
869
1008
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
function _define_property(obj, key, value) {
|
|
21
|
+
if (key in obj) {
|
|
22
|
+
Object.defineProperty(obj, key, {
|
|
23
|
+
value: value,
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true
|
|
27
|
+
});
|
|
28
|
+
} else {
|
|
29
|
+
obj[key] = value;
|
|
30
|
+
}
|
|
31
|
+
return obj;
|
|
32
|
+
}
|
|
33
|
+
import React from 'react';
|
|
34
|
+
import { AuthStatus } from '../components/auth-status.js';
|
|
35
|
+
import { AuthLogin } from '../components/auth-login.js';
|
|
36
|
+
import { AuthLogout } from '../components/auth-logout.js';
|
|
37
|
+
import { AuthList } from '../components/auth-list.js';
|
|
38
|
+
import { AuthFormatJwkKey } from '../components/auth-format-jwk-key.js';
|
|
39
|
+
import { ProjectConfigManager } from './project-config-manager.js';
|
|
40
|
+
export var AuthCommand = /*#__PURE__*/ function() {
|
|
41
|
+
"use strict";
|
|
42
|
+
function AuthCommand(configManager) {
|
|
43
|
+
_class_call_check(this, AuthCommand);
|
|
44
|
+
_define_property(this, "configManager", void 0);
|
|
45
|
+
this.configManager = configManager || new ProjectConfigManager();
|
|
46
|
+
}
|
|
47
|
+
_create_class(AuthCommand, [
|
|
48
|
+
{
|
|
49
|
+
/**
|
|
50
|
+
* Handles the 'px auth' or 'px auth status' command.
|
|
51
|
+
* Shows current auth configuration.
|
|
52
|
+
*/ key: "status",
|
|
53
|
+
value: function status() {
|
|
54
|
+
return React.createElement(AuthStatus, {
|
|
55
|
+
configManager: this.configManager
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
/**
|
|
61
|
+
* Handles the 'px auth login' command.
|
|
62
|
+
* Configure SSH key for authentication.
|
|
63
|
+
*/ key: "login",
|
|
64
|
+
value: function login(param) {
|
|
65
|
+
var path = param.path, project = param.project;
|
|
66
|
+
return React.createElement(AuthLogin, {
|
|
67
|
+
configManager: this.configManager,
|
|
68
|
+
keyPath: path,
|
|
69
|
+
forProject: project || false
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
/**
|
|
75
|
+
* Handles the 'px auth logout' command.
|
|
76
|
+
* Clear SSH key configuration.
|
|
77
|
+
*/ key: "logout",
|
|
78
|
+
value: function logout(param) {
|
|
79
|
+
var project = param.project;
|
|
80
|
+
return React.createElement(AuthLogout, {
|
|
81
|
+
configManager: this.configManager,
|
|
82
|
+
forProject: project || false
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
/**
|
|
88
|
+
* Handles the 'px auth list' command.
|
|
89
|
+
* List available SSH keys.
|
|
90
|
+
*/ key: "list",
|
|
91
|
+
value: function list() {
|
|
92
|
+
return React.createElement(AuthList, {
|
|
93
|
+
configManager: this.configManager
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
/**
|
|
99
|
+
* Handles the 'px auth format-jwk-key' command.
|
|
100
|
+
* Convert an SSH public key to JWK format for ROOT_PUBLIC_KEY configuration.
|
|
101
|
+
*/ key: "formatJwkKey",
|
|
102
|
+
value: function formatJwkKey(param) {
|
|
103
|
+
var pubkey = param.pubkey;
|
|
104
|
+
return React.createElement(AuthFormatJwkKey, {
|
|
105
|
+
pubkeyPath: pubkey
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]);
|
|
110
|
+
return AuthCommand;
|
|
111
|
+
}();
|
|
@@ -48,6 +48,13 @@ function _define_property(obj, key, value) {
|
|
|
48
48
|
}
|
|
49
49
|
return obj;
|
|
50
50
|
}
|
|
51
|
+
function _instanceof(left, right) {
|
|
52
|
+
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
53
|
+
return !!right[Symbol.hasInstance](left);
|
|
54
|
+
} else {
|
|
55
|
+
return left instanceof right;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
51
58
|
function _iterable_to_array_limit(arr, i) {
|
|
52
59
|
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
53
60
|
if (_i == null) return;
|
|
@@ -220,13 +227,13 @@ import process from 'process';
|
|
|
220
227
|
import * as fs from 'fs';
|
|
221
228
|
import * as path from 'path';
|
|
222
229
|
import * as os from 'os';
|
|
223
|
-
import caz from 'caz';
|
|
224
230
|
import { isText } from 'istextorbinary';
|
|
225
231
|
import * as http from 'http';
|
|
226
232
|
import * as https from 'https';
|
|
227
233
|
import { URL } from 'url';
|
|
228
234
|
import { createRequire } from 'module';
|
|
229
235
|
import * as dotenv from 'dotenv';
|
|
236
|
+
import { maybeSignRequest } from '../lib/request-signer.js';
|
|
230
237
|
// API client configuration
|
|
231
238
|
var apiBaseUrl = null;
|
|
232
239
|
var isLocalDevMode = true;
|
|
@@ -259,6 +266,51 @@ var isLocalDevMode = true;
|
|
|
259
266
|
// Singleton API client instance
|
|
260
267
|
export var apiClient = {
|
|
261
268
|
fetch: function(apiPath, options) {
|
|
269
|
+
return _async_to_generator(function() {
|
|
270
|
+
var baseUrl, port, fullUrl, requestOptions, method, existingHeaders, headersObj, signatureHeaders;
|
|
271
|
+
return _ts_generator(this, function(_state) {
|
|
272
|
+
if (apiBaseUrl) {
|
|
273
|
+
baseUrl = apiBaseUrl;
|
|
274
|
+
} else {
|
|
275
|
+
// Fallback to localhost (for backwards compatibility and testing)
|
|
276
|
+
port = process.env.POSITRONIC_PORT || '8787';
|
|
277
|
+
baseUrl = "http://localhost:".concat(port);
|
|
278
|
+
}
|
|
279
|
+
fullUrl = "".concat(baseUrl).concat(apiPath.startsWith('/') ? apiPath : '/' + apiPath);
|
|
280
|
+
// Sign requests when not in local dev mode
|
|
281
|
+
requestOptions = options || {};
|
|
282
|
+
if (!isLocalDevMode) {
|
|
283
|
+
method = ((options === null || options === void 0 ? void 0 : options.method) || 'GET').toUpperCase();
|
|
284
|
+
existingHeaders = (options === null || options === void 0 ? void 0 : options.headers) || {};
|
|
285
|
+
headersObj = {};
|
|
286
|
+
// Convert headers to plain object
|
|
287
|
+
if (_instanceof(existingHeaders, Headers)) {
|
|
288
|
+
existingHeaders.forEach(function(value, key) {
|
|
289
|
+
headersObj[key] = value;
|
|
290
|
+
});
|
|
291
|
+
} else if (Array.isArray(existingHeaders)) {
|
|
292
|
+
existingHeaders.forEach(function(param) {
|
|
293
|
+
var _param = _sliced_to_array(param, 2), key = _param[0], value = _param[1];
|
|
294
|
+
headersObj[key] = value;
|
|
295
|
+
});
|
|
296
|
+
} else {
|
|
297
|
+
Object.assign(headersObj, existingHeaders);
|
|
298
|
+
}
|
|
299
|
+
signatureHeaders = maybeSignRequest(method, fullUrl, headersObj);
|
|
300
|
+
requestOptions = _object_spread_props(_object_spread({}, options), {
|
|
301
|
+
headers: _object_spread({}, headersObj, signatureHeaders)
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
return [
|
|
305
|
+
2,
|
|
306
|
+
fetch(fullUrl, requestOptions)
|
|
307
|
+
];
|
|
308
|
+
});
|
|
309
|
+
})();
|
|
310
|
+
},
|
|
311
|
+
/**
|
|
312
|
+
* Fetch without authentication - used for unauthenticated endpoints like /auth/setup
|
|
313
|
+
*/ fetchUnauthenticated: function(apiPath, options) {
|
|
262
314
|
return _async_to_generator(function() {
|
|
263
315
|
var baseUrl, port, fullUrl;
|
|
264
316
|
return _ts_generator(this, function(_state) {
|
|
@@ -270,6 +322,7 @@ export var apiClient = {
|
|
|
270
322
|
baseUrl = "http://localhost:".concat(port);
|
|
271
323
|
}
|
|
272
324
|
fullUrl = "".concat(baseUrl).concat(apiPath.startsWith('/') ? apiPath : '/' + apiPath);
|
|
325
|
+
// Don't sign the request - this is for unauthenticated endpoints
|
|
273
326
|
return [
|
|
274
327
|
2,
|
|
275
328
|
fetch(fullUrl, options)
|
|
@@ -280,7 +333,7 @@ export var apiClient = {
|
|
|
280
333
|
};
|
|
281
334
|
export function generateProject(projectName, projectDir) {
|
|
282
335
|
return _async_to_generator(function() {
|
|
283
|
-
var devPath, newProjectTemplatePath, cazOptions, templateSourcePath, require, templatePackageJsonPath, copiedNewProjectPkg;
|
|
336
|
+
var devPath, newProjectTemplatePath, cazOptions, templateSourcePath, require, templatePackageJsonPath, copiedNewProjectPkg, cazModule, caz;
|
|
284
337
|
return _ts_generator(this, function(_state) {
|
|
285
338
|
switch(_state.label){
|
|
286
339
|
case 0:
|
|
@@ -294,8 +347,8 @@ export function generateProject(projectName, projectDir) {
|
|
|
294
347
|
_state.trys.push([
|
|
295
348
|
1,
|
|
296
349
|
,
|
|
297
|
-
|
|
298
|
-
|
|
350
|
+
4,
|
|
351
|
+
5
|
|
299
352
|
]);
|
|
300
353
|
if (devPath) {
|
|
301
354
|
// Copying templates, why you ask?
|
|
@@ -339,19 +392,26 @@ export function generateProject(projectName, projectDir) {
|
|
|
339
392
|
claudemd: false
|
|
340
393
|
});
|
|
341
394
|
}
|
|
395
|
+
return [
|
|
396
|
+
4,
|
|
397
|
+
import('caz')
|
|
398
|
+
];
|
|
399
|
+
case 2:
|
|
400
|
+
cazModule = _state.sent();
|
|
401
|
+
caz = cazModule.default;
|
|
342
402
|
return [
|
|
343
403
|
4,
|
|
344
404
|
caz.default(newProjectTemplatePath, projectDir, _object_spread_props(_object_spread({}, cazOptions), {
|
|
345
405
|
force: false
|
|
346
406
|
}))
|
|
347
407
|
];
|
|
348
|
-
case
|
|
408
|
+
case 3:
|
|
349
409
|
_state.sent();
|
|
350
410
|
return [
|
|
351
411
|
3,
|
|
352
|
-
|
|
412
|
+
5
|
|
353
413
|
];
|
|
354
|
-
case
|
|
414
|
+
case 4:
|
|
355
415
|
// Clean up the temporary copied new project package
|
|
356
416
|
if (devPath) {
|
|
357
417
|
fs.rmSync(newProjectTemplatePath, {
|
|
@@ -363,7 +423,7 @@ export function generateProject(projectName, projectDir) {
|
|
|
363
423
|
return [
|
|
364
424
|
7
|
|
365
425
|
];
|
|
366
|
-
case
|
|
426
|
+
case 5:
|
|
367
427
|
return [
|
|
368
428
|
2
|
|
369
429
|
];
|
|
@@ -191,6 +191,125 @@ export var ProjectConfigManager = /*#__PURE__*/ function() {
|
|
|
191
191
|
current: config.currentProject
|
|
192
192
|
};
|
|
193
193
|
}
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
/**
|
|
197
|
+
* Get the resolved private key path following the priority order:
|
|
198
|
+
* 1. POSITRONIC_PRIVATE_KEY environment variable (highest)
|
|
199
|
+
* 2. Project-specific privateKeyPath (if project selected and has override)
|
|
200
|
+
* 3. Global defaultPrivateKeyPath from config
|
|
201
|
+
* 4. ~/.ssh/id_rsa fallback (lowest)
|
|
202
|
+
*/ key: "getPrivateKeyPath",
|
|
203
|
+
value: function getPrivateKeyPath() {
|
|
204
|
+
// Priority 1: Environment variable
|
|
205
|
+
if (process.env.POSITRONIC_PRIVATE_KEY) {
|
|
206
|
+
return process.env.POSITRONIC_PRIVATE_KEY;
|
|
207
|
+
}
|
|
208
|
+
var config = this.read();
|
|
209
|
+
// Priority 2: Project-specific key
|
|
210
|
+
if (config.currentProject) {
|
|
211
|
+
var project = config.projects.find(function(p) {
|
|
212
|
+
return p.name === config.currentProject;
|
|
213
|
+
});
|
|
214
|
+
if (project === null || project === void 0 ? void 0 : project.privateKeyPath) {
|
|
215
|
+
return project.privateKeyPath;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// Priority 3: Global default key
|
|
219
|
+
if (config.defaultPrivateKeyPath) {
|
|
220
|
+
return config.defaultPrivateKeyPath;
|
|
221
|
+
}
|
|
222
|
+
// Priority 4: No configured key (return null, let caller use fallback)
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
/**
|
|
228
|
+
* Set the global default private key path
|
|
229
|
+
*/ key: "setDefaultPrivateKeyPath",
|
|
230
|
+
value: function setDefaultPrivateKeyPath(keyPath) {
|
|
231
|
+
var config = this.read();
|
|
232
|
+
config.defaultPrivateKeyPath = keyPath;
|
|
233
|
+
this.write(config);
|
|
234
|
+
return {
|
|
235
|
+
success: true
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
/**
|
|
241
|
+
* Set the private key path for a specific project
|
|
242
|
+
*/ key: "setProjectPrivateKeyPath",
|
|
243
|
+
value: function setProjectPrivateKeyPath(projectName, keyPath) {
|
|
244
|
+
var config = this.read();
|
|
245
|
+
var project = config.projects.find(function(p) {
|
|
246
|
+
return p.name === projectName;
|
|
247
|
+
});
|
|
248
|
+
if (!project) {
|
|
249
|
+
return {
|
|
250
|
+
success: false,
|
|
251
|
+
error: 'Project "'.concat(projectName, '" not found')
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
project.privateKeyPath = keyPath;
|
|
255
|
+
this.write(config);
|
|
256
|
+
return {
|
|
257
|
+
success: true
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
/**
|
|
263
|
+
* Clear the global default private key path
|
|
264
|
+
*/ key: "clearDefaultPrivateKeyPath",
|
|
265
|
+
value: function clearDefaultPrivateKeyPath() {
|
|
266
|
+
var config = this.read();
|
|
267
|
+
delete config.defaultPrivateKeyPath;
|
|
268
|
+
this.write(config);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
/**
|
|
273
|
+
* Clear the private key path for a specific project
|
|
274
|
+
*/ key: "clearProjectPrivateKeyPath",
|
|
275
|
+
value: function clearProjectPrivateKeyPath(projectName) {
|
|
276
|
+
var config = this.read();
|
|
277
|
+
var project = config.projects.find(function(p) {
|
|
278
|
+
return p.name === projectName;
|
|
279
|
+
});
|
|
280
|
+
if (!project) {
|
|
281
|
+
return {
|
|
282
|
+
success: false,
|
|
283
|
+
error: 'Project "'.concat(projectName, '" not found')
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
delete project.privateKeyPath;
|
|
287
|
+
this.write(config);
|
|
288
|
+
return {
|
|
289
|
+
success: true
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
/**
|
|
295
|
+
* Get the default private key path (global config only, no env var or project override)
|
|
296
|
+
*/ key: "getDefaultPrivateKeyPath",
|
|
297
|
+
value: function getDefaultPrivateKeyPath() {
|
|
298
|
+
var config = this.read();
|
|
299
|
+
return config.defaultPrivateKeyPath;
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
/**
|
|
304
|
+
* Get the private key path for a specific project
|
|
305
|
+
*/ key: "getProjectPrivateKeyPath",
|
|
306
|
+
value: function getProjectPrivateKeyPath(projectName) {
|
|
307
|
+
var config = this.read();
|
|
308
|
+
var project = config.projects.find(function(p) {
|
|
309
|
+
return p.name === projectName;
|
|
310
|
+
});
|
|
311
|
+
return project === null || project === void 0 ? void 0 : project.privateKeyPath;
|
|
312
|
+
}
|
|
194
313
|
}
|
|
195
314
|
]);
|
|
196
315
|
return ProjectConfigManager;
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
function _class_call_check(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
function _defineProperties(target, props) {
|
|
7
|
+
for(var i = 0; i < props.length; i++){
|
|
8
|
+
var descriptor = props[i];
|
|
9
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
10
|
+
descriptor.configurable = true;
|
|
11
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
12
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _create_class(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
20
|
+
import React from 'react';
|
|
21
|
+
import { UsersList } from '../components/users-list.js';
|
|
22
|
+
import { UsersCreate } from '../components/users-create.js';
|
|
23
|
+
import { UsersDelete } from '../components/users-delete.js';
|
|
24
|
+
import { UsersKeysList } from '../components/users-keys-list.js';
|
|
25
|
+
import { UsersKeysAdd } from '../components/users-keys-add.js';
|
|
26
|
+
import { UsersKeysRemove } from '../components/users-keys-remove.js';
|
|
27
|
+
export var UsersCommand = /*#__PURE__*/ function() {
|
|
28
|
+
"use strict";
|
|
29
|
+
function UsersCommand() {
|
|
30
|
+
_class_call_check(this, UsersCommand);
|
|
31
|
+
}
|
|
32
|
+
_create_class(UsersCommand, [
|
|
33
|
+
{
|
|
34
|
+
key: "list",
|
|
35
|
+
value: function list() {
|
|
36
|
+
return React.createElement(UsersList);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
key: "create",
|
|
41
|
+
value: function create(param) {
|
|
42
|
+
var name = param.name;
|
|
43
|
+
return React.createElement(UsersCreate, {
|
|
44
|
+
name: name
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
key: "delete",
|
|
50
|
+
value: function _delete(param) {
|
|
51
|
+
var id = param.id, force = param.force;
|
|
52
|
+
return React.createElement(UsersDelete, {
|
|
53
|
+
userId: id,
|
|
54
|
+
force: force
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "keysList",
|
|
60
|
+
value: function keysList(param) {
|
|
61
|
+
var id = param.id;
|
|
62
|
+
return React.createElement(UsersKeysList, {
|
|
63
|
+
userId: id
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
key: "keysAdd",
|
|
69
|
+
value: function keysAdd(param) {
|
|
70
|
+
var id = param.id, pubkeyPath = param.pubkeyPath, label = param.label;
|
|
71
|
+
return React.createElement(UsersKeysAdd, {
|
|
72
|
+
userId: id,
|
|
73
|
+
pubkeyPath: pubkeyPath,
|
|
74
|
+
label: label
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
key: "keysRemove",
|
|
80
|
+
value: function keysRemove(param) {
|
|
81
|
+
var id = param.id, fingerprint = param.fingerprint, force = param.force;
|
|
82
|
+
return React.createElement(UsersKeysRemove, {
|
|
83
|
+
userId: id,
|
|
84
|
+
fingerprint: fingerprint,
|
|
85
|
+
force: force
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]);
|
|
90
|
+
return UsersCommand;
|
|
91
|
+
}();
|