@castari/cli 0.1.10 → 0.1.11
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 +27 -7
- package/dist/commands/init.js +19 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ castari dev
|
|
|
22
22
|
# Deploy to Castari Platform
|
|
23
23
|
castari deploy
|
|
24
24
|
|
|
25
|
-
# Start a cloud sandbox
|
|
25
|
+
# Start a cloud sandbox and connect
|
|
26
26
|
castari start
|
|
27
27
|
```
|
|
28
28
|
|
|
@@ -37,12 +37,17 @@ castari init # Basic agent scaffold
|
|
|
37
37
|
castari init --demo # Full demo with agent + Next.js chat UI
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
Creates
|
|
40
|
+
**Creates:**
|
|
41
41
|
- `package.json` - Configured with dependencies
|
|
42
42
|
- `tsconfig.json` - TypeScript configuration
|
|
43
43
|
- `src/agent.ts` - Starter agent code
|
|
44
44
|
- `.env.example` - Environment variable template
|
|
45
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
|
+
|
|
46
51
|
### `castari dev`
|
|
47
52
|
|
|
48
53
|
Runs the agent locally for development.
|
|
@@ -51,11 +56,11 @@ Runs the agent locally for development.
|
|
|
51
56
|
castari dev
|
|
52
57
|
```
|
|
53
58
|
|
|
54
|
-
Starts a local server at `http://localhost:3000` with
|
|
59
|
+
Starts a local server at `http://localhost:3000`. Connect to it using the SDK's `CastariClient` with `connectionUrl: 'http://localhost:3000'`.
|
|
55
60
|
|
|
56
61
|
### `castari deploy`
|
|
57
62
|
|
|
58
|
-
Uploads your agent to the Castari Platform.
|
|
63
|
+
Uploads your agent to the Castari Platform and creates a snapshot.
|
|
59
64
|
|
|
60
65
|
```bash
|
|
61
66
|
castari deploy
|
|
@@ -65,14 +70,17 @@ castari deploy --name my-custom-name
|
|
|
65
70
|
**Options:**
|
|
66
71
|
- `--name <name>` - Override the snapshot name (defaults to package.json name)
|
|
67
72
|
|
|
68
|
-
**Requires:** `CASTARI_CLIENT_ID` environment
|
|
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.
|
|
69
76
|
|
|
70
77
|
### `castari start`
|
|
71
78
|
|
|
72
|
-
Starts a cloud sandbox and connects
|
|
79
|
+
Starts a cloud sandbox running your agent and connects interactively.
|
|
73
80
|
|
|
74
81
|
```bash
|
|
75
82
|
castari start
|
|
83
|
+
castari start --snapshot my-agent
|
|
76
84
|
castari start --snapshot my-agent --volume my-data
|
|
77
85
|
```
|
|
78
86
|
|
|
@@ -80,7 +88,7 @@ castari start --snapshot my-agent --volume my-data
|
|
|
80
88
|
- `--snapshot <name>` - Snapshot to use (defaults to package.json name)
|
|
81
89
|
- `--volume <name>` - Volume to mount for persistent storage
|
|
82
90
|
|
|
83
|
-
**Requires:** `CASTARI_CLIENT_ID` and `ANTHROPIC_API_KEY` environment variables
|
|
91
|
+
**Requires:** `CASTARI_CLIENT_ID`, `CASTARI_API_KEY`, and `ANTHROPIC_API_KEY` environment variables
|
|
84
92
|
|
|
85
93
|
Press `Ctrl+C` to gracefully shut down.
|
|
86
94
|
|
|
@@ -93,6 +101,7 @@ castari generate-secrets
|
|
|
93
101
|
```
|
|
94
102
|
|
|
95
103
|
Outputs both values so you can copy them to your `.env` file:
|
|
104
|
+
|
|
96
105
|
```
|
|
97
106
|
CASTARI_CLIENT_ID=your-client-id
|
|
98
107
|
CASTARI_API_KEY=castari_your-api-key
|
|
@@ -112,6 +121,8 @@ CASTARI_API_KEY=castari_your-api-key
|
|
|
112
121
|
|
|
113
122
|
### package.json
|
|
114
123
|
|
|
124
|
+
Configure Castari settings in your package.json:
|
|
125
|
+
|
|
115
126
|
```json
|
|
116
127
|
{
|
|
117
128
|
"name": "my-agent",
|
|
@@ -121,6 +132,15 @@ CASTARI_API_KEY=castari_your-api-key
|
|
|
121
132
|
}
|
|
122
133
|
```
|
|
123
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
|
+
|
|
124
144
|
## Prerequisites
|
|
125
145
|
|
|
126
146
|
- [Bun](https://bun.sh) v1.0+
|
package/dist/commands/init.js
CHANGED
|
@@ -25,7 +25,7 @@ export async function init(options = {}) {
|
|
|
25
25
|
start: 'castari start',
|
|
26
26
|
},
|
|
27
27
|
dependencies: {
|
|
28
|
-
'@castari/sdk': '^0.1.
|
|
28
|
+
'@castari/sdk': '^0.1.5',
|
|
29
29
|
'@anthropic-ai/claude-agent-sdk': '^0.1.50',
|
|
30
30
|
},
|
|
31
31
|
castari: {
|
|
@@ -92,7 +92,7 @@ async function initDemo() {
|
|
|
92
92
|
start: 'bun run src/agent.ts',
|
|
93
93
|
},
|
|
94
94
|
dependencies: {
|
|
95
|
-
'@castari/sdk': '^0.1.
|
|
95
|
+
'@castari/sdk': '^0.1.5',
|
|
96
96
|
'@anthropic-ai/claude-agent-sdk': '^0.1.50',
|
|
97
97
|
},
|
|
98
98
|
castari: {
|
|
@@ -136,7 +136,7 @@ serve({
|
|
|
136
136
|
start: 'next start',
|
|
137
137
|
},
|
|
138
138
|
dependencies: {
|
|
139
|
-
'@castari/sdk': '^0.1.
|
|
139
|
+
'@castari/sdk': '^0.1.5',
|
|
140
140
|
next: '14.2.3',
|
|
141
141
|
react: '18.3.1',
|
|
142
142
|
'react-dom': '18.3.1',
|
|
@@ -640,6 +640,7 @@ const LABELS = { app: 'castari-demo', env: 'local' }
|
|
|
640
640
|
const VOLUME = 'castari-demo-workspace'
|
|
641
641
|
|
|
642
642
|
let clientPromise: Promise<CastariClient> | null = null
|
|
643
|
+
let currentClient: CastariClient | null = null
|
|
643
644
|
|
|
644
645
|
async function createClient() {
|
|
645
646
|
const anthropicApiKey = process.env.ANTHROPIC_API_KEY
|
|
@@ -657,11 +658,26 @@ async function createClient() {
|
|
|
657
658
|
debug: process.env.CASTARI_DEBUG === 'true',
|
|
658
659
|
})
|
|
659
660
|
|
|
661
|
+
// Clear singleton when connection closes so we reconnect on next message
|
|
662
|
+
client.onClose((code, reason) => {
|
|
663
|
+
console.log(\`[Castari] Connection closed (code=\${code}), will reconnect on next message\`)
|
|
664
|
+
clientPromise = null
|
|
665
|
+
currentClient = null
|
|
666
|
+
})
|
|
667
|
+
|
|
660
668
|
await client.start()
|
|
669
|
+
currentClient = client
|
|
661
670
|
return client
|
|
662
671
|
}
|
|
663
672
|
|
|
664
673
|
async function getClient() {
|
|
674
|
+
// If we have a client but it's disconnected, clear and recreate
|
|
675
|
+
if (currentClient && !currentClient.isConnected()) {
|
|
676
|
+
console.log('[Castari] Client disconnected, reconnecting...')
|
|
677
|
+
clientPromise = null
|
|
678
|
+
currentClient = null
|
|
679
|
+
}
|
|
680
|
+
|
|
665
681
|
if (!clientPromise) {
|
|
666
682
|
clientPromise = createClient()
|
|
667
683
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@castari/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"castari": "./dist/index.js"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"@anthropic-ai/claude-agent-sdk": "^0.1.44",
|
|
21
|
-
"@castari/sdk": "^0.1.
|
|
21
|
+
"@castari/sdk": "^0.1.5",
|
|
22
22
|
"adm-zip": "^0.5.16",
|
|
23
23
|
"cac": "^6.7.14",
|
|
24
24
|
"chalk": "^5.3.0",
|