@castari/cli 0.1.11 → 0.2.0

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.
Files changed (70) hide show
  1. package/bin/cast.js +2 -0
  2. package/dist/commands/agents.d.ts +6 -0
  3. package/dist/commands/agents.d.ts.map +1 -0
  4. package/dist/commands/agents.js +174 -0
  5. package/dist/commands/agents.js.map +1 -0
  6. package/dist/commands/apikey.d.ts +6 -0
  7. package/dist/commands/apikey.d.ts.map +1 -0
  8. package/dist/commands/apikey.js +57 -0
  9. package/dist/commands/apikey.js.map +1 -0
  10. package/dist/commands/deploy.d.ts +3 -3
  11. package/dist/commands/deploy.d.ts.map +1 -0
  12. package/dist/commands/deploy.js +24 -64
  13. package/dist/commands/deploy.js.map +1 -0
  14. package/dist/commands/invoke.d.ts +3 -0
  15. package/dist/commands/invoke.d.ts.map +1 -0
  16. package/dist/commands/invoke.js +50 -0
  17. package/dist/commands/invoke.js.map +1 -0
  18. package/dist/commands/login.d.ts +3 -0
  19. package/dist/commands/login.d.ts.map +1 -0
  20. package/dist/commands/login.js +123 -0
  21. package/dist/commands/login.js.map +1 -0
  22. package/dist/commands/logout.d.ts +3 -0
  23. package/dist/commands/logout.d.ts.map +1 -0
  24. package/dist/commands/logout.js +16 -0
  25. package/dist/commands/logout.js.map +1 -0
  26. package/dist/commands/secrets.d.ts +6 -0
  27. package/dist/commands/secrets.d.ts.map +1 -0
  28. package/dist/commands/secrets.js +90 -0
  29. package/dist/commands/secrets.js.map +1 -0
  30. package/dist/commands/stop.d.ts +3 -0
  31. package/dist/commands/stop.d.ts.map +1 -0
  32. package/dist/commands/stop.js +25 -0
  33. package/dist/commands/stop.js.map +1 -0
  34. package/dist/commands/usage.d.ts +3 -0
  35. package/dist/commands/usage.d.ts.map +1 -0
  36. package/dist/commands/usage.js +76 -0
  37. package/dist/commands/usage.js.map +1 -0
  38. package/dist/commands/whoami.d.ts +3 -0
  39. package/dist/commands/whoami.d.ts.map +1 -0
  40. package/dist/commands/whoami.js +27 -0
  41. package/dist/commands/whoami.js.map +1 -0
  42. package/dist/index.d.ts +2 -1
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +36 -34
  45. package/dist/index.js.map +1 -0
  46. package/dist/utils/errors.d.ts +6 -0
  47. package/dist/utils/errors.d.ts.map +1 -0
  48. package/dist/utils/errors.js +42 -0
  49. package/dist/utils/errors.js.map +1 -0
  50. package/dist/utils/output.d.ts +45 -0
  51. package/dist/utils/output.d.ts.map +1 -0
  52. package/dist/utils/output.js +75 -0
  53. package/dist/utils/output.js.map +1 -0
  54. package/package.json +55 -35
  55. package/LICENSE +0 -21
  56. package/README.md +0 -151
  57. package/dist/commands/client-id.d.ts +0 -1
  58. package/dist/commands/client-id.js +0 -25
  59. package/dist/commands/dev.d.ts +0 -1
  60. package/dist/commands/dev.js +0 -17
  61. package/dist/commands/generate-secrets.d.ts +0 -1
  62. package/dist/commands/generate-secrets.js +0 -60
  63. package/dist/commands/init.d.ts +0 -5
  64. package/dist/commands/init.js +0 -899
  65. package/dist/commands/start.d.ts +0 -5
  66. package/dist/commands/start.js +0 -100
  67. package/dist/utils/client-auth.d.ts +0 -11
  68. package/dist/utils/client-auth.js +0 -21
  69. package/dist/utils/client-id.d.ts +0 -10
  70. package/dist/utils/client-id.js +0 -36
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.
package/README.md DELETED
@@ -1,151 +0,0 @@
1
- # @castari/cli
2
-
3
- The command line interface for building and deploying Castari agents.
4
-
5
- ## Installation
6
-
7
- ```bash
8
- npm install -g @castari/cli
9
- # or
10
- bun add -g @castari/cli
11
- ```
12
-
13
- ## Quick Start
14
-
15
- ```bash
16
- # Create a new agent project
17
- castari init
18
-
19
- # Run locally for development
20
- castari dev
21
-
22
- # Deploy to Castari Platform
23
- castari deploy
24
-
25
- # Start a cloud sandbox and connect
26
- castari start
27
- ```
28
-
29
- ## Commands
30
-
31
- ### `castari init`
32
-
33
- Scaffolds a new Castari agent project.
34
-
35
- ```bash
36
- castari init # Basic agent scaffold
37
- castari init --demo # Full demo with agent + Next.js chat UI
38
- ```
39
-
40
- **Creates:**
41
- - `package.json` - Configured with dependencies
42
- - `tsconfig.json` - TypeScript configuration
43
- - `src/agent.ts` - Starter agent code
44
- - `.env.example` - Environment variable template
45
-
46
- The `--demo` option creates a complete working example with:
47
- - A sample agent with custom tools
48
- - A Next.js chat interface
49
- - Real-time streaming responses
50
-
51
- ### `castari dev`
52
-
53
- Runs the agent locally for development.
54
-
55
- ```bash
56
- castari dev
57
- ```
58
-
59
- Starts a local server at `http://localhost:3000`. Connect to it using the SDK's `CastariClient` with `connectionUrl: 'http://localhost:3000'`.
60
-
61
- ### `castari deploy`
62
-
63
- Uploads your agent to the Castari Platform and creates a snapshot.
64
-
65
- ```bash
66
- castari deploy
67
- castari deploy --name my-custom-name
68
- ```
69
-
70
- **Options:**
71
- - `--name <name>` - Override the snapshot name (defaults to package.json name)
72
-
73
- **Requires:** `CASTARI_CLIENT_ID` and `CASTARI_API_KEY` environment variables
74
-
75
- After deploying, your snapshot is available to start via `castari start` or the SDK.
76
-
77
- ### `castari start`
78
-
79
- Starts a cloud sandbox running your agent and connects interactively.
80
-
81
- ```bash
82
- castari start
83
- castari start --snapshot my-agent
84
- castari start --snapshot my-agent --volume my-data
85
- ```
86
-
87
- **Options:**
88
- - `--snapshot <name>` - Snapshot to use (defaults to package.json name)
89
- - `--volume <name>` - Volume to mount for persistent storage
90
-
91
- **Requires:** `CASTARI_CLIENT_ID`, `CASTARI_API_KEY`, and `ANTHROPIC_API_KEY` environment variables
92
-
93
- Press `Ctrl+C` to gracefully shut down.
94
-
95
- ### `castari generate-secrets`
96
-
97
- Generates Castari credentials (client ID and API key) and stores them in `~/.castari/client.json`.
98
-
99
- ```bash
100
- castari generate-secrets
101
- ```
102
-
103
- Outputs both values so you can copy them to your `.env` file:
104
-
105
- ```
106
- CASTARI_CLIENT_ID=your-client-id
107
- CASTARI_API_KEY=castari_your-api-key
108
- ```
109
-
110
- ## Configuration
111
-
112
- ### Environment Variables
113
-
114
- Create a `.env` file in your project:
115
-
116
- ```env
117
- ANTHROPIC_API_KEY=sk-ant-...
118
- CASTARI_CLIENT_ID=your-client-id
119
- CASTARI_API_KEY=castari_your-api-key
120
- ```
121
-
122
- ### package.json
123
-
124
- Configure Castari settings in your package.json:
125
-
126
- ```json
127
- {
128
- "name": "my-agent",
129
- "castari": {
130
- "volume": "my-volume-name"
131
- }
132
- }
133
- ```
134
-
135
- ## Workflow
136
-
137
- 1. **Initialize** - `castari init` to scaffold a new project
138
- 2. **Develop** - `castari dev` to run locally and test
139
- 3. **Deploy** - `castari deploy` to upload to the platform
140
- 4. **Run** - `castari start` to launch in a cloud sandbox
141
-
142
- For production applications, use the `@castari/sdk` client to connect programmatically.
143
-
144
- ## Prerequisites
145
-
146
- - [Bun](https://bun.sh) v1.0+
147
- - [Anthropic](https://anthropic.com) API key
148
-
149
- ## License
150
-
151
- MIT
@@ -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
- }
@@ -1 +0,0 @@
1
- export declare function dev(): Promise<void>;
@@ -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
- }
@@ -1,5 +0,0 @@
1
- type InitOptions = {
2
- demo?: boolean;
3
- };
4
- export declare function init(options?: InitOptions): Promise<void>;
5
- export {};