@openbeam/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/README.md +271 -0
- package/dist/index.d.ts +720 -0
- package/dist/index.js +497 -0
- package/package.json +46 -0
package/README.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# @openbeam/sdk
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [OpenBeam](https://openbeam.work) enterprise search and AI platform.
|
|
4
|
+
|
|
5
|
+
Search across 103+ connectors, query the knowledge graph, run AI agents, and manage sync operations — all from a single client.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @openbeam/sdk
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Quick Start
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import OpenBeam from "@openbeam/sdk";
|
|
17
|
+
|
|
18
|
+
const ob = new OpenBeam({ apiKey: "op_live_..." });
|
|
19
|
+
|
|
20
|
+
// Search across all connected data sources
|
|
21
|
+
const results = await ob.search.documents("quarterly revenue report");
|
|
22
|
+
console.log(results.data);
|
|
23
|
+
|
|
24
|
+
// Ask a question with RAG-powered citations
|
|
25
|
+
const answer = await ob.agents.ask("Who owns the authentication service?");
|
|
26
|
+
console.log(answer.data.answer, answer.data.citations);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const ob = new OpenBeam({
|
|
33
|
+
apiKey: "op_live_...", // Required — from Settings > API Keys
|
|
34
|
+
baseUrl: "https://api.openbeam.work", // Optional — custom endpoint
|
|
35
|
+
timeout: 30_000, // Optional — request timeout in ms (default: 30s)
|
|
36
|
+
maxRetries: 2, // Optional — retry count for transient errors (default: 2)
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Resources
|
|
41
|
+
|
|
42
|
+
### Search
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Hybrid semantic + keyword search
|
|
46
|
+
const results = await ob.search.documents("deployment runbook", {
|
|
47
|
+
limit: 20,
|
|
48
|
+
connectorTypes: ["NOTION", "CONFLUENCE"],
|
|
49
|
+
ranking: "hybrid",
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Semantic-only search
|
|
53
|
+
const semantic = await ob.search.semantic("how does auth work");
|
|
54
|
+
|
|
55
|
+
// Find similar documents
|
|
56
|
+
const similar = await ob.search.similar("doc_abc123");
|
|
57
|
+
|
|
58
|
+
// Recent documents (last N hours)
|
|
59
|
+
const recent = await ob.search.recent({ hours: 24, limit: 10 });
|
|
60
|
+
|
|
61
|
+
// Documents by author
|
|
62
|
+
const authored = await ob.search.byAuthor("person_xyz", { limit: 10 });
|
|
63
|
+
|
|
64
|
+
// Find people
|
|
65
|
+
const people = await ob.search.people("engineering manager");
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Connectors
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// List connected data sources
|
|
72
|
+
const connectors = await ob.connectors.list({ status: "active" });
|
|
73
|
+
|
|
74
|
+
// Get connector details
|
|
75
|
+
const detail = await ob.connectors.get("conn_abc");
|
|
76
|
+
|
|
77
|
+
// Check connector health
|
|
78
|
+
const health = await ob.connectors.health("conn_abc");
|
|
79
|
+
|
|
80
|
+
// List available connector types
|
|
81
|
+
const available = await ob.connectors.available({ authType: "OAUTH" });
|
|
82
|
+
|
|
83
|
+
// Disconnect a connector
|
|
84
|
+
await ob.connectors.disconnect("conn_abc");
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Sync
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
// Trigger incremental sync
|
|
91
|
+
const job = await ob.sync.trigger("conn_abc", "incremental");
|
|
92
|
+
|
|
93
|
+
// Trigger full re-sync
|
|
94
|
+
const fullJob = await ob.sync.trigger("conn_abc", "full");
|
|
95
|
+
|
|
96
|
+
// Trigger all connectors
|
|
97
|
+
const all = await ob.sync.triggerAll({ type: "incremental" });
|
|
98
|
+
|
|
99
|
+
// Check sync status
|
|
100
|
+
const status = await ob.sync.status("conn_abc");
|
|
101
|
+
|
|
102
|
+
// View sync history
|
|
103
|
+
const history = await ob.sync.history("conn_abc", { limit: 10 });
|
|
104
|
+
|
|
105
|
+
// Live progress
|
|
106
|
+
const progress = await ob.sync.progress("conn_abc");
|
|
107
|
+
|
|
108
|
+
// Fleet health overview
|
|
109
|
+
const fleet = await ob.sync.health();
|
|
110
|
+
|
|
111
|
+
// Recent errors
|
|
112
|
+
const errors = await ob.sync.errors({ limit: 20 });
|
|
113
|
+
|
|
114
|
+
// Control operations
|
|
115
|
+
await ob.sync.pause("conn_abc");
|
|
116
|
+
await ob.sync.resume("conn_abc");
|
|
117
|
+
await ob.sync.cancel("conn_abc");
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Actions
|
|
121
|
+
|
|
122
|
+
Execute write operations across 88+ connectors (send messages, create issues, etc.).
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
// Discover available actions
|
|
126
|
+
const actions = await ob.actions.list({ connectorType: "LINEAR" });
|
|
127
|
+
|
|
128
|
+
// Execute an action
|
|
129
|
+
const result = await ob.actions.execute("conn_abc", "issue_create", {
|
|
130
|
+
title: "Fix login bug",
|
|
131
|
+
teamId: "team_123",
|
|
132
|
+
priority: 1,
|
|
133
|
+
});
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Knowledge Graph
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
// Search entities (people, projects, topics)
|
|
140
|
+
const entities = await ob.knowledge.searchEntities("authentication", {
|
|
141
|
+
type: "TOPIC",
|
|
142
|
+
limit: 10,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Get entity details with relations
|
|
146
|
+
const entity = await ob.knowledge.getEntity("entity_abc");
|
|
147
|
+
|
|
148
|
+
// Get entity relations
|
|
149
|
+
const relations = await ob.knowledge.getRelations("entity_abc", {
|
|
150
|
+
direction: "both",
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Find experts on a topic
|
|
154
|
+
const experts = await ob.knowledge.topicExperts("topic_abc");
|
|
155
|
+
|
|
156
|
+
// Get a person's expertise areas
|
|
157
|
+
const expertise = await ob.knowledge.personExpertise("person_abc");
|
|
158
|
+
|
|
159
|
+
// Browse topic hierarchy
|
|
160
|
+
const topics = await ob.knowledge.topics({ limit: 20 });
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Agents
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
// List available agent templates
|
|
167
|
+
const agents = await ob.agents.list();
|
|
168
|
+
|
|
169
|
+
// Run an agent
|
|
170
|
+
const result = await ob.agents.run("research", "Analyze our API latency trends");
|
|
171
|
+
|
|
172
|
+
// RAG-powered Q&A with citations
|
|
173
|
+
const answer = await ob.agents.ask("What is our SLA for search latency?", {
|
|
174
|
+
connectorTypes: ["NOTION", "CONFLUENCE"],
|
|
175
|
+
maxSources: 5,
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Search context database
|
|
179
|
+
const context = await ob.agents.contextSearch("deployment procedures");
|
|
180
|
+
|
|
181
|
+
// Read a specific context entry
|
|
182
|
+
const entry = await ob.agents.contextRead("openbeam://resources/team_1/...", {
|
|
183
|
+
level: "2",
|
|
184
|
+
});
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### Team
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Get team info
|
|
191
|
+
const team = await ob.team.info();
|
|
192
|
+
|
|
193
|
+
// List members
|
|
194
|
+
const members = await ob.team.members();
|
|
195
|
+
|
|
196
|
+
// Invite a member
|
|
197
|
+
await ob.team.inviteMember("new@example.com", "MEMBER");
|
|
198
|
+
|
|
199
|
+
// Update role
|
|
200
|
+
await ob.team.updateRole("user_abc", "ADMIN");
|
|
201
|
+
|
|
202
|
+
// Remove member
|
|
203
|
+
await ob.team.removeMember("user_abc");
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### API Keys
|
|
207
|
+
|
|
208
|
+
```typescript
|
|
209
|
+
// List API keys
|
|
210
|
+
const keys = await ob.apiKeys.list();
|
|
211
|
+
|
|
212
|
+
// Create a new key
|
|
213
|
+
const key = await ob.apiKeys.create("CI Pipeline", [
|
|
214
|
+
"search:read",
|
|
215
|
+
"connectors:read",
|
|
216
|
+
]);
|
|
217
|
+
console.log(key.key); // Only shown once
|
|
218
|
+
|
|
219
|
+
// Revoke a key
|
|
220
|
+
await ob.apiKeys.revoke("apikey_abc");
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
## Error Handling
|
|
224
|
+
|
|
225
|
+
```typescript
|
|
226
|
+
import OpenBeam, {
|
|
227
|
+
AuthenticationError,
|
|
228
|
+
RateLimitError,
|
|
229
|
+
NotFoundError,
|
|
230
|
+
PermissionError,
|
|
231
|
+
ToolError,
|
|
232
|
+
} from "@openbeam/sdk";
|
|
233
|
+
|
|
234
|
+
try {
|
|
235
|
+
await ob.search.documents("test");
|
|
236
|
+
} catch (error) {
|
|
237
|
+
if (error instanceof AuthenticationError) {
|
|
238
|
+
// Invalid or missing API key (401)
|
|
239
|
+
} else if (error instanceof PermissionError) {
|
|
240
|
+
// Insufficient scope (403)
|
|
241
|
+
} else if (error instanceof NotFoundError) {
|
|
242
|
+
// Resource not found (404)
|
|
243
|
+
} else if (error instanceof RateLimitError) {
|
|
244
|
+
// Rate limited (429) — retryAfter available
|
|
245
|
+
console.log(`Retry after ${error.retryAfter}s`);
|
|
246
|
+
} else if (error instanceof ToolError) {
|
|
247
|
+
// MCP tool execution failed (422)
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Request Options
|
|
253
|
+
|
|
254
|
+
Every method accepts an options object with:
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
interface RequestOptions {
|
|
258
|
+
signal?: AbortSignal; // Cancel the request
|
|
259
|
+
timeout?: number; // Override default timeout (ms)
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// Example: abort after 5s
|
|
263
|
+
const controller = new AbortController();
|
|
264
|
+
setTimeout(() => controller.abort(), 5000);
|
|
265
|
+
|
|
266
|
+
await ob.search.documents("query", { signal: controller.signal });
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
## License
|
|
270
|
+
|
|
271
|
+
Apache-2.0
|