@positronic/cli 0.0.55 → 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 +142 -2
- package/dist/src/commands/auth.js +98 -0
- package/dist/src/commands/brain.js +3 -2
- 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 +379 -0
- 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-resolver.js +3 -2
- package/dist/src/components/watch.js +390 -36
- 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/brain.d.ts +2 -1
- package/dist/types/commands/brain.d.ts.map +1 -1
- 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 +13 -0
- package/dist/types/components/events-view.d.ts.map +1 -0
- 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-resolver.d.ts +2 -1
- package/dist/types/components/watch-resolver.d.ts.map +1 -1
- package/dist/types/components/watch.d.ts +2 -1
- 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) ---
|
|
@@ -451,7 +454,12 @@ export function buildCli(options) {
|
|
|
451
454
|
describe: 'Brain name or run ID to watch',
|
|
452
455
|
type: 'string',
|
|
453
456
|
demandOption: true
|
|
454
|
-
}).
|
|
457
|
+
}).option('events', {
|
|
458
|
+
describe: 'Start in events view instead of progress view',
|
|
459
|
+
type: 'boolean',
|
|
460
|
+
alias: 'e',
|
|
461
|
+
default: false
|
|
462
|
+
}).example('$0 watch my-brain', "Watch the latest run of the brain named 'my-brain'").example('$0 watch abc123def', 'Watch a specific brain run by its ID').example('$0 watch my-brain --events', 'Watch with events log view');
|
|
455
463
|
}, function(argv) {
|
|
456
464
|
var element = brainCommand.watch(argv);
|
|
457
465
|
render(element);
|
|
@@ -548,7 +556,12 @@ export function buildCli(options) {
|
|
|
548
556
|
describe: 'Brain name or run ID to watch',
|
|
549
557
|
type: 'string',
|
|
550
558
|
demandOption: true
|
|
551
|
-
}).
|
|
559
|
+
}).option('events', {
|
|
560
|
+
describe: 'Start in events view instead of progress view',
|
|
561
|
+
type: 'boolean',
|
|
562
|
+
alias: 'e',
|
|
563
|
+
default: false
|
|
564
|
+
}).example('$0 brain watch my-brain', "Watch the latest run of the brain named 'my-brain'").example('$0 brain watch abc123def', 'Watch a specific brain run by its ID').example('$0 brain watch my-brain --events', 'Watch with events log view');
|
|
552
565
|
}, function(argv) {
|
|
553
566
|
var element = brainCommand.watch(argv);
|
|
554
567
|
render(element);
|
|
@@ -854,6 +867,133 @@ export function buildCli(options) {
|
|
|
854
867
|
}).demandCommand(1, 'You need to specify a subcommand');
|
|
855
868
|
return yargsSecret;
|
|
856
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('$0', false, function() {}, function() {
|
|
990
|
+
// Default to status when just 'px auth' is run
|
|
991
|
+
var element = authCommand.status();
|
|
992
|
+
render(element);
|
|
993
|
+
});
|
|
994
|
+
return yargsAuth;
|
|
995
|
+
});
|
|
996
|
+
}
|
|
857
997
|
cli = cli.epilogue('For more information, visit https://positronic.sh');
|
|
858
998
|
return cli;
|
|
859
999
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
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 { ProjectConfigManager } from './project-config-manager.js';
|
|
39
|
+
export var AuthCommand = /*#__PURE__*/ function() {
|
|
40
|
+
"use strict";
|
|
41
|
+
function AuthCommand(configManager) {
|
|
42
|
+
_class_call_check(this, AuthCommand);
|
|
43
|
+
_define_property(this, "configManager", void 0);
|
|
44
|
+
this.configManager = configManager || new ProjectConfigManager();
|
|
45
|
+
}
|
|
46
|
+
_create_class(AuthCommand, [
|
|
47
|
+
{
|
|
48
|
+
/**
|
|
49
|
+
* Handles the 'px auth' or 'px auth status' command.
|
|
50
|
+
* Shows current auth configuration.
|
|
51
|
+
*/ key: "status",
|
|
52
|
+
value: function status() {
|
|
53
|
+
return React.createElement(AuthStatus, {
|
|
54
|
+
configManager: this.configManager
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
/**
|
|
60
|
+
* Handles the 'px auth login' command.
|
|
61
|
+
* Configure SSH key for authentication.
|
|
62
|
+
*/ key: "login",
|
|
63
|
+
value: function login(param) {
|
|
64
|
+
var path = param.path, project = param.project;
|
|
65
|
+
return React.createElement(AuthLogin, {
|
|
66
|
+
configManager: this.configManager,
|
|
67
|
+
keyPath: path,
|
|
68
|
+
forProject: project || false
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
/**
|
|
74
|
+
* Handles the 'px auth logout' command.
|
|
75
|
+
* Clear SSH key configuration.
|
|
76
|
+
*/ key: "logout",
|
|
77
|
+
value: function logout(param) {
|
|
78
|
+
var project = param.project;
|
|
79
|
+
return React.createElement(AuthLogout, {
|
|
80
|
+
configManager: this.configManager,
|
|
81
|
+
forProject: project || false
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
/**
|
|
87
|
+
* Handles the 'px auth list' command.
|
|
88
|
+
* List available SSH keys.
|
|
89
|
+
*/ key: "list",
|
|
90
|
+
value: function list() {
|
|
91
|
+
return React.createElement(AuthList, {
|
|
92
|
+
configManager: this.configManager
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
]);
|
|
97
|
+
return AuthCommand;
|
|
98
|
+
}();
|
|
@@ -114,9 +114,10 @@ export var BrainCommand = /*#__PURE__*/ function() {
|
|
|
114
114
|
{
|
|
115
115
|
key: "watch",
|
|
116
116
|
value: function watch(param) {
|
|
117
|
-
var identifier = param.identifier;
|
|
117
|
+
var identifier = param.identifier, events = param.events;
|
|
118
118
|
return React.createElement(WatchResolver, {
|
|
119
|
-
identifier: identifier
|
|
119
|
+
identifier: identifier,
|
|
120
|
+
startWithEvents: events
|
|
120
121
|
});
|
|
121
122
|
}
|
|
122
123
|
},
|
|
@@ -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;
|
|
@@ -260,7 +267,7 @@ var isLocalDevMode = true;
|
|
|
260
267
|
export var apiClient = {
|
|
261
268
|
fetch: function(apiPath, options) {
|
|
262
269
|
return _async_to_generator(function() {
|
|
263
|
-
var baseUrl, port, fullUrl;
|
|
270
|
+
var baseUrl, port, fullUrl, requestOptions, method, existingHeaders, headersObj, signatureHeaders;
|
|
264
271
|
return _ts_generator(this, function(_state) {
|
|
265
272
|
if (apiBaseUrl) {
|
|
266
273
|
baseUrl = apiBaseUrl;
|
|
@@ -270,9 +277,33 @@ export var apiClient = {
|
|
|
270
277
|
baseUrl = "http://localhost:".concat(port);
|
|
271
278
|
}
|
|
272
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
|
+
}
|
|
273
304
|
return [
|
|
274
305
|
2,
|
|
275
|
-
fetch(fullUrl,
|
|
306
|
+
fetch(fullUrl, requestOptions)
|
|
276
307
|
];
|
|
277
308
|
});
|
|
278
309
|
})();
|
|
@@ -280,7 +311,7 @@ export var apiClient = {
|
|
|
280
311
|
};
|
|
281
312
|
export function generateProject(projectName, projectDir) {
|
|
282
313
|
return _async_to_generator(function() {
|
|
283
|
-
var devPath, newProjectTemplatePath, cazOptions, templateSourcePath, require, templatePackageJsonPath, copiedNewProjectPkg;
|
|
314
|
+
var devPath, newProjectTemplatePath, cazOptions, templateSourcePath, require, templatePackageJsonPath, copiedNewProjectPkg, cazModule, caz;
|
|
284
315
|
return _ts_generator(this, function(_state) {
|
|
285
316
|
switch(_state.label){
|
|
286
317
|
case 0:
|
|
@@ -294,8 +325,8 @@ export function generateProject(projectName, projectDir) {
|
|
|
294
325
|
_state.trys.push([
|
|
295
326
|
1,
|
|
296
327
|
,
|
|
297
|
-
|
|
298
|
-
|
|
328
|
+
4,
|
|
329
|
+
5
|
|
299
330
|
]);
|
|
300
331
|
if (devPath) {
|
|
301
332
|
// Copying templates, why you ask?
|
|
@@ -339,19 +370,26 @@ export function generateProject(projectName, projectDir) {
|
|
|
339
370
|
claudemd: false
|
|
340
371
|
});
|
|
341
372
|
}
|
|
373
|
+
return [
|
|
374
|
+
4,
|
|
375
|
+
import('caz')
|
|
376
|
+
];
|
|
377
|
+
case 2:
|
|
378
|
+
cazModule = _state.sent();
|
|
379
|
+
caz = cazModule.default;
|
|
342
380
|
return [
|
|
343
381
|
4,
|
|
344
382
|
caz.default(newProjectTemplatePath, projectDir, _object_spread_props(_object_spread({}, cazOptions), {
|
|
345
383
|
force: false
|
|
346
384
|
}))
|
|
347
385
|
];
|
|
348
|
-
case
|
|
386
|
+
case 3:
|
|
349
387
|
_state.sent();
|
|
350
388
|
return [
|
|
351
389
|
3,
|
|
352
|
-
|
|
390
|
+
5
|
|
353
391
|
];
|
|
354
|
-
case
|
|
392
|
+
case 4:
|
|
355
393
|
// Clean up the temporary copied new project package
|
|
356
394
|
if (devPath) {
|
|
357
395
|
fs.rmSync(newProjectTemplatePath, {
|
|
@@ -363,7 +401,7 @@ export function generateProject(projectName, projectDir) {
|
|
|
363
401
|
return [
|
|
364
402
|
7
|
|
365
403
|
];
|
|
366
|
-
case
|
|
404
|
+
case 5:
|
|
367
405
|
return [
|
|
368
406
|
2
|
|
369
407
|
];
|
|
@@ -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
|
+
}();
|