@castari/cli 0.1.11 ā 0.2.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 +79 -90
- package/bin/cast.js +2 -0
- package/dist/commands/agents.d.ts +6 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +174 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/apikey.d.ts +6 -0
- package/dist/commands/apikey.d.ts.map +1 -0
- package/dist/commands/apikey.js +57 -0
- package/dist/commands/apikey.js.map +1 -0
- package/dist/commands/deploy.d.ts +3 -3
- package/dist/commands/deploy.d.ts.map +1 -0
- package/dist/commands/deploy.js +24 -64
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/invoke.d.ts +3 -0
- package/dist/commands/invoke.d.ts.map +1 -0
- package/dist/commands/invoke.js +50 -0
- package/dist/commands/invoke.js.map +1 -0
- package/dist/commands/login.d.ts +3 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +123 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +3 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +16 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/secrets.d.ts +6 -0
- package/dist/commands/secrets.d.ts.map +1 -0
- package/dist/commands/secrets.js +90 -0
- package/dist/commands/secrets.js.map +1 -0
- package/dist/commands/stop.d.ts +3 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +25 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/usage.d.ts +3 -0
- package/dist/commands/usage.d.ts.map +1 -0
- package/dist/commands/usage.js +76 -0
- package/dist/commands/usage.js.map +1 -0
- package/dist/commands/whoami.d.ts +3 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +27 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +36 -34
- package/dist/index.js.map +1 -0
- package/dist/utils/errors.d.ts +6 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +42 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/output.d.ts +45 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +75 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +56 -35
- package/LICENSE +0 -21
- package/dist/commands/client-id.d.ts +0 -1
- package/dist/commands/client-id.js +0 -25
- package/dist/commands/dev.d.ts +0 -1
- package/dist/commands/dev.js +0 -17
- package/dist/commands/generate-secrets.d.ts +0 -1
- package/dist/commands/generate-secrets.js +0 -60
- package/dist/commands/init.d.ts +0 -5
- package/dist/commands/init.js +0 -899
- package/dist/commands/start.d.ts +0 -5
- package/dist/commands/start.js +0 -100
- package/dist/utils/client-auth.d.ts +0 -11
- package/dist/utils/client-auth.js +0 -21
- package/dist/utils/client-id.d.ts +0 -10
- package/dist/utils/client-id.js +0 -36
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { CastariError, AuthenticationError, NotFoundError, RateLimitError, ValidationError, BadRequestError, } from '@castari/sdk';
|
|
2
|
+
import { error, hint } from './output.js';
|
|
3
|
+
/**
|
|
4
|
+
* Handle an error and display a user-friendly message
|
|
5
|
+
* Exits the process with code 1
|
|
6
|
+
*/
|
|
7
|
+
export function handleError(err) {
|
|
8
|
+
if (err instanceof AuthenticationError) {
|
|
9
|
+
error('Authentication failed');
|
|
10
|
+
hint("Run 'cast login' to authenticate");
|
|
11
|
+
}
|
|
12
|
+
else if (err instanceof NotFoundError) {
|
|
13
|
+
error(err.message || 'Resource not found');
|
|
14
|
+
hint("Run 'cast agents list' to see your agents");
|
|
15
|
+
}
|
|
16
|
+
else if (err instanceof RateLimitError) {
|
|
17
|
+
error('Rate limit exceeded');
|
|
18
|
+
if (err.retryAfter) {
|
|
19
|
+
hint(`Try again in ${err.retryAfter} seconds`);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
hint('Try again in a few moments');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (err instanceof ValidationError) {
|
|
26
|
+
error(`Validation error: ${err.message}`);
|
|
27
|
+
}
|
|
28
|
+
else if (err instanceof BadRequestError) {
|
|
29
|
+
error(`Bad request: ${err.message}`);
|
|
30
|
+
}
|
|
31
|
+
else if (err instanceof CastariError) {
|
|
32
|
+
error(err.message);
|
|
33
|
+
}
|
|
34
|
+
else if (err instanceof Error) {
|
|
35
|
+
error(err.message);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
error('An unexpected error occurred');
|
|
39
|
+
}
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,eAAe,EACf,eAAe,GAChB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,mBAAmB,EAAE,CAAC;QACvC,KAAK,CAAC,uBAAuB,CAAC,CAAC;QAC/B,IAAI,CAAC,kCAAkC,CAAC,CAAC;IAC3C,CAAC;SAAM,IAAI,GAAG,YAAY,aAAa,EAAE,CAAC;QACxC,KAAK,CAAC,GAAG,CAAC,OAAO,IAAI,oBAAoB,CAAC,CAAC;QAC3C,IAAI,CAAC,2CAA2C,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,GAAG,YAAY,cAAc,EAAE,CAAC;QACzC,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC7B,IAAI,GAAG,CAAC,UAAU,EAAE,CAAC;YACnB,IAAI,CAAC,gBAAgB,GAAG,CAAC,UAAU,UAAU,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,4BAA4B,CAAC,CAAC;QACrC,CAAC;IACH,CAAC;SAAM,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;QAC1C,KAAK,CAAC,qBAAqB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;SAAM,IAAI,GAAG,YAAY,eAAe,EAAE,CAAC;QAC1C,KAAK,CAAC,gBAAgB,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC;IACvC,CAAC;SAAM,IAAI,GAAG,YAAY,YAAY,EAAE,CAAC;QACvC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;SAAM,IAAI,GAAG,YAAY,KAAK,EAAE,CAAC;QAChC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACrB,CAAC;SAAM,CAAC;QACN,KAAK,CAAC,8BAA8B,CAAC,CAAC;IACxC,CAAC;IAED,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Print a success message
|
|
3
|
+
*/
|
|
4
|
+
export declare function success(message: string): void;
|
|
5
|
+
/**
|
|
6
|
+
* Print an info message
|
|
7
|
+
*/
|
|
8
|
+
export declare function info(message: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Print a warning message
|
|
11
|
+
*/
|
|
12
|
+
export declare function warn(message: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Print an error message
|
|
15
|
+
*/
|
|
16
|
+
export declare function error(message: string): void;
|
|
17
|
+
/**
|
|
18
|
+
* Print a hint/suggestion
|
|
19
|
+
*/
|
|
20
|
+
export declare function hint(message: string): void;
|
|
21
|
+
/**
|
|
22
|
+
* Print a blank line
|
|
23
|
+
*/
|
|
24
|
+
export declare function blank(): void;
|
|
25
|
+
/**
|
|
26
|
+
* Print a header
|
|
27
|
+
*/
|
|
28
|
+
export declare function header(title: string): void;
|
|
29
|
+
/**
|
|
30
|
+
* Print a key-value pair
|
|
31
|
+
*/
|
|
32
|
+
export declare function keyValue(key: string, value: string | number | undefined): void;
|
|
33
|
+
/**
|
|
34
|
+
* Format a number with commas
|
|
35
|
+
*/
|
|
36
|
+
export declare function formatNumber(n: number): string;
|
|
37
|
+
/**
|
|
38
|
+
* Format a cost in USD
|
|
39
|
+
*/
|
|
40
|
+
export declare function formatCost(usd: number): string;
|
|
41
|
+
/**
|
|
42
|
+
* Format a date string
|
|
43
|
+
*/
|
|
44
|
+
export declare function formatDate(dateStr: string): string;
|
|
45
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE3C;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAE5B;AAED;;GAEG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE1C;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAE9E;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CASlD"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
/**
|
|
3
|
+
* Print a success message
|
|
4
|
+
*/
|
|
5
|
+
export function success(message) {
|
|
6
|
+
console.log(chalk.green('ā'), message);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Print an info message
|
|
10
|
+
*/
|
|
11
|
+
export function info(message) {
|
|
12
|
+
console.log(chalk.blue('ā¹'), message);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Print a warning message
|
|
16
|
+
*/
|
|
17
|
+
export function warn(message) {
|
|
18
|
+
console.log(chalk.yellow('ā '), message);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Print an error message
|
|
22
|
+
*/
|
|
23
|
+
export function error(message) {
|
|
24
|
+
console.error(chalk.red('ā'), message);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Print a hint/suggestion
|
|
28
|
+
*/
|
|
29
|
+
export function hint(message) {
|
|
30
|
+
console.log(chalk.gray(' ā'), chalk.gray(message));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Print a blank line
|
|
34
|
+
*/
|
|
35
|
+
export function blank() {
|
|
36
|
+
console.log();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Print a header
|
|
40
|
+
*/
|
|
41
|
+
export function header(title) {
|
|
42
|
+
console.log(chalk.bold(title));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Print a key-value pair
|
|
46
|
+
*/
|
|
47
|
+
export function keyValue(key, value) {
|
|
48
|
+
console.log(` ${chalk.gray(key + ':')} ${value ?? chalk.gray('N/A')}`);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Format a number with commas
|
|
52
|
+
*/
|
|
53
|
+
export function formatNumber(n) {
|
|
54
|
+
return n.toLocaleString();
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Format a cost in USD
|
|
58
|
+
*/
|
|
59
|
+
export function formatCost(usd) {
|
|
60
|
+
return `$${usd.toFixed(4)}`;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Format a date string
|
|
64
|
+
*/
|
|
65
|
+
export function formatDate(dateStr) {
|
|
66
|
+
const date = new Date(dateStr);
|
|
67
|
+
return date.toLocaleDateString('en-US', {
|
|
68
|
+
year: 'numeric',
|
|
69
|
+
month: 'short',
|
|
70
|
+
day: 'numeric',
|
|
71
|
+
hour: '2-digit',
|
|
72
|
+
minute: '2-digit',
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/utils/output.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,UAAU,OAAO,CAAC,OAAe;IACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK,CAAC,OAAe;IACnC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;AACtD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,KAAK;IACnB,OAAO,CAAC,GAAG,EAAE,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,KAAkC;IACtE,OAAO,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,cAAc,EAAE,CAAC;AAC5B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAAW;IACpC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;AAC9B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;QACtC,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,OAAO;QACd,GAAG,EAAE,SAAS;QACd,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,37 +1,58 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
2
|
+
"name": "@castari/cli",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Castari CLI - Deploy AI agents with one command",
|
|
5
|
+
"author": "Castari <hello@castari.dev>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/castari/cli.git",
|
|
10
|
+
"directory": "packages/cli"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/castari/cli",
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/castari/cli/issues"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "dist/index.js",
|
|
18
|
+
"types": "dist/index.d.ts",
|
|
19
|
+
"bin": {
|
|
20
|
+
"cast": "./bin/cast.js"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "tsc",
|
|
24
|
+
"test": "vitest run --passWithNoTests",
|
|
25
|
+
"test:watch": "vitest",
|
|
26
|
+
"typecheck": "tsc --noEmit",
|
|
27
|
+
"clean": "rm -rf dist"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@castari/sdk": "workspace:*",
|
|
31
|
+
"chalk": "^5.3.0",
|
|
32
|
+
"cli-table3": "^0.6.0",
|
|
33
|
+
"commander": "^12.0.0",
|
|
34
|
+
"open": "^10.0.0",
|
|
35
|
+
"ora": "^8.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"typescript": "^5.3.0"
|
|
39
|
+
},
|
|
40
|
+
"files": [
|
|
41
|
+
"dist",
|
|
42
|
+
"bin",
|
|
43
|
+
"README.md"
|
|
44
|
+
],
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"keywords": [
|
|
49
|
+
"castari",
|
|
50
|
+
"ai",
|
|
51
|
+
"agents",
|
|
52
|
+
"cli",
|
|
53
|
+
"claude",
|
|
54
|
+
"anthropic",
|
|
55
|
+
"llm",
|
|
56
|
+
"deploy"
|
|
57
|
+
]
|
|
37
58
|
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Castari
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function resolveClientId(): Promise<string>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'fs/promises';
|
|
2
|
-
import { existsSync } from 'fs';
|
|
3
|
-
import { join } from 'path';
|
|
4
|
-
import { homedir } from 'os';
|
|
5
|
-
import chalk from 'chalk';
|
|
6
|
-
const CONFIG_PATH = join(homedir(), '.castari', 'client.json');
|
|
7
|
-
export async function resolveClientId() {
|
|
8
|
-
const envId = process.env.CASTARI_CLIENT_ID;
|
|
9
|
-
if (envId)
|
|
10
|
-
return envId.trim();
|
|
11
|
-
if (existsSync(CONFIG_PATH)) {
|
|
12
|
-
try {
|
|
13
|
-
const raw = await readFile(CONFIG_PATH, 'utf-8');
|
|
14
|
-
const data = JSON.parse(raw);
|
|
15
|
-
if (data.clientId)
|
|
16
|
-
return data.clientId.trim();
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
// ignore and fall through
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
console.error(chalk.red('ā CASTARI_CLIENT_ID is required.'));
|
|
23
|
-
console.error(chalk.white('Run `castari generate-secrets` to create one, or set CASTARI_CLIENT_ID in your environment.'));
|
|
24
|
-
throw new Error('Missing CASTARI_CLIENT_ID');
|
|
25
|
-
}
|
package/dist/commands/dev.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function dev(): Promise<void>;
|
package/dist/commands/dev.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { pathToFileURL } from 'url';
|
|
2
|
-
import { join } from 'path';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
export async function dev() {
|
|
5
|
-
console.log(chalk.blue('š ļø Starting local development server...'));
|
|
6
|
-
try {
|
|
7
|
-
const agentPath = join(process.cwd(), 'src', 'agent.ts');
|
|
8
|
-
// Dynamic import of the agent file.
|
|
9
|
-
// Since the agent file calls `serve()`, this will start the server.
|
|
10
|
-
await import(pathToFileURL(agentPath).href);
|
|
11
|
-
}
|
|
12
|
-
catch (err) {
|
|
13
|
-
console.error(chalk.red('Failed to start local agent:'), err.message || err);
|
|
14
|
-
console.log(chalk.white('Make sure src/agent.ts exists and exports/calls serve().'));
|
|
15
|
-
process.exit(1);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function generateSecrets(): Promise<void>;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'crypto';
|
|
2
|
-
import inquirer from 'inquirer';
|
|
3
|
-
import chalk from 'chalk';
|
|
4
|
-
import { saveClientAuth } from '../utils/client-auth';
|
|
5
|
-
export async function generateSecrets() {
|
|
6
|
-
const platformUrl = process.env.CASTARI_PLATFORM_URL || 'https://castari-api-12511-04c55b73-g4p2s9om.onporter.run';
|
|
7
|
-
const mintOnline = async () => {
|
|
8
|
-
try {
|
|
9
|
-
const res = await fetch(`${platformUrl}/client-ids`, { method: 'POST' });
|
|
10
|
-
if (!res.ok) {
|
|
11
|
-
const text = await res.text();
|
|
12
|
-
throw new Error(text || `status ${res.status}`);
|
|
13
|
-
}
|
|
14
|
-
const data = (await res.json());
|
|
15
|
-
if (!data.clientId)
|
|
16
|
-
throw new Error('No clientId returned');
|
|
17
|
-
await saveClientAuth({
|
|
18
|
-
clientId: data.clientId,
|
|
19
|
-
apiKey: data.apiKey,
|
|
20
|
-
source: 'online',
|
|
21
|
-
platformUrl,
|
|
22
|
-
});
|
|
23
|
-
console.log(chalk.green(`\nā
Secrets generated!\n`));
|
|
24
|
-
console.log(chalk.white(`CASTARI_CLIENT_ID=${data.clientId}`));
|
|
25
|
-
if (data.apiKey) {
|
|
26
|
-
console.log(chalk.white(`CASTARI_API_KEY=${data.apiKey}`));
|
|
27
|
-
}
|
|
28
|
-
console.log(chalk.gray(`\nSaved to ~/.castari/client.json`));
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
console.error(chalk.yellow(`ā ļø Failed to mint via platform: ${err?.message || err}`));
|
|
33
|
-
return false;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const success = await mintOnline();
|
|
37
|
-
if (success)
|
|
38
|
-
return;
|
|
39
|
-
const { confirmOffline } = await inquirer.prompt([
|
|
40
|
-
{
|
|
41
|
-
type: 'confirm',
|
|
42
|
-
name: 'confirmOffline',
|
|
43
|
-
message: 'Generate an offline client ID instead? (no API key)',
|
|
44
|
-
default: false,
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
|
-
if (!confirmOffline) {
|
|
48
|
-
console.error(chalk.red('Aborted. No secrets generated.'));
|
|
49
|
-
process.exit(1);
|
|
50
|
-
}
|
|
51
|
-
const offlineId = randomUUID();
|
|
52
|
-
await saveClientAuth({
|
|
53
|
-
clientId: offlineId,
|
|
54
|
-
source: 'offline',
|
|
55
|
-
});
|
|
56
|
-
console.log(chalk.green(`\nā
Offline client ID generated!\n`));
|
|
57
|
-
console.log(chalk.white(`CASTARI_CLIENT_ID=${offlineId}`));
|
|
58
|
-
console.log(chalk.yellow(`\nNote: No API key generated in offline mode.`));
|
|
59
|
-
console.log(chalk.gray(`Saved to ~/.castari/client.json`));
|
|
60
|
-
}
|