@superpanel-sdk/cli 0.0.0-stage → 0.1.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 +16 -2
- package/bin/superpanel.mjs +23 -0
- package/dist/api/platform.d.ts +31 -0
- package/dist/api/platform.js +39 -0
- package/dist/auth/auth.d.ts +162 -0
- package/dist/auth/auth.js +923 -0
- package/dist/auth/backend-url.d.ts +7 -0
- package/dist/auth/backend-url.js +41 -0
- package/dist/auth/cli-login.d.ts +8 -0
- package/dist/auth/cli-login.js +92 -0
- package/dist/auth/clipboard.d.ts +8 -0
- package/dist/auth/clipboard.js +42 -0
- package/dist/auth/file-lock.d.ts +25 -0
- package/dist/auth/file-lock.js +173 -0
- package/dist/auth/http.d.ts +34 -0
- package/dist/auth/http.js +48 -0
- package/dist/auth/index.d.ts +13 -0
- package/dist/auth/index.js +117 -0
- package/dist/auth/origin-guard.d.ts +4 -0
- package/dist/auth/origin-guard.js +9 -0
- package/dist/auth/origin.d.ts +17 -0
- package/dist/auth/origin.js +142 -0
- package/dist/auth/pending-login.d.ts +5 -0
- package/dist/auth/pending-login.js +67 -0
- package/dist/commands/auth-token.d.ts +26 -0
- package/dist/commands/auth-token.js +71 -0
- package/dist/commands/git-method.d.ts +54 -0
- package/dist/commands/git-method.js +180 -0
- package/dist/commands/setup.d.ts +88 -0
- package/dist/commands/setup.js +366 -0
- package/dist/commands/skill.d.ts +29 -0
- package/dist/commands/skill.js +169 -0
- package/dist/commands/ssh-key.d.ts +13 -0
- package/dist/commands/ssh-key.js +83 -0
- package/dist/git/credential.d.ts +7 -0
- package/dist/git/credential.js +66 -0
- package/dist/git/index.d.ts +36 -0
- package/dist/git/index.js +119 -0
- package/dist/git/run.d.ts +13 -0
- package/dist/git/run.js +32 -0
- package/dist/git/setup.d.ts +97 -0
- package/dist/git/setup.js +471 -0
- package/dist/handover/clone.d.ts +8 -0
- package/dist/handover/clone.js +39 -0
- package/dist/handover/repo-help.d.ts +7 -0
- package/dist/handover/repo-help.js +55 -0
- package/dist/handover/run.d.ts +5 -0
- package/dist/handover/run.js +67 -0
- package/dist/inbound/index.d.ts +44 -0
- package/dist/inbound/index.js +129 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +251 -0
- package/dist/logs/index.d.ts +19 -0
- package/dist/logs/index.js +132 -0
- package/dist/npm-launch.d.ts +19 -0
- package/dist/npm-launch.js +80 -0
- package/dist/ops/agent.d.ts +3 -0
- package/dist/ops/agent.js +14 -0
- package/dist/ops/cache.d.ts +18 -0
- package/dist/ops/cache.js +92 -0
- package/dist/ops/parse.d.ts +6 -0
- package/dist/ops/parse.js +106 -0
- package/dist/ops/register.d.ts +18 -0
- package/dist/ops/register.js +174 -0
- package/dist/ops/run.d.ts +20 -0
- package/dist/ops/run.js +127 -0
- package/dist/ops/types.d.ts +41 -0
- package/dist/ops/types.js +16 -0
- package/dist/protocol.d.ts +4 -0
- package/dist/protocol.js +17 -0
- package/dist/reserved.d.ts +4 -0
- package/dist/reserved.js +25 -0
- package/dist/turns/index.d.ts +20 -0
- package/dist/turns/index.js +108 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +11 -0
- package/package.json +48 -4
- package/skill/SKILL.md +17 -0
package/README.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @superpanel-sdk/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `superpanel` command: login, setup, git, logs, inbound, turns, and the account commands.
|
|
4
|
+
Company-repo commands (`serve`, `compile`, `type:gen`, `exec`, `brief`) are handed to the
|
|
5
|
+
`@superpanel-sdk/runtime` installed in that repository.
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g @superpanel-sdk/cli@latest && superpanel setup --url <backend> --company <slug>
|
|
9
|
+
superpanel login
|
|
10
|
+
superpanel whoami
|
|
11
|
+
superpanel setup-git
|
|
12
|
+
superpanel logs
|
|
13
|
+
superpanel inbound
|
|
14
|
+
superpanel turns
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Node.js 22 or newer. Do not run `npx superpanel`: that name on npm is a different package.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { existsSync } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
|
|
7
|
+
// This process is the CLI. Spawning a child would keep the lifetime pipe open after this process is killed.
|
|
8
|
+
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
9
|
+
const packageRoot = path.join(here, '..');
|
|
10
|
+
const dist = path.join(packageRoot, 'dist', 'index.js');
|
|
11
|
+
const source = path.join(packageRoot, 'src', 'index.ts');
|
|
12
|
+
|
|
13
|
+
if (existsSync(dist)) {
|
|
14
|
+
await import(pathToFileURL(dist).href);
|
|
15
|
+
} else if (existsSync(source)) {
|
|
16
|
+
const requireFromPackage = createRequire(path.join(packageRoot, 'package.json'));
|
|
17
|
+
const api = pathToFileURL(requireFromPackage.resolve('tsx/esm/api')).href;
|
|
18
|
+
const { tsImport } = await import(api);
|
|
19
|
+
await tsImport(pathToFileURL(source).href, import.meta.url);
|
|
20
|
+
} else {
|
|
21
|
+
console.error('@superpanel-sdk/cli has no dist/index.js. Reinstall the package.');
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export type GitAccount = {
|
|
2
|
+
username: string;
|
|
3
|
+
email: string;
|
|
4
|
+
webUrl: string | null;
|
|
5
|
+
httpsCloneUrl: string | null;
|
|
6
|
+
sshCloneUrl: string | null;
|
|
7
|
+
sshHost: string | null;
|
|
8
|
+
sshPort: number | null;
|
|
9
|
+
};
|
|
10
|
+
export type SshKey = {
|
|
11
|
+
id: number;
|
|
12
|
+
title: string;
|
|
13
|
+
fingerprint: string;
|
|
14
|
+
createdAt: string;
|
|
15
|
+
};
|
|
16
|
+
export declare class PlatformApiError extends Error {
|
|
17
|
+
readonly status: number;
|
|
18
|
+
constructor(message: string, status: number);
|
|
19
|
+
}
|
|
20
|
+
export declare function getGitAccount(backendUrl: string, token: string, options?: {
|
|
21
|
+
cliVersion?: boolean;
|
|
22
|
+
}): Promise<GitAccount | null>;
|
|
23
|
+
export declare function listSshKeys(backendUrl: string, token: string): Promise<SshKey[]>;
|
|
24
|
+
export declare function addSshKey(backendUrl: string, token: string, input: {
|
|
25
|
+
title: string;
|
|
26
|
+
publicKey: string;
|
|
27
|
+
}): Promise<{
|
|
28
|
+
key: SshKey;
|
|
29
|
+
created: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { CliLoginRejectedError } from '../auth/auth.js';
|
|
2
|
+
import { apiUrl, sendJson } from '../auth/http.js';
|
|
3
|
+
export class PlatformApiError extends Error {
|
|
4
|
+
status;
|
|
5
|
+
constructor(message, status) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.status = status;
|
|
8
|
+
this.name = 'PlatformApiError';
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function call(method, backendUrl, token, path, body, options) {
|
|
12
|
+
const { response, payload } = await sendJson(method, apiUrl(backendUrl, path), token, body, options);
|
|
13
|
+
if (response.status === 401)
|
|
14
|
+
throw new CliLoginRejectedError(payload.error ?? 'CLI login rejected');
|
|
15
|
+
if (!response.ok) {
|
|
16
|
+
throw new PlatformApiError(payload.error ?? `${method} /api/${path} failed (${response.status})`, response.status);
|
|
17
|
+
}
|
|
18
|
+
return payload;
|
|
19
|
+
}
|
|
20
|
+
export async function getGitAccount(backendUrl, token, options) {
|
|
21
|
+
const payload = await call('GET', backendUrl, token, 'me/gitea', undefined, options);
|
|
22
|
+
if (!payload.bound || !payload.username)
|
|
23
|
+
return null;
|
|
24
|
+
return {
|
|
25
|
+
username: payload.username,
|
|
26
|
+
email: payload.email ?? '',
|
|
27
|
+
webUrl: payload.webUrl ?? null,
|
|
28
|
+
httpsCloneUrl: payload.httpsCloneUrl ?? null,
|
|
29
|
+
sshCloneUrl: payload.sshCloneUrl ?? null,
|
|
30
|
+
sshHost: payload.sshHost ?? null,
|
|
31
|
+
sshPort: payload.sshPort ?? null,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export async function listSshKeys(backendUrl, token) {
|
|
35
|
+
return (await call('GET', backendUrl, token, 'me/gitea/ssh-keys')).keys;
|
|
36
|
+
}
|
|
37
|
+
export async function addSshKey(backendUrl, token, input) {
|
|
38
|
+
return call('POST', backendUrl, token, 'me/gitea/ssh-keys', input);
|
|
39
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { backendCacheKey } from './backend-url.js';
|
|
2
|
+
export declare const CLI_CLIENT_ID = "superpanel-cli";
|
|
3
|
+
export declare const LOGIN_SAVE_WAIT_MS: number;
|
|
4
|
+
export type CliAuthorization = {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
accessTokenExpiresAt: number;
|
|
7
|
+
refreshToken: string;
|
|
8
|
+
user: {
|
|
9
|
+
id: string;
|
|
10
|
+
email: string;
|
|
11
|
+
};
|
|
12
|
+
companyId: string;
|
|
13
|
+
companyName: string | null;
|
|
14
|
+
connectedAt?: number;
|
|
15
|
+
deviceName?: string;
|
|
16
|
+
logoutId?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class LoginCancelledError extends Error {
|
|
19
|
+
constructor();
|
|
20
|
+
}
|
|
21
|
+
export declare class CliVersionRejectedError extends Error {
|
|
22
|
+
}
|
|
23
|
+
export declare class CliLoginRejectedError extends Error {
|
|
24
|
+
constructor(message: string);
|
|
25
|
+
}
|
|
26
|
+
export type BackendSource = '--url' | 'SUPERPANEL_SDK_BACKEND_URL' | '.superpanel/config.json' | 'default';
|
|
27
|
+
export declare const BACKEND_CONFIG_FILE = ".superpanel/config.json";
|
|
28
|
+
export declare function backendConfigPath(dir: string): string;
|
|
29
|
+
export declare function parseBackendConfig(text: string): {
|
|
30
|
+
config: Record<string, unknown>;
|
|
31
|
+
backendUrl?: string;
|
|
32
|
+
};
|
|
33
|
+
export declare function writeBackendConfig(config: Record<string, unknown> | null, url: string | null): string | null;
|
|
34
|
+
export declare function loadBackendFromConfig(dir?: string, warn?: (line: string) => void): void;
|
|
35
|
+
export declare function resolveBackend(optionUrl?: string): {
|
|
36
|
+
url: string;
|
|
37
|
+
source: BackendSource;
|
|
38
|
+
};
|
|
39
|
+
export declare function shellBackendUrl(): string | undefined;
|
|
40
|
+
export declare function resolveBackendUrl(optionUrl?: string): string;
|
|
41
|
+
export declare function announceBackend(backend: {
|
|
42
|
+
url: string;
|
|
43
|
+
source: BackendSource;
|
|
44
|
+
}, say?: (line: string) => void): void;
|
|
45
|
+
export declare function cliCommand(command: string, backendUrl: string): string;
|
|
46
|
+
export declare function loginCommand(backendUrl: string): string;
|
|
47
|
+
export { backendCacheKey };
|
|
48
|
+
export declare function authorizationCachePath(): string;
|
|
49
|
+
export declare function withCacheLock<T>(file: string, run: (held: () => Promise<boolean>) => Promise<T>, waitMs?: number): Promise<T>;
|
|
50
|
+
export declare function loginMarkPath(backendUrl: string, file?: string): string;
|
|
51
|
+
export declare function withLoginMark<T>(backendUrl: string, run: (waited: boolean) => Promise<T>, options?: {
|
|
52
|
+
say?: (line: string) => void;
|
|
53
|
+
file?: string;
|
|
54
|
+
}): Promise<T>;
|
|
55
|
+
export declare function readLoginEpoch(backendUrl: string, file?: string): Promise<number>;
|
|
56
|
+
export declare function beginLogout(backendUrl: string, file?: string): Promise<{
|
|
57
|
+
epoch: number;
|
|
58
|
+
authorization: CliAuthorization | undefined;
|
|
59
|
+
}>;
|
|
60
|
+
export declare function loginStillCurrent(backendUrl: string, epoch: number, file?: string): Promise<boolean>;
|
|
61
|
+
export declare function cacheCliAuthorization(backendUrl: string, authorization: CliAuthorization, file?: string, options?: {
|
|
62
|
+
waitMs?: number;
|
|
63
|
+
epoch?: number;
|
|
64
|
+
}): Promise<void>;
|
|
65
|
+
export declare function removeCachedCliAuthorization(backendUrl: string, options?: {
|
|
66
|
+
refreshToken?: string;
|
|
67
|
+
logoutId?: string;
|
|
68
|
+
waitMs?: number;
|
|
69
|
+
}, file?: string): Promise<boolean>;
|
|
70
|
+
export type CliAuthorizationStatus = {
|
|
71
|
+
loggedIn: false;
|
|
72
|
+
} | {
|
|
73
|
+
loggedIn: true;
|
|
74
|
+
authorization: CliAuthorization;
|
|
75
|
+
};
|
|
76
|
+
export declare function readCliAuthorizationStatus(backendUrl: string, file?: string): Promise<CliAuthorizationStatus>;
|
|
77
|
+
type ServerMetadata = {
|
|
78
|
+
issuer: string;
|
|
79
|
+
device_authorization_endpoint: string;
|
|
80
|
+
token_endpoint: string;
|
|
81
|
+
revocation_endpoint: string;
|
|
82
|
+
};
|
|
83
|
+
export declare function discoverOAuthServer(backendUrl: string): Promise<ServerMetadata>;
|
|
84
|
+
export declare class OAuthRequestError extends Error {
|
|
85
|
+
readonly code: string | undefined;
|
|
86
|
+
readonly status: number;
|
|
87
|
+
constructor(code: string | undefined, message: string, status: number);
|
|
88
|
+
}
|
|
89
|
+
export declare function printable(text: string): string;
|
|
90
|
+
export declare function revokeCliLogin(backendUrl: string, authorization: Pick<CliAuthorization, 'refreshToken'>): Promise<void>;
|
|
91
|
+
export declare function getValidCliAuthorization(backendUrl: string, file?: string): Promise<CliAuthorization | null>;
|
|
92
|
+
export declare function withCliLogin<T>(backendUrl: string, call: (authorization: CliAuthorization) => Promise<T>, file?: string): Promise<T>;
|
|
93
|
+
export declare function requestCliIdentity(backendUrl: string, accessToken: string, options?: {
|
|
94
|
+
cliVersion?: boolean;
|
|
95
|
+
}): Promise<{
|
|
96
|
+
response: Response;
|
|
97
|
+
payload: {
|
|
98
|
+
user?: {
|
|
99
|
+
id: string;
|
|
100
|
+
email: string;
|
|
101
|
+
companyId: string | null;
|
|
102
|
+
companyName: string | null;
|
|
103
|
+
companyDisplayName: string | null;
|
|
104
|
+
role?: string;
|
|
105
|
+
};
|
|
106
|
+
} & {
|
|
107
|
+
error?: string;
|
|
108
|
+
};
|
|
109
|
+
}>;
|
|
110
|
+
export declare function fetchCliIdentity(backendUrl: string, accessToken: string, options?: {
|
|
111
|
+
cliVersion?: boolean;
|
|
112
|
+
}): Promise<Pick<CliAuthorization, 'user' | 'companyId' | 'companyName'>>;
|
|
113
|
+
export declare function backendAcceptsCliLogin(backendUrl: string, accessToken: string): Promise<boolean>;
|
|
114
|
+
export type ServeEnvironment = {
|
|
115
|
+
id: string;
|
|
116
|
+
name: string;
|
|
117
|
+
};
|
|
118
|
+
export declare function listServeEnvironments(backendUrl: string, accessToken: string): Promise<ServeEnvironment[]>;
|
|
119
|
+
export declare function isRemoteSession(environment?: NodeJS.ProcessEnv): boolean;
|
|
120
|
+
export type AuthorizeCliOptions = {
|
|
121
|
+
openBrowser?: boolean;
|
|
122
|
+
remote?: boolean;
|
|
123
|
+
say?: (line: string) => void;
|
|
124
|
+
open?: (url: string) => void;
|
|
125
|
+
deviceName?: string;
|
|
126
|
+
pollTiming?: {
|
|
127
|
+
floorMs?: number;
|
|
128
|
+
slowDownMs?: number;
|
|
129
|
+
maxWaitMs?: number;
|
|
130
|
+
};
|
|
131
|
+
resume?: DeviceLogin;
|
|
132
|
+
onStarted?: (login: DeviceLogin) => void | Promise<void>;
|
|
133
|
+
epoch?: number;
|
|
134
|
+
};
|
|
135
|
+
export declare function neverSent(error: unknown): boolean;
|
|
136
|
+
export declare function cliDeviceName(): string;
|
|
137
|
+
export declare function timeOf(at: Date): string;
|
|
138
|
+
export declare function loginLeftOnBackend(backendUrl: string, what: string, error: unknown, deviceName?: string, madeAt?: Date | {
|
|
139
|
+
from: Date;
|
|
140
|
+
to: Date;
|
|
141
|
+
}): Error;
|
|
142
|
+
export declare function loginNotFinished(backendUrl: string, what: string, error: unknown): Error;
|
|
143
|
+
export type DeviceLogin = {
|
|
144
|
+
nextPollAt?: number;
|
|
145
|
+
unconfirmedExchange?: {
|
|
146
|
+
from: number;
|
|
147
|
+
to: number;
|
|
148
|
+
};
|
|
149
|
+
deviceCode: string;
|
|
150
|
+
userCode: string;
|
|
151
|
+
link: string;
|
|
152
|
+
intervalMs: number;
|
|
153
|
+
expiresAt: number;
|
|
154
|
+
};
|
|
155
|
+
export declare class UnconfirmedExchangeError extends Error {
|
|
156
|
+
}
|
|
157
|
+
export declare class AuthorizationPendingError extends Error {
|
|
158
|
+
readonly reason: 'authorization_pending';
|
|
159
|
+
constructor(backendUrl: string);
|
|
160
|
+
}
|
|
161
|
+
export declare function authorizeCli(backendUrl: string, options?: AuthorizeCliOptions): Promise<CliAuthorization>;
|
|
162
|
+
//# sourceMappingURL=auth.d.ts.map
|