@maximem/synap-js-sdk 0.2.4 → 1.0.0-beta.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.
Files changed (55) hide show
  1. package/MIGRATING.md +146 -0
  2. package/README.md +96 -83
  3. package/bin/synap-js-sdk.js +45 -122
  4. package/dist/anticipation-cache-BgkqcTPJ.d.cts +180 -0
  5. package/dist/anticipation-cache-BgkqcTPJ.d.ts +180 -0
  6. package/dist/anticipation-cache-D5YHEPV3.js +10 -0
  7. package/dist/anticipation-cache-D5YHEPV3.js.map +1 -0
  8. package/dist/anticipation-cache-JBZHTJ3O.cjs +10 -0
  9. package/dist/anticipation-cache-JBZHTJ3O.cjs.map +1 -0
  10. package/dist/chunk-5SC3ELNK.js +856 -0
  11. package/dist/chunk-5SC3ELNK.js.map +1 -0
  12. package/dist/chunk-HR5Y3KXS.cjs +172 -0
  13. package/dist/chunk-HR5Y3KXS.cjs.map +1 -0
  14. package/dist/chunk-NIDPTBNC.cjs +800 -0
  15. package/dist/chunk-NIDPTBNC.cjs.map +1 -0
  16. package/dist/chunk-QBCVMPGK.js +28 -0
  17. package/dist/chunk-QBCVMPGK.js.map +1 -0
  18. package/dist/chunk-T3NZBIV2.js +172 -0
  19. package/dist/chunk-T3NZBIV2.js.map +1 -0
  20. package/dist/chunk-TCEP5OVR.js +800 -0
  21. package/dist/chunk-TCEP5OVR.js.map +1 -0
  22. package/dist/chunk-VXRCBMCY.cjs +856 -0
  23. package/dist/chunk-VXRCBMCY.cjs.map +1 -0
  24. package/dist/chunk-ZKOJDUN4.cjs +28 -0
  25. package/dist/chunk-ZKOJDUN4.cjs.map +1 -0
  26. package/dist/env-55ULHNJZ.cjs +11 -0
  27. package/dist/env-55ULHNJZ.cjs.map +1 -0
  28. package/dist/env-QCUKKW36.js +11 -0
  29. package/dist/env-QCUKKW36.js.map +1 -0
  30. package/dist/grpc/index.cjs +87 -0
  31. package/dist/grpc/index.cjs.map +1 -0
  32. package/dist/grpc/index.d.cts +162 -0
  33. package/dist/grpc/index.d.ts +162 -0
  34. package/dist/grpc/index.js +87 -0
  35. package/dist/grpc/index.js.map +1 -0
  36. package/dist/index.cjs +2111 -0
  37. package/dist/index.cjs.map +1 -0
  38. package/dist/index.d.cts +1477 -0
  39. package/dist/index.d.ts +1477 -0
  40. package/dist/index.js +2111 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/stream-client-ME5N5NK4.js +7 -0
  43. package/dist/stream-client-ME5N5NK4.js.map +1 -0
  44. package/dist/stream-client-ZN6ADZBR.cjs +7 -0
  45. package/dist/stream-client-ZN6ADZBR.cjs.map +1 -0
  46. package/package.json +68 -19
  47. package/.env.example +0 -39
  48. package/bridge/synap_bridge.py +0 -708
  49. package/src/bridge-manager.js +0 -262
  50. package/src/errors.js +0 -151
  51. package/src/index.js +0 -13
  52. package/src/runtime.js +0 -161
  53. package/src/setup-typescript.js +0 -161
  54. package/src/synap-client.js +0 -363
  55. package/types/index.d.ts +0 -384
