@usewhisper/sdk 0.2.5 → 1.0.1

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/index.cjs DELETED
@@ -1,310 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
-
20
- // src/sdk/index.ts
21
- var index_exports = {};
22
- __export(index_exports, {
23
- WhisperContext: () => WhisperContext,
24
- default: () => index_default
25
- });
26
- module.exports = __toCommonJS(index_exports);
27
- var WhisperContext = class {
28
- apiKey;
29
- baseUrl;
30
- constructor(config) {
31
- if (!config.apiKey) {
32
- throw new Error("API key is required");
33
- }
34
- this.apiKey = config.apiKey;
35
- this.baseUrl = config.baseUrl || "https://context.usewhisper.dev";
36
- }
37
- async request(endpoint, options = {}) {
38
- const response = await fetch(`${this.baseUrl}${endpoint}`, {
39
- ...options,
40
- headers: {
41
- Authorization: `Bearer ${this.apiKey}`,
42
- "Content-Type": "application/json",
43
- ...options.headers
44
- }
45
- });
46
- if (!response.ok) {
47
- const error = await response.json().catch(() => ({ error: "Request failed" }));
48
- throw new Error(error.error || `HTTP ${response.status}: ${response.statusText}`);
49
- }
50
- return response.json();
51
- }
52
- async query(params) {
53
- return this.request("/v1/context/query", {
54
- method: "POST",
55
- body: JSON.stringify(params)
56
- });
57
- }
58
- async createProject(params) {
59
- return this.request("/v1/projects", {
60
- method: "POST",
61
- body: JSON.stringify(params)
62
- });
63
- }
64
- async listProjects() {
65
- return this.request("/v1/projects");
66
- }
67
- async getProject(id) {
68
- return this.request(`/v1/projects/${id}`);
69
- }
70
- async deleteProject(id) {
71
- return this.request(`/v1/projects/${id}`, { method: "DELETE" });
72
- }
73
- async addSource(projectId, params) {
74
- return this.request(`/v1/projects/${projectId}/sources`, {
75
- method: "POST",
76
- body: JSON.stringify(params)
77
- });
78
- }
79
- async syncSource(sourceId) {
80
- return this.request(`/v1/sources/${sourceId}/sync`, { method: "POST" });
81
- }
82
- async ingest(projectId, documents) {
83
- return this.request(`/v1/projects/${projectId}/ingest`, {
84
- method: "POST",
85
- body: JSON.stringify({ documents })
86
- });
87
- }
88
- async addMemory(params) {
89
- return this.request("/v1/memories", {
90
- method: "POST",
91
- body: JSON.stringify(params)
92
- });
93
- }
94
- async searchMemories(params) {
95
- return this.request("/v1/memories/search", {
96
- method: "POST",
97
- body: JSON.stringify(params)
98
- });
99
- }
100
- async createApiKey(params) {
101
- return this.request("/v1/keys", {
102
- method: "POST",
103
- body: JSON.stringify(params)
104
- });
105
- }
106
- async listApiKeys() {
107
- return this.request("/v1/keys");
108
- }
109
- async getUsage(days = 30) {
110
- return this.request(`/v1/usage?days=${days}`);
111
- }
112
- // ─── SOTA Memory System ─────────────────────────────────────────
113
- /**
114
- * SOTA Memory Search - Search memories with temporal and type filtering
115
- */
116
- async searchMemoriesSOTA(params) {
117
- return this.request("/v1/memory/search", {
118
- method: "POST",
119
- body: JSON.stringify(params)
120
- });
121
- }
122
- /**
123
- * Ingest Session - Create memories from a conversation
124
- */
125
- async ingestSession(params) {
126
- return this.request("/v1/memory/ingest/session", {
127
- method: "POST",
128
- body: JSON.stringify(params)
129
- });
130
- }
131
- /**
132
- * Get Session Memories - Recent memories from a session
133
- */
134
- async getSessionMemories(params) {
135
- const query = new URLSearchParams({
136
- project: params.project,
137
- ...params.limit && { limit: params.limit.toString() },
138
- ...params.since_date && { since_date: params.since_date }
139
- });
140
- return this.request(`/v1/memory/session/${params.session_id}?${query}`);
141
- }
142
- /**
143
- * Get User Profile - Long-term user preferences and facts
144
- */
145
- async getUserProfile(params) {
146
- const query = new URLSearchParams({
147
- project: params.project,
148
- ...params.memory_types && { memory_types: params.memory_types }
149
- });
150
- return this.request(`/v1/memory/profile/${params.user_id}?${query}`);
151
- }
152
- /**
153
- * Get Memory Versions - Version chain history
154
- */
155
- async getMemoryVersions(memoryId) {
156
- return this.request(`/v1/memory/${memoryId}/versions`);
157
- }
158
- /**
159
- * Update Memory - Create a new version
160
- */
161
- async updateMemory(memoryId, params) {
162
- return this.request(`/v1/memory/${memoryId}`, {
163
- method: "PUT",
164
- body: JSON.stringify(params)
165
- });
166
- }
167
- /**
168
- * Delete Memory - Soft delete
169
- */
170
- async deleteMemory(memoryId) {
171
- return this.request(`/v1/memory/${memoryId}`, { method: "DELETE" });
172
- }
173
- /**
174
- * Get Memory Relations - Graph connections
175
- */
176
- async getMemoryRelations(memoryId) {
177
- return this.request(`/v1/memory/${memoryId}/relations`);
178
- }
179
- // ─── Context Layer ──────────────────────────────────────────────
180
- /**
181
- * Oracle Search - Tree-guided document navigation with research mode
182
- */
183
- async oracleSearch(params) {
184
- return this.request("/v1/oracle/search", {
185
- method: "POST",
186
- body: JSON.stringify(params)
187
- });
188
- }
189
- /**
190
- * Autosubscribe - Auto-index project dependencies
191
- */
192
- async autosubscribe(params) {
193
- return this.request("/v1/autosubscribe", {
194
- method: "POST",
195
- body: JSON.stringify(params)
196
- });
197
- }
198
- /**
199
- * Create Shared Context - Save and share a conversation
200
- */
201
- async createSharedContext(params) {
202
- return this.request("/v1/context/share", {
203
- method: "POST",
204
- body: JSON.stringify(params)
205
- });
206
- }
207
- /**
208
- * Load Shared Context - View shared context (public endpoint)
209
- */
210
- async loadSharedContext(shareId) {
211
- return this.request(`/v1/context/shared/${shareId}`);
212
- }
213
- /**
214
- * Resume from Shared Context - Fork shared context to new session
215
- */
216
- async resumeFromSharedContext(params) {
217
- return this.request("/v1/context/resume", {
218
- method: "POST",
219
- body: JSON.stringify(params)
220
- });
221
- }
222
- // ─── Optimization ───────────────────────────────────────────────
223
- /**
224
- * Consolidate Memories - Find and merge duplicates
225
- */
226
- async consolidateMemories(params) {
227
- return this.request("/v1/memory/consolidate", {
228
- method: "POST",
229
- body: JSON.stringify(params)
230
- });
231
- }
232
- /**
233
- * Update Importance Decay - Apply time-based relevance scoring
234
- */
235
- async updateImportanceDecay(params) {
236
- return this.request("/v1/memory/decay/update", {
237
- method: "POST",
238
- body: JSON.stringify(params)
239
- });
240
- }
241
- /**
242
- * Get Importance Statistics
243
- */
244
- async getImportanceStats(project) {
245
- return this.request(`/v1/memory/decay/stats?project=${project}`);
246
- }
247
- /**
248
- * Get Cache Statistics
249
- */
250
- async getCacheStats() {
251
- return this.request("/v1/cache/stats");
252
- }
253
- /**
254
- * Warm Cache - Preload common queries
255
- */
256
- async warmCache(params) {
257
- return this.request("/v1/cache/warm", {
258
- method: "POST",
259
- body: JSON.stringify(params)
260
- });
261
- }
262
- /**
263
- * Clear Cache Pattern
264
- */
265
- async clearCache(params) {
266
- return this.request("/v1/cache/clear", {
267
- method: "DELETE",
268
- body: JSON.stringify(params)
269
- });
270
- }
271
- /**
272
- * Get Cost Summary - Cost tracking overview
273
- */
274
- async getCostSummary(params) {
275
- const query = new URLSearchParams({
276
- ...params.project && { project: params.project },
277
- ...params.start_date && { start_date: params.start_date },
278
- ...params.end_date && { end_date: params.end_date }
279
- });
280
- return this.request(`/v1/cost/summary?${query}`);
281
- }
282
- /**
283
- * Get Cost Breakdown - Detailed cost analysis
284
- */
285
- async getCostBreakdown(params) {
286
- const query = new URLSearchParams({
287
- ...params.project && { project: params.project },
288
- ...params.group_by && { group_by: params.group_by },
289
- ...params.start_date && { start_date: params.start_date },
290
- ...params.end_date && { end_date: params.end_date }
291
- });
292
- return this.request(`/v1/cost/breakdown?${query}`);
293
- }
294
- /**
295
- * Get Savings Report - Compare actual vs always-Opus costs
296
- */
297
- async getCostSavings(params) {
298
- const query = new URLSearchParams({
299
- ...params.project && { project: params.project },
300
- ...params.start_date && { start_date: params.start_date },
301
- ...params.end_date && { end_date: params.end_date }
302
- });
303
- return this.request(`/v1/cost/savings?${query}`);
304
- }
305
- };
306
- var index_default = WhisperContext;
307
- // Annotate the CommonJS export names for ESM import in node:
308
- 0 && (module.exports = {
309
- WhisperContext
310
- });