@agent-nexus/sdk 0.1.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/LICENSE +21 -0
- package/README.md +260 -0
- package/dist/index.d.mts +3336 -0
- package/dist/index.d.ts +3336 -0
- package/dist/index.js +2182 -0
- package/dist/index.mjs +2129 -0
- package/package.json +56 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 NexusGPT
|
|
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
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
# @agent-nexus/sdk
|
|
2
|
+
|
|
3
|
+
Official TypeScript SDK for the [Nexus](https://nexusgpt.io) Public API. Manage agents, tools, folders, and prompt versions programmatically.
|
|
4
|
+
|
|
5
|
+
- Zero runtime dependencies (uses native `fetch`)
|
|
6
|
+
- Full TypeScript support with detailed types
|
|
7
|
+
- Dual CJS/ESM build
|
|
8
|
+
- Node.js 18+
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @agent-nexus/sdk
|
|
14
|
+
# or
|
|
15
|
+
pnpm add @agent-nexus/sdk
|
|
16
|
+
# or
|
|
17
|
+
yarn add @agent-nexus/sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { NexusClient } from "@agent-nexus/sdk";
|
|
24
|
+
|
|
25
|
+
const client = new NexusClient({ apiKey: "nxs_..." });
|
|
26
|
+
|
|
27
|
+
// List all active agents
|
|
28
|
+
const { data: agents, meta } = await client.agents.list({ status: "ACTIVE" });
|
|
29
|
+
console.log(`Found ${meta.total} agents`);
|
|
30
|
+
|
|
31
|
+
// Create a new agent
|
|
32
|
+
const agent = await client.agents.create({
|
|
33
|
+
firstName: "Support",
|
|
34
|
+
lastName: "Bot",
|
|
35
|
+
role: "Customer Support Agent"
|
|
36
|
+
});
|
|
37
|
+
console.log(`Created agent: ${agent.id}`);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Configuration
|
|
41
|
+
|
|
42
|
+
### Options
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const client = new NexusClient({
|
|
46
|
+
apiKey: "nxs_...", // Required (or set NEXUS_API_KEY env var)
|
|
47
|
+
baseUrl: "https://api.nexusgpt.io", // Optional, defaults to production
|
|
48
|
+
timeout: 30000, // Optional, request timeout in ms
|
|
49
|
+
defaultHeaders: {}, // Optional, extra headers per request
|
|
50
|
+
fetch: customFetch // Optional, custom fetch implementation
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Environment Variables
|
|
55
|
+
|
|
56
|
+
| Variable | Description |
|
|
57
|
+
| ---------------- | --------------------------------------------------- |
|
|
58
|
+
| `NEXUS_API_KEY` | API key (used if `apiKey` option is not provided) |
|
|
59
|
+
| `NEXUS_BASE_URL` | Base URL (used if `baseUrl` option is not provided) |
|
|
60
|
+
|
|
61
|
+
## API Reference
|
|
62
|
+
|
|
63
|
+
### Agents
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
// List agents (paginated)
|
|
67
|
+
const { data, meta } = await client.agents.list({
|
|
68
|
+
page: 1,
|
|
69
|
+
limit: 20,
|
|
70
|
+
status: "ACTIVE",
|
|
71
|
+
search: "support"
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Get agent details
|
|
75
|
+
const agent = await client.agents.get("agent-id");
|
|
76
|
+
|
|
77
|
+
// Create agent
|
|
78
|
+
const created = await client.agents.create({ firstName: "A", lastName: "B", role: "Assistant" });
|
|
79
|
+
|
|
80
|
+
// Update agent
|
|
81
|
+
const updated = await client.agents.update("agent-id", { role: "Senior Assistant" });
|
|
82
|
+
|
|
83
|
+
// Delete agent
|
|
84
|
+
await client.agents.delete("agent-id");
|
|
85
|
+
|
|
86
|
+
// Duplicate agent
|
|
87
|
+
const copy = await client.agents.duplicate("agent-id");
|
|
88
|
+
|
|
89
|
+
// Upload profile picture
|
|
90
|
+
await client.agents.uploadProfilePicture("agent-id", file);
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Agent Tools
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
// List tools for an agent
|
|
97
|
+
const tools = await client.agents.tools.list("agent-id");
|
|
98
|
+
|
|
99
|
+
// Get tool details
|
|
100
|
+
const tool = await client.agents.tools.get("agent-id", "tool-id");
|
|
101
|
+
|
|
102
|
+
// Create tool
|
|
103
|
+
const created = await client.agents.tools.create("agent-id", {
|
|
104
|
+
label: "Web Search",
|
|
105
|
+
type: "PLUGIN"
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Update tool
|
|
109
|
+
await client.agents.tools.update("agent-id", "tool-id", { label: "Updated Label" });
|
|
110
|
+
|
|
111
|
+
// Delete tool
|
|
112
|
+
await client.agents.tools.delete("agent-id", "tool-id");
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Folders
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
// List folders and assignments
|
|
119
|
+
const { folders, assignments } = await client.folders.list();
|
|
120
|
+
|
|
121
|
+
// Create folder
|
|
122
|
+
const folder = await client.folders.create({ name: "Support Agents" });
|
|
123
|
+
|
|
124
|
+
// Update folder
|
|
125
|
+
await client.folders.update("folder-id", { name: "Renamed" });
|
|
126
|
+
|
|
127
|
+
// Delete folder
|
|
128
|
+
await client.folders.delete("folder-id");
|
|
129
|
+
|
|
130
|
+
// Assign agent to folder (or set folderId to null to remove)
|
|
131
|
+
await client.folders.assignAgent({ agentId: "agent-id", folderId: "folder-id" });
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Tool Discovery (`client.tools`)
|
|
135
|
+
|
|
136
|
+
The tool discovery resource enables the full LLM tool-configuration workflow: search for tools, inspect their parameters, resolve dynamic dropdown values, and test execution.
|
|
137
|
+
|
|
138
|
+
**Recommended workflow:** search → get detail → list credentials → resolve dynamic fields → configure on agent → test.
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
// 1. Search marketplace tools
|
|
142
|
+
const results = await client.tools.search({ q: "gmail", limit: 5 });
|
|
143
|
+
// results.tools — matching tools
|
|
144
|
+
// results.facets — category facet counts
|
|
145
|
+
// results.total — total matches
|
|
146
|
+
|
|
147
|
+
// 2. Get full tool detail (actions + parameter schemas)
|
|
148
|
+
const detail = await client.tools.get("tool-id");
|
|
149
|
+
// detail.actions — array of actions (e.g. "Send Email", "Create Draft")
|
|
150
|
+
// Each action has parameters with types, descriptions, and remoteOptions flags
|
|
151
|
+
|
|
152
|
+
// 3. List credentials (connected accounts) for the tool
|
|
153
|
+
const { credentials } = await client.tools.credentials("tool-id");
|
|
154
|
+
// credentials[0].id — use this as credentialId below
|
|
155
|
+
|
|
156
|
+
// 4. Resolve dynamic dropdown options
|
|
157
|
+
// For parameters where remoteOptions === true, fetch options at runtime:
|
|
158
|
+
const { options } = await client.tools.resolveOptions("tool-id", {
|
|
159
|
+
componentId: "gmail-send-email", // from action.key
|
|
160
|
+
propName: "label", // from parameter.name
|
|
161
|
+
credentialId: "cred-id", // from credentials list
|
|
162
|
+
configuredProps: {} // previously selected values (for cascading fields)
|
|
163
|
+
});
|
|
164
|
+
// options — [{ label: "Inbox", value: "INBOX" }, ...]
|
|
165
|
+
|
|
166
|
+
// 5. Configure the tool on an agent (existing endpoint)
|
|
167
|
+
await client.agents.tools.create("agent-id", {
|
|
168
|
+
label: "Gmail - Send Email",
|
|
169
|
+
type: "PLUGIN",
|
|
170
|
+
config: { toolId: "tool-id" /* action, parameters, credential */ }
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
// 6. Test the configured tool
|
|
174
|
+
const result = await client.tools.test("agent-id", "tool-config-id", {
|
|
175
|
+
input: { to: "test@example.com", subject: "Hello" }
|
|
176
|
+
});
|
|
177
|
+
// result.status — "success" | "error"
|
|
178
|
+
// result.output — tool's return value
|
|
179
|
+
// result.executionTimeMs — timing
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// List org skills (workflows, AI tasks, collections)
|
|
184
|
+
const { skills, total } = await client.tools.skills({ type: "WORKFLOW", limit: 10 });
|
|
185
|
+
|
|
186
|
+
// Search skills by name
|
|
187
|
+
const filtered = await client.tools.skills({ search: "onboarding" });
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Prompt Versions
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
// List versions (paginated)
|
|
194
|
+
const { data: versions, meta } = await client.agents.versions.list("agent-id");
|
|
195
|
+
|
|
196
|
+
// Get version details
|
|
197
|
+
const version = await client.agents.versions.get("agent-id", "version-id");
|
|
198
|
+
|
|
199
|
+
// Create checkpoint
|
|
200
|
+
const checkpoint = await client.agents.versions.createCheckpoint("agent-id", { name: "v1.0" });
|
|
201
|
+
|
|
202
|
+
// Update version metadata
|
|
203
|
+
await client.agents.versions.update("agent-id", "version-id", { name: "v1.1" });
|
|
204
|
+
|
|
205
|
+
// Delete version
|
|
206
|
+
await client.agents.versions.delete("agent-id", "version-id");
|
|
207
|
+
|
|
208
|
+
// Restore agent prompt to a specific version
|
|
209
|
+
const result = await client.agents.versions.restore("agent-id", "version-id");
|
|
210
|
+
|
|
211
|
+
// Publish version to production
|
|
212
|
+
await client.agents.versions.publish("agent-id", "version-id");
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Error Handling
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { NexusApiError, NexusAuthenticationError, NexusConnectionError } from "@agent-nexus/sdk";
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
await client.agents.get("non-existent-id");
|
|
222
|
+
} catch (err) {
|
|
223
|
+
if (err instanceof NexusAuthenticationError) {
|
|
224
|
+
console.error("Invalid API key");
|
|
225
|
+
} else if (err instanceof NexusApiError) {
|
|
226
|
+
console.error(`API error [${err.code}]: ${err.message} (status ${err.status})`);
|
|
227
|
+
} else if (err instanceof NexusConnectionError) {
|
|
228
|
+
console.error("Network error:", err.message);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## TypeScript
|
|
234
|
+
|
|
235
|
+
All types are exported for use in your application:
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
import type {
|
|
239
|
+
AgentDetail,
|
|
240
|
+
AgentSummary,
|
|
241
|
+
CreateAgentBody,
|
|
242
|
+
AgentToolConfig,
|
|
243
|
+
AgentFolder,
|
|
244
|
+
VersionDetail,
|
|
245
|
+
PageResponse,
|
|
246
|
+
// Tool discovery types
|
|
247
|
+
MarketplaceToolItem,
|
|
248
|
+
MarketplaceToolDetail,
|
|
249
|
+
ToolAction,
|
|
250
|
+
ToolActionParameter,
|
|
251
|
+
ToolCredential,
|
|
252
|
+
RemoteOption,
|
|
253
|
+
SkillItem,
|
|
254
|
+
TestAgentToolResponse
|
|
255
|
+
} from "@agent-nexus/sdk";
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT
|