package/types/index.d.ts DELETED
@@ -1,384 +0,0 @@
1
- export type LogLevel = 'debug' | 'error';
2
- export type RetrievalMode = 'fast' | 'accurate';
3
- export type IngestMode = 'fast' | 'long-range';
4
- export type PromptStyle = 'structured' | 'narrative' | 'bullet_points';
5
- export type ContextType =
6
- | 'all'
7
- | 'facts'
8
- | 'preferences'
9
- | 'episodes'
10
- | 'emotions'
11
- | 'temporal_events';
12
- export type FlattenedContextType =
13
- | 'fact'
14
- | 'preference'
15
- | 'episode'
16
- | 'emotion'
17
- | 'temporal_event';
18
- export type DocumentType =
19
- | 'ai-chat-conversation'
20
- | 'document'
21
- | 'email'
22
- | 'pdf'
23
- | 'image'
24
- | 'audio'
25
- | 'meeting-transcript';
26
-
27
- export interface BridgeLogHandler {
28
- (level: LogLevel, message: string): void;
29
- }
30
-
31
- export interface SynapClientOptions {
32
- apiKey?: string;
33
- baseUrl?: string;
34
- grpcHost?: string;
35
- grpcPort?: number;
36
- grpcUseTls?: boolean;
37
- pythonBin?: string;
38
- bridgeScriptPath?: string;
39
- sdkHome?: string;
40
- venvPath?: string;
41
- pythonBootstrap?: string;
42
- pythonPackage?: string;
43
- pythonSdkVersion?: string;
44
- noDeps?: boolean;
45
- noBuildIsolation?: boolean;
46
- upgrade?: boolean;
47
- forceRecreateVenv?: boolean;
48
- autoSetup?: boolean;
49
- requestTimeoutMs?: number;
50
- initTimeoutMs?: number;
51
- ingestTimeoutMs?: number;
52
- pythonEnv?: NodeJS.ProcessEnv;
53
- onLog?: BridgeLogHandler;
54
- }
55
-
56
- export interface ChatMessage {
57
- role?: 'user' | 'assistant';
58
- content: string;
59
- metadata?: Record<string, string>;
60
- }
61
-
62
- export interface AddMemoryInput {
63
- userId: string;
64
- customerId: string;
65
- conversationId?: string;
66
- sessionId?: string;
67
- messages: ChatMessage[];
68
- mode?: IngestMode;
69
- documentType?: DocumentType;
70
- documentId?: string;
71
- documentCreatedAt?: string;
72
- metadata?: Record<string, unknown>;
73
- }
74
-
75
- export interface SearchMemoryInput {
76
- userId: string;
77
- customerId?: string;
78
- query: string;
79
- maxResults?: number;
80
- mode?: RetrievalMode;
81
- conversationId?: string;
82
- types?: ContextType[];
83
- }
84
-
85
- export interface GetMemoriesInput {
86
- userId: string;
87
- customerId?: string;
88
- mode?: RetrievalMode;
89
- conversationId?: string;
90
- maxResults?: number;
91
- types?: ContextType[];
92
- }
93
-
94
- export interface DeleteMemoryInput {
95
- userId: string;
96
- customerId?: string;
97
- memoryId?: string | null;
98
- }
99
-
100
- export interface FetchUserContextInput {
101
- userId: string;
102
- customerId?: string;
103
- conversationId?: string;
104
- searchQuery?: string[];
105
- maxResults?: number;
106
- types?: ContextType[];
107
- mode?: RetrievalMode;
108
- }
109
-
110
- export interface FetchCustomerContextInput {
111
- customerId: string;
112
- conversationId?: string;
113
- searchQuery?: string[];
114
- maxResults?: number;
115
- types?: ContextType[];
116
- mode?: RetrievalMode;
117
- }
118
-
119
- export interface FetchClientContextInput {
120
- conversationId?: string;
121
- searchQuery?: string[];
122
- maxResults?: number;
123
- types?: ContextType[];
124
- mode?: RetrievalMode;
125
- }
126
-
127
- export interface GetContextForPromptInput {
128
- conversationId: string;
129
- style?: PromptStyle;
130
- }
131
-
132
- export interface BridgeStepTiming {
133
- step: string;
134
- ms: number;
135
- }
136
-
137
- export interface BridgeTiming {
138
- python_total_ms: number;
139
- steps: BridgeStepTiming[];
140
- }
141
-
142
- export interface TemporalFields {
143
- eventDate: string | null;
144
- validUntil: string | null;
145
- temporalCategory: string | null;
146
- temporalConfidence: number;
147
- }
148
-
149
- export interface Fact extends TemporalFields {
150
- id: string;
151
- content: string;
152
- confidence: number;
153
- source: string;
154
- extractedAt: string | null;
155
- metadata: Record<string, unknown>;
156
- }
157
-
158
- export interface Preference extends TemporalFields {
159
- id: string;
160
- category: string;
161
- content: string;
162
- strength: number;
163
- source: string;
164
- extractedAt: string | null;
165
- metadata: Record<string, unknown>;
166
- }
167
-
168
- export interface Episode extends TemporalFields {
169
- id: string;
170
- summary: string;
171
- occurredAt: string | null;
172
- significance: number;
173
- participants: string[];
174
- metadata: Record<string, unknown>;
175
- }
176
-
177
- export interface Emotion extends TemporalFields {
178
- id: string;
179
- emotionType: string;
180
- intensity: number;
181
- detectedAt: string | null;
182
- context: string;
183
- metadata: Record<string, unknown>;
184
- }
185
-
186
- export interface TemporalEvent {
187
- id: string;
188
- content: string;
189
- eventDate: string | null;
190
- validUntil: string | null;
191
- temporalCategory: string;
192
- temporalConfidence: number;
193
- confidence: number;
194
- source: string;
195
- extractedAt: string | null;
196
- metadata: Record<string, unknown>;
197
- }
198
-
199
- export interface RecentMessage {
200
- role: string;
201
- content: string;
202
- timestamp: string | null;
203
- messageId: string;
204
- }
205
-
206
- export interface ContextResponseMetadata {
207
- correlationId: string;
208
- ttlSeconds: number;
209
- source: string;
210
- retrievedAt: string | null;
211
- compactionApplied: string | null;
212
- }
213
-
214
- export interface ConversationContext {
215
- summary: string | null;
216
- currentState: Record<string, unknown>;
217
- keyExtractions: Record<string, Array<Record<string, unknown>>>;
218
- recentTurns: Array<Record<string, unknown>>;
219
- compactionId: string | null;
220
- compactedAt: string | null;
221
- conversationId: string | null;
222
- }
223
-
224
- export interface ContextResponse {
225
- facts: Fact[];
226
- preferences: Preference[];
227
- episodes: Episode[];
228
- emotions: Emotion[];
229
- temporalEvents: TemporalEvent[];
230
- conversationContext: ConversationContext | null;
231
- metadata: ContextResponseMetadata;
232
- rawResponse: Record<string, unknown>;
233
- bridgeTiming?: BridgeTiming;
234
- }
235
-
236
- export interface ContextForPromptResult {
237
- formattedContext: string | null;
238
- available: boolean;
239
- isStale: boolean;
240
- compressionRatio: number | null;
241
- validationScore: number | null;
242
- compactionAgeSeconds: number | null;
243
- qualityWarning: boolean;
244
- recentMessages: RecentMessage[];
245
- recentMessageCount: number;
246
- compactedMessageCount: number;
247
- totalMessageCount: number;
248
- bridgeTiming?: BridgeTiming;
249
- }
250
-
251
- export interface AddMemoryResult {
252
- success: boolean;
253
- latencyMs: number;
254
- rawResponse: Record<string, unknown>;
255
- note?: string;
256
- bridgeTiming?: BridgeTiming;
257
- }
258
-
259
- export interface SearchMemoryItem extends TemporalFields {
260
- id: string;
261
- memory: string;
262
- score?: number;
263
- source?: string;
264
- metadata: Record<string, unknown>;
265
- contextType?: FlattenedContextType;
266
- }
267
-
268
- export interface SearchMemoryResult {
269
- success: boolean;
270
- latencyMs: number;
271
- results: SearchMemoryItem[];
272
- resultsCount: number;
273
- rawResponse: Record<string, unknown>;
274
- source?: string;
275
- bridgeTiming?: BridgeTiming;
276
- }
277
-
278
- export interface MemoryItem extends SearchMemoryItem {}
279
-
280
- export interface GetMemoriesResult {
281
- success: boolean;
282
- latencyMs: number;
283
- memories: MemoryItem[];
284
- totalCount: number;
285
- rawResponse: Record<string, unknown> | null;
286
- source?: string;
287
- bridgeTiming?: BridgeTiming;
288
- }
289
-
290
- export interface DeleteMemoryResult {
291
- success: boolean;
292
- latencyMs: number;
293
- deletedCount: number;
294
- rawResponse: Record<string, unknown> | null;
295
- note?: string;
296
- bridgeTiming?: BridgeTiming;
297
- }
298
-
299
- export class SynapClient {
300
- constructor(options?: SynapClientOptions);
301
- init(): Promise<void>;
302
- addMemory(input: AddMemoryInput): Promise<AddMemoryResult>;
303
- searchMemory(input: SearchMemoryInput): Promise<SearchMemoryResult>;
304
- getMemories(input: GetMemoriesInput): Promise<GetMemoriesResult>;
305
- fetchUserContext(input: FetchUserContextInput): Promise<ContextResponse>;
306
- fetchCustomerContext(input: FetchCustomerContextInput): Promise<ContextResponse>;
307
- fetchClientContext(input?: FetchClientContextInput): Promise<ContextResponse>;
308
- getContextForPrompt(input: GetContextForPromptInput): Promise<ContextForPromptResult>;
309
- deleteMemory(input: DeleteMemoryInput): Promise<DeleteMemoryResult>;
310
- shutdown(): Promise<void>;
311
- }
312
-
313
- export interface SetupPythonRuntimeOptions {
314
- sdkHome?: string;
315
- venvPath?: string;
316
- pythonBootstrap?: string;
317
- pythonPackage?: string;
318
- pythonSdkVersion?: string;
319
- noDeps?: boolean;
320
- noBuildIsolation?: boolean;
321
- upgrade?: boolean;
322
- forceRecreateVenv?: boolean;
323
- }
324
-
325
- export interface SetupPythonRuntimeResult {
326
- sdkHome: string;
327
- venvPath: string;
328
- pythonBin: string;
329
- pythonPackage: string;
330
- pythonSdkVersion: string | null;
331
- installTarget: string;
332
- }
333
-
334
- export interface SetupTypeScriptExtensionOptions {
335
- projectDir?: string;
336
- packageManager?: 'npm' | 'pnpm' | 'yarn' | 'bun';
337
- skipInstall?: boolean;
338
- tsconfigPath?: string;
339
- wrapperPath?: string;
340
- force?: boolean;
341
- noWrapper?: boolean;
342
- }
343
-
344
- export interface SetupTypeScriptExtensionResult {
345
- projectDir: string;
346
- packageManager: 'npm' | 'pnpm' | 'yarn' | 'bun';
347
- installedDevDependencies: boolean;
348
- tsconfigPath: string;
349
- tsconfigCreated: boolean;
350
- wrapperPath: string | null;
351
- wrapperCreated: boolean;
352
- }
353
-
354
- // Error classes
355
- export class SynapError extends Error {
356
- correlationId: string | null;
357
- constructor(message: string, correlationId?: string);
358
- }
359
- export class SynapTransientError extends SynapError {}
360
- export class SynapPermanentError extends SynapError {}
361
- export class NetworkTimeoutError extends SynapTransientError {}
362
- export class RateLimitError extends SynapTransientError {
363
- retryAfterSeconds: number | null;
364
- constructor(message: string, retryAfterSeconds?: number, correlationId?: string);
365
- }
366
- export class ServiceUnavailableError extends SynapTransientError {}
367
- export class AgentUnavailableError extends SynapTransientError {}
368
- export class InvalidInputError extends SynapPermanentError {}
369
- export class InvalidInstanceIdError extends InvalidInputError {}
370
- export class InvalidConversationIdError extends InvalidInputError {}
371
- export class AuthenticationError extends SynapPermanentError {}
372
- export class ContextNotFoundError extends SynapPermanentError {}
373
- export class SessionExpiredError extends SynapPermanentError {}
374
- export class ListeningAlreadyActiveError extends SynapPermanentError {}
375
- export class ListeningNotActiveError extends SynapPermanentError {}
376
-
377
- export function createClient(options?: SynapClientOptions): SynapClient;
378
- export function resolveInstanceId(explicitInstanceId?: string): string;
379
- export function setupPythonRuntime(
380
- options?: SetupPythonRuntimeOptions
381
- ): Promise<SetupPythonRuntimeResult>;
382
- export function setupTypeScriptExtension(
383
- options?: SetupTypeScriptExtensionOptions
384
- ): Promise<SetupTypeScriptExtensionResult>;