@castari/sdk 0.1.5 → 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.
- package/README.md +84 -174
- package/dist/agents.d.ts +76 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +111 -0
- package/dist/agents.js.map +1 -0
- package/dist/auth.d.ts +27 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +33 -0
- package/dist/auth.js.map +1 -0
- package/dist/client.d.ts +51 -50
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +90 -243
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +47 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +108 -0
- package/dist/config.js.map +1 -0
- package/dist/errors.d.ts +52 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +73 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +32 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +117 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -4
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +157 -58
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/dist/usage.d.ts +26 -0
- package/dist/usage.d.ts.map +1 -0
- package/dist/usage.js +45 -0
- package/dist/usage.js.map +1 -0
- package/package.json +51 -34
- package/LICENSE +0 -21
- package/dist/const.d.ts +0 -6
- package/dist/const.js +0 -9
- package/dist/message-handler.d.ts +0 -8
- package/dist/message-handler.js +0 -96
- package/dist/server.d.ts +0 -6
- package/dist/server.js +0 -222
package/README.md
CHANGED
|
@@ -1,230 +1,140 @@
|
|
|
1
1
|
# @castari/sdk
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official Castari SDK for TypeScript and Node.js.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @castari/sdk
|
|
9
|
-
# or
|
|
10
|
-
bun add @castari/sdk
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
14
|
-
|
|
15
|
-
### `serve(options)`
|
|
16
|
-
|
|
17
|
-
Starts the agent server. This should be the entrypoint of your agent.
|
|
11
|
+
## Quick Start
|
|
18
12
|
|
|
19
13
|
```typescript
|
|
20
|
-
import {
|
|
14
|
+
import { CastariClient } from '@castari/sdk';
|
|
21
15
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
})
|
|
26
|
-
```
|
|
16
|
+
// Using API key
|
|
17
|
+
const client = new CastariClient({
|
|
18
|
+
apiKey: process.env.CASTARI_API_KEY,
|
|
19
|
+
});
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
// Or let it load from ~/.castari/credentials.yaml
|
|
22
|
+
const client = new CastariClient();
|
|
23
|
+
await client.ensureAuthenticated();
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
| `tools` | `Tool[]` | Array of tools exposed by the agent |
|
|
33
|
-
| `systemPrompt` | `string` | The system prompt defining the agent's behavior |
|
|
34
|
-
| `allowedTools` | `string[]` | (Optional) Restrict which tools the agent can use |
|
|
35
|
-
| `port` | `number` | (Optional) Port to listen on. Defaults to `3000` |
|
|
25
|
+
// List agents
|
|
26
|
+
const agents = await client.agents.list();
|
|
36
27
|
|
|
37
|
-
|
|
28
|
+
// Deploy an agent
|
|
29
|
+
await client.agents.deploy('my-agent');
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
31
|
+
// Invoke an agent
|
|
32
|
+
const result = await client.agents.invoke('my-agent', {
|
|
33
|
+
prompt: 'Hello, world!',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
console.log(result.response_content);
|
|
44
37
|
```
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
## API Reference
|
|
47
40
|
|
|
48
|
-
|
|
41
|
+
### CastariClient
|
|
49
42
|
|
|
50
43
|
```typescript
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
inputSchema: {
|
|
57
|
-
type: 'object',
|
|
58
|
-
properties: {
|
|
59
|
-
location: { type: 'string' }
|
|
60
|
-
},
|
|
61
|
-
required: ['location']
|
|
62
|
-
},
|
|
63
|
-
handler: async ({ location }) => {
|
|
64
|
-
return `The weather in ${location} is sunny.`
|
|
65
|
-
}
|
|
66
|
-
})
|
|
44
|
+
const client = new CastariClient({
|
|
45
|
+
apiKey?: string, // API key (cast_...)
|
|
46
|
+
token?: string, // OAuth token
|
|
47
|
+
baseUrl?: string, // API base URL
|
|
48
|
+
});
|
|
67
49
|
```
|
|
68
50
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
### `CastariClient`
|
|
72
|
-
|
|
73
|
-
A client for connecting to Castari agents running in cloud sandboxes.
|
|
51
|
+
### Agents
|
|
74
52
|
|
|
75
53
|
```typescript
|
|
76
|
-
|
|
54
|
+
// List all agents
|
|
55
|
+
const agents = await client.agents.list();
|
|
77
56
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
})
|
|
57
|
+
// Create an agent
|
|
58
|
+
const agent = await client.agents.create({
|
|
59
|
+
name: 'My Agent',
|
|
60
|
+
gitRepoUrl: 'https://github.com/user/repo',
|
|
61
|
+
slug: 'my-agent',
|
|
62
|
+
});
|
|
84
63
|
|
|
85
|
-
|
|
64
|
+
// Get agent by slug
|
|
65
|
+
const agent = await client.agents.get('my-agent');
|
|
86
66
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
console.log('Agent:', msg.data.message)
|
|
90
|
-
}
|
|
91
|
-
})
|
|
67
|
+
// Delete an agent
|
|
68
|
+
await client.agents.delete('my-agent');
|
|
92
69
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
data: { message: 'Hello!' }
|
|
96
|
-
})
|
|
70
|
+
// Deploy an agent
|
|
71
|
+
const agent = await client.agents.deploy('my-agent');
|
|
97
72
|
|
|
98
|
-
//
|
|
99
|
-
await client.
|
|
73
|
+
// Invoke an agent
|
|
74
|
+
const result = await client.agents.invoke('my-agent', {
|
|
75
|
+
prompt: 'Your prompt here',
|
|
76
|
+
});
|
|
100
77
|
```
|
|
101
78
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
| Property | Type | Description |
|
|
105
|
-
|----------|------|-------------|
|
|
106
|
-
| `snapshot` | `string` | Name of the deployed snapshot to use |
|
|
107
|
-
| `clientId` | `string` | Your Castari client ID |
|
|
108
|
-
| `platformApiKey` | `string` | Your Castari API key |
|
|
109
|
-
| `anthropicApiKey` | `string` | Your Anthropic API key |
|
|
110
|
-
| `volume` | `string` | (Optional) Volume name for persistent storage |
|
|
111
|
-
| `labels` | `Record<string, string>` | (Optional) Labels for sandbox reuse |
|
|
112
|
-
| `resume` | `string` | (Optional) Session ID to resume a previous conversation |
|
|
113
|
-
| `connectionUrl` | `string` | (Optional) Direct URL for local development |
|
|
114
|
-
| `platformUrl` | `string` | (Optional) Override the platform URL |
|
|
115
|
-
| `useProxy` | `boolean` | (Optional) Use platform proxy. Defaults to `true` |
|
|
116
|
-
| `debug` | `boolean` | (Optional) Enable debug logging |
|
|
117
|
-
|
|
118
|
-
#### Methods
|
|
119
|
-
|
|
120
|
-
- `start()` - Creates a sandbox and connects to the agent
|
|
121
|
-
- `stop(options?)` - Disconnects and cleans up
|
|
122
|
-
- `{ delete: false }` - Stop but preserve sandbox for reuse
|
|
123
|
-
- `{ delete: true }` (default) - Delete the sandbox
|
|
124
|
-
- `send(message)` - Send a message to the agent
|
|
125
|
-
- `onMessage(callback)` - Register a callback for incoming messages
|
|
126
|
-
|
|
127
|
-
### Message Types
|
|
128
|
-
|
|
129
|
-
#### Input Messages (client to agent)
|
|
79
|
+
### Secrets
|
|
130
80
|
|
|
131
81
|
```typescript
|
|
132
|
-
//
|
|
133
|
-
client.
|
|
134
|
-
type: 'user_message',
|
|
135
|
-
data: { message: 'Hello!' }
|
|
136
|
-
})
|
|
137
|
-
```
|
|
82
|
+
// List secrets (keys only, values are never returned)
|
|
83
|
+
const secrets = await client.agents.listSecrets('my-agent');
|
|
138
84
|
|
|
139
|
-
|
|
85
|
+
// Set a secret
|
|
86
|
+
await client.agents.setSecret('my-agent', 'API_KEY', 'secret-value');
|
|
140
87
|
|
|
141
|
-
|
|
142
|
-
client.
|
|
143
|
-
switch (msg.type) {
|
|
144
|
-
case 'connected':
|
|
145
|
-
// Connection established
|
|
146
|
-
break
|
|
147
|
-
case 'assistant_message':
|
|
148
|
-
// Text response from the agent
|
|
149
|
-
console.log(msg.data.message)
|
|
150
|
-
break
|
|
151
|
-
case 'tool_use':
|
|
152
|
-
// Agent is using a tool
|
|
153
|
-
console.log(`Using tool: ${msg.data.name}`)
|
|
154
|
-
break
|
|
155
|
-
case 'tool_result':
|
|
156
|
-
// Tool execution result
|
|
157
|
-
break
|
|
158
|
-
case 'done':
|
|
159
|
-
// Agent finished processing
|
|
160
|
-
break
|
|
161
|
-
case 'error':
|
|
162
|
-
// Error occurred
|
|
163
|
-
console.error(msg.data.error)
|
|
164
|
-
break
|
|
165
|
-
}
|
|
166
|
-
})
|
|
88
|
+
// Delete a secret
|
|
89
|
+
await client.agents.deleteSecret('my-agent', 'API_KEY');
|
|
167
90
|
```
|
|
168
91
|
|
|
169
|
-
###
|
|
170
|
-
|
|
171
|
-
Use labels to reuse sandboxes across sessions:
|
|
92
|
+
### Usage
|
|
172
93
|
|
|
173
94
|
```typescript
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
volume: `user-${userId}`,
|
|
177
|
-
labels: {
|
|
178
|
-
userId,
|
|
179
|
-
app: 'my-app'
|
|
180
|
-
}
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
// First call creates, subsequent calls reuse the same sandbox
|
|
184
|
-
await client.start()
|
|
95
|
+
// Get usage summary
|
|
96
|
+
const summary = await client.usage.summary({ days: 30 });
|
|
185
97
|
|
|
186
|
-
//
|
|
187
|
-
await client.
|
|
98
|
+
// Get daily breakdown
|
|
99
|
+
const daily = await client.usage.daily({ days: 7 });
|
|
188
100
|
```
|
|
189
101
|
|
|
190
|
-
###
|
|
191
|
-
|
|
192
|
-
Resume a previous conversation:
|
|
102
|
+
### Auth
|
|
193
103
|
|
|
194
104
|
```typescript
|
|
195
|
-
//
|
|
196
|
-
const
|
|
105
|
+
// Get current user
|
|
106
|
+
const user = await client.auth.me();
|
|
197
107
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
resume: sessionId
|
|
201
|
-
})
|
|
108
|
+
// Create API key
|
|
109
|
+
const { api_key, prefix } = await client.auth.createApiKey();
|
|
202
110
|
|
|
203
|
-
|
|
204
|
-
|
|
111
|
+
// Revoke API key
|
|
112
|
+
await client.auth.revokeApiKey();
|
|
205
113
|
```
|
|
206
114
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
Connect directly to a local agent server:
|
|
115
|
+
## Error Handling
|
|
210
116
|
|
|
211
117
|
```typescript
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
118
|
+
import {
|
|
119
|
+
CastariError,
|
|
120
|
+
AuthenticationError,
|
|
121
|
+
NotFoundError,
|
|
122
|
+
RateLimitError,
|
|
123
|
+
} from '@castari/sdk';
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
await client.agents.get('non-existent');
|
|
127
|
+
} catch (error) {
|
|
128
|
+
if (error instanceof NotFoundError) {
|
|
129
|
+
console.log('Agent not found');
|
|
130
|
+
} else if (error instanceof AuthenticationError) {
|
|
131
|
+
console.log('Not authenticated');
|
|
132
|
+
} else if (error instanceof RateLimitError) {
|
|
133
|
+
console.log(`Rate limited, retry in ${error.retryAfter}s`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
218
136
|
```
|
|
219
137
|
|
|
220
|
-
## Environment Variables
|
|
221
|
-
|
|
222
|
-
| Variable | Description |
|
|
223
|
-
|----------|-------------|
|
|
224
|
-
| `ANTHROPIC_API_KEY` | Your Anthropic API key |
|
|
225
|
-
| `CASTARI_CLIENT_ID` | Your Castari client ID |
|
|
226
|
-
| `CASTARI_API_KEY` | Your Castari API key |
|
|
227
|
-
|
|
228
138
|
## License
|
|
229
139
|
|
|
230
140
|
MIT
|
package/dist/agents.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { HttpClient } from './http.js';
|
|
2
|
+
import type { Agent, CreateAgentOptions, InvocationResponse, InvokeOptions, Secret } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* API for managing agents
|
|
5
|
+
*/
|
|
6
|
+
export declare class AgentsAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* List all agents for the authenticated user
|
|
11
|
+
* @returns Array of agents
|
|
12
|
+
*/
|
|
13
|
+
list(): Promise<Agent[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Create a new agent
|
|
16
|
+
* @param options - Agent creation options
|
|
17
|
+
* @returns The created agent
|
|
18
|
+
*/
|
|
19
|
+
create(options: CreateAgentOptions): Promise<Agent>;
|
|
20
|
+
/**
|
|
21
|
+
* Get an agent by slug
|
|
22
|
+
* @param slug - The agent's unique slug
|
|
23
|
+
* @returns The agent
|
|
24
|
+
* @throws NotFoundError if agent doesn't exist
|
|
25
|
+
*/
|
|
26
|
+
get(slug: string): Promise<Agent>;
|
|
27
|
+
/**
|
|
28
|
+
* Delete an agent
|
|
29
|
+
* @param slug - The agent's unique slug
|
|
30
|
+
* @throws NotFoundError if agent doesn't exist
|
|
31
|
+
*/
|
|
32
|
+
delete(slug: string): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Deploy an agent (create sandbox, clone repo, install deps)
|
|
35
|
+
* @param slug - The agent's unique slug
|
|
36
|
+
* @returns The updated agent with status 'active'
|
|
37
|
+
* @throws NotFoundError if agent doesn't exist
|
|
38
|
+
*/
|
|
39
|
+
deploy(slug: string): Promise<Agent>;
|
|
40
|
+
/**
|
|
41
|
+
* Stop a running agent
|
|
42
|
+
* @param slug - The agent's unique slug
|
|
43
|
+
* @returns The updated agent with status 'stopped'
|
|
44
|
+
* @throws NotFoundError if agent doesn't exist
|
|
45
|
+
*/
|
|
46
|
+
stop(slug: string): Promise<Agent>;
|
|
47
|
+
/**
|
|
48
|
+
* Invoke an agent with a prompt
|
|
49
|
+
* @param slug - The agent's unique slug
|
|
50
|
+
* @param options - Invocation options including prompt
|
|
51
|
+
* @returns The invocation response with result and usage stats
|
|
52
|
+
* @throws NotFoundError if agent doesn't exist
|
|
53
|
+
* @throws BadRequestError if agent is not deployed
|
|
54
|
+
*/
|
|
55
|
+
invoke(slug: string, options: InvokeOptions): Promise<InvocationResponse>;
|
|
56
|
+
/**
|
|
57
|
+
* List secret keys for an agent (values are never returned)
|
|
58
|
+
* @param slug - The agent's unique slug
|
|
59
|
+
* @returns Array of secret key names
|
|
60
|
+
*/
|
|
61
|
+
listSecrets(slug: string): Promise<Secret[]>;
|
|
62
|
+
/**
|
|
63
|
+
* Set a secret for an agent
|
|
64
|
+
* @param slug - The agent's unique slug
|
|
65
|
+
* @param key - The secret key
|
|
66
|
+
* @param value - The secret value
|
|
67
|
+
*/
|
|
68
|
+
setSecret(slug: string, key: string, value: string): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Delete a secret from an agent
|
|
71
|
+
* @param slug - The agent's unique slug
|
|
72
|
+
* @param key - The secret key to delete
|
|
73
|
+
*/
|
|
74
|
+
deleteSecret(slug: string, key: string): Promise<void>;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAA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
|
|
4
|
+
export class AgentsAPI {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* List all agents for the authenticated user
|
|
11
|
+
* @returns Array of agents
|
|
12
|
+
*/
|
|
13
|
+
async list() {
|
|
14
|
+
const response = await this.client.request('GET', '/agents');
|
|
15
|
+
return response.agents;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a new agent
|
|
19
|
+
* @param options - Agent creation options
|
|
20
|
+
* @returns The created agent
|
|
21
|
+
*/
|
|
22
|
+
async create(options) {
|
|
23
|
+
return this.client.request('POST', '/agents', {
|
|
24
|
+
body: {
|
|
25
|
+
name: options.name,
|
|
26
|
+
git_repo_url: options.gitRepoUrl,
|
|
27
|
+
slug: options.slug,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get an agent by slug
|
|
33
|
+
* @param slug - The agent's unique slug
|
|
34
|
+
* @returns The agent
|
|
35
|
+
* @throws NotFoundError if agent doesn't exist
|
|
36
|
+
*/
|
|
37
|
+
async get(slug) {
|
|
38
|
+
return this.client.request('GET', `/agents/${encodeURIComponent(slug)}`);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Delete an agent
|
|
42
|
+
* @param slug - The agent's unique slug
|
|
43
|
+
* @throws NotFoundError if agent doesn't exist
|
|
44
|
+
*/
|
|
45
|
+
async delete(slug) {
|
|
46
|
+
return this.client.request('DELETE', `/agents/${encodeURIComponent(slug)}`);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Deploy an agent (create sandbox, clone repo, install deps)
|
|
50
|
+
* @param slug - The agent's unique slug
|
|
51
|
+
* @returns The updated agent with status 'active'
|
|
52
|
+
* @throws NotFoundError if agent doesn't exist
|
|
53
|
+
*/
|
|
54
|
+
async deploy(slug) {
|
|
55
|
+
return this.client.request('POST', `/agents/${encodeURIComponent(slug)}/deploy`, {
|
|
56
|
+
timeout: 120000, // 2 minutes for deployment
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Stop a running agent
|
|
61
|
+
* @param slug - The agent's unique slug
|
|
62
|
+
* @returns The updated agent with status 'stopped'
|
|
63
|
+
* @throws NotFoundError if agent doesn't exist
|
|
64
|
+
*/
|
|
65
|
+
async stop(slug) {
|
|
66
|
+
return this.client.request('POST', `/agents/${encodeURIComponent(slug)}/stop`);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Invoke an agent with a prompt
|
|
70
|
+
* @param slug - The agent's unique slug
|
|
71
|
+
* @param options - Invocation options including prompt
|
|
72
|
+
* @returns The invocation response with result and usage stats
|
|
73
|
+
* @throws NotFoundError if agent doesn't exist
|
|
74
|
+
* @throws BadRequestError if agent is not deployed
|
|
75
|
+
*/
|
|
76
|
+
async invoke(slug, options) {
|
|
77
|
+
return this.client.request('POST', `/agents/${encodeURIComponent(slug)}/invoke`, {
|
|
78
|
+
body: { prompt: options.prompt },
|
|
79
|
+
timeout: 180000, // 3 minutes for invocation
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* List secret keys for an agent (values are never returned)
|
|
84
|
+
* @param slug - The agent's unique slug
|
|
85
|
+
* @returns Array of secret key names
|
|
86
|
+
*/
|
|
87
|
+
async listSecrets(slug) {
|
|
88
|
+
const response = await this.client.request('GET', `/agents/${encodeURIComponent(slug)}/secrets`);
|
|
89
|
+
return response.secrets;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Set a secret for an agent
|
|
93
|
+
* @param slug - The agent's unique slug
|
|
94
|
+
* @param key - The secret key
|
|
95
|
+
* @param value - The secret value
|
|
96
|
+
*/
|
|
97
|
+
async setSecret(slug, key, value) {
|
|
98
|
+
return this.client.request('POST', `/agents/${encodeURIComponent(slug)}/secrets`, {
|
|
99
|
+
body: { key, value },
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Delete a secret from an agent
|
|
104
|
+
* @param slug - The agent's unique slug
|
|
105
|
+
* @param key - The secret key to delete
|
|
106
|
+
*/
|
|
107
|
+
async deleteSecret(slug, key) {
|
|
108
|
+
return this.client.request('DELETE', `/agents/${encodeURIComponent(slug)}/secrets/${encodeURIComponent(key)}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAUA;;GAEG;AACH,MAAM,OAAO,SAAS;IACA;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAqB,KAAK,EAAE,SAAS,CAAC,CAAC;QACjF,OAAO,QAAQ,CAAC,MAAM,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,OAA2B;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAQ,MAAM,EAAE,SAAS,EAAE;YACnD,IAAI,EAAE;gBACJ,IAAI,EAAE,OAAO,CAAC,IAAI;gBAClB,YAAY,EAAE,OAAO,CAAC,UAAU;gBAChC,IAAI,EAAE,OAAO,CAAC,IAAI;aACnB;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAQ,KAAK,EAAE,WAAW,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAClF,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,O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,KAAK,EAAE;SACrB,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,IAAY,EAAE,GAAW;QAC1C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,QAAQ,EACR,WAAW,kBAAkB,CAAC,IAAI,CAAC,YAAY,kBAAkB,CAAC,GAAG,CAAC,EAAE,CACzE,CAAC;IACJ,CAAC;CACF"}
|
package/dist/auth.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HttpClient } from './http.js';
|
|
2
|
+
import type { User, ApiKeyResponse } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* API for authentication operations
|
|
5
|
+
*/
|
|
6
|
+
export declare class AuthAPI {
|
|
7
|
+
private client;
|
|
8
|
+
constructor(client: HttpClient);
|
|
9
|
+
/**
|
|
10
|
+
* Get the currently authenticated user
|
|
11
|
+
* @returns The authenticated user
|
|
12
|
+
* @throws AuthenticationError if not authenticated
|
|
13
|
+
*/
|
|
14
|
+
me(): Promise<User>;
|
|
15
|
+
/**
|
|
16
|
+
* Create a new API key for the authenticated user
|
|
17
|
+
* @returns The new API key (only shown once)
|
|
18
|
+
* @throws BadRequestError if user already has an API key
|
|
19
|
+
*/
|
|
20
|
+
createApiKey(): Promise<ApiKeyResponse>;
|
|
21
|
+
/**
|
|
22
|
+
* Revoke the user's API key
|
|
23
|
+
* @throws BadRequestError if user has no API key
|
|
24
|
+
*/
|
|
25
|
+
revokeApiKey(): Promise<void>;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEvD;;GAEG;AACH,qBAAa,OAAO;IACN,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,UAAU;IAEtC;;;;OAIG;IACG,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IAIzB;;;;OAIG;IACG,YAAY,IAAI,OAAO,CAAC,cAAc,CAAC;IAI7C;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;CAGpC"}
|
package/dist/auth.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API for authentication operations
|
|
3
|
+
*/
|
|
4
|
+
export class AuthAPI {
|
|
5
|
+
client;
|
|
6
|
+
constructor(client) {
|
|
7
|
+
this.client = client;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Get the currently authenticated user
|
|
11
|
+
* @returns The authenticated user
|
|
12
|
+
* @throws AuthenticationError if not authenticated
|
|
13
|
+
*/
|
|
14
|
+
async me() {
|
|
15
|
+
return this.client.request('GET', '/auth/me');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Create a new API key for the authenticated user
|
|
19
|
+
* @returns The new API key (only shown once)
|
|
20
|
+
* @throws BadRequestError if user already has an API key
|
|
21
|
+
*/
|
|
22
|
+
async createApiKey() {
|
|
23
|
+
return this.client.request('POST', '/auth/api-key');
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Revoke the user's API key
|
|
27
|
+
* @throws BadRequestError if user has no API key
|
|
28
|
+
*/
|
|
29
|
+
async revokeApiKey() {
|
|
30
|
+
return this.client.request('DELETE', '/auth/api-key');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=auth.js.map
|
package/dist/auth.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,OAAO,OAAO;IACE;IAApB,YAAoB,MAAkB;QAAlB,WAAM,GAAN,MAAM,CAAY;IAAG,CAAC;IAE1C;;;;OAIG;IACH,KAAK,CAAC,EAAE;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO,KAAK,EAAE,UAAU,CAAC,CAAC;IACtD,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAiB,MAAM,EAAE,eAAe,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YAAY;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAO,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC9D,CAAC;CACF"}
|