@dreamingai/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.
@@ -0,0 +1,1414 @@
1
+ export interface Memory {
2
+ id: string;
3
+ userId: string;
4
+ appId: string;
5
+ content: string;
6
+ memoryType: string;
7
+ memoryTier: number;
8
+ importance: number;
9
+ confidence: number;
10
+ accessCount: number;
11
+ metadata: Record<string, unknown>;
12
+ createdAt: string;
13
+ lastAccessed?: string;
14
+ }
15
+ export interface MemorySearchResult {
16
+ memory: Memory;
17
+ relevance: number;
18
+ decayScore?: number;
19
+ effectiveScore?: number;
20
+ }
21
+ export interface Entity {
22
+ id: string;
23
+ name: string;
24
+ entityType: string;
25
+ properties: Record<string, unknown>;
26
+ }
27
+ export interface Triple {
28
+ id: string;
29
+ subject: string;
30
+ predicate: string;
31
+ object: string;
32
+ validFrom?: string;
33
+ validTo?: string;
34
+ confidence: number;
35
+ }
36
+ export interface OceanProfile {
37
+ userId: string;
38
+ openness: number;
39
+ conscientiousness: number;
40
+ extraversion: number;
41
+ agreeableness: number;
42
+ neuroticism: number;
43
+ mbtiType?: string;
44
+ confidence: number;
45
+ sampleCount: number;
46
+ }
47
+ export interface LinguisticFingerprint {
48
+ userId: string;
49
+ formality: number;
50
+ vocabRichness: number;
51
+ avgSentenceLength: number;
52
+ emojiUsage: number;
53
+ dominantTone: string;
54
+ }
55
+ export interface SleeptimeInsight {
56
+ id: number;
57
+ type: string;
58
+ content: string;
59
+ createdAt: string;
60
+ }
61
+ export interface PaginatedResponse<T> {
62
+ data: T[];
63
+ total: number;
64
+ offset: number;
65
+ limit: number;
66
+ hasMore: boolean;
67
+ }
68
+ export interface MeterStatus {
69
+ subscriptionTier: string;
70
+ modelTier: 'efficient' | 'smart' | 'genius';
71
+ modelTierName: string;
72
+ modelTierIcon: string;
73
+ modelTierDescription: string;
74
+ primaryModel: string;
75
+ fallbackModel: string;
76
+ maxTokens: number;
77
+ availableTiers: Array<{
78
+ key: string;
79
+ name: string;
80
+ icon: string;
81
+ description: string;
82
+ primaryModel: string;
83
+ }>;
84
+ tierMapping: Record<string, string>;
85
+ usage: {
86
+ callsThisMonth: number;
87
+ tokensThisMonth: number;
88
+ avgLatencyMs: number;
89
+ fallbackRate: string;
90
+ };
91
+ }
92
+ export interface MeterUsage {
93
+ daily: Array<{
94
+ day: string;
95
+ model_tier: string;
96
+ model_used: string;
97
+ calls: number;
98
+ total_tokens_in: number;
99
+ total_tokens_out: number;
100
+ avg_latency: number;
101
+ fallback_count: number;
102
+ }>;
103
+ byFeature: Array<{
104
+ feature: string;
105
+ model_tier: string;
106
+ calls: number;
107
+ total_tokens: number;
108
+ }>;
109
+ }
110
+ export interface DreamingClientConfig {
111
+ apiKey: string;
112
+ appId: string;
113
+ baseUrl?: string;
114
+ timeout?: number;
115
+ }
116
+ declare class HttpClient {
117
+ private baseUrl;
118
+ private headers;
119
+ private timeout;
120
+ constructor(config: DreamingClientConfig);
121
+ request<T>(method: string, path: string, body?: unknown): Promise<T>;
122
+ get<T>(path: string): Promise<T>;
123
+ post<T>(path: string, body?: unknown): Promise<T>;
124
+ patch<T>(path: string, body?: unknown): Promise<T>;
125
+ delete<T>(path: string): Promise<T>;
126
+ }
127
+ export declare class DreamingError extends Error {
128
+ code: string;
129
+ status: number;
130
+ constructor(code: string, message: string, status: number);
131
+ }
132
+ declare class MemoriesClient {
133
+ private http;
134
+ constructor(http: HttpClient);
135
+ create(input: {
136
+ userId: string;
137
+ content: string;
138
+ type?: string;
139
+ importance?: number;
140
+ metadata?: Record<string, unknown>;
141
+ }): Promise<Memory>;
142
+ list(userId: string, options?: {
143
+ limit?: number;
144
+ offset?: number;
145
+ types?: string[];
146
+ }): Promise<PaginatedResponse<Memory>>;
147
+ get(id: string): Promise<Memory>;
148
+ delete(id: string): Promise<{
149
+ success: boolean;
150
+ }>;
151
+ search(input: {
152
+ userId: string;
153
+ query: string;
154
+ limit?: number;
155
+ types?: string[];
156
+ crossApp?: boolean;
157
+ includeDecayScore?: boolean;
158
+ }): Promise<MemorySearchResult[]>;
159
+ recall(input: {
160
+ userId: string;
161
+ query: string;
162
+ limit?: number;
163
+ includeDecayScore?: boolean;
164
+ }): Promise<MemorySearchResult[]>;
165
+ }
166
+ declare class DreamingApiClient {
167
+ private http;
168
+ constructor(http: HttpClient);
169
+ process(input: {
170
+ userId: string;
171
+ conversation: Array<{
172
+ role: string;
173
+ content: string;
174
+ }>;
175
+ }): Promise<{
176
+ queued: number;
177
+ }>;
178
+ consolidate(userId: string): Promise<{
179
+ promoted: number;
180
+ merged: number;
181
+ evicted: number;
182
+ }>;
183
+ getInsights(userId: string, limit?: number): Promise<SleeptimeInsight[]>;
184
+ getStatus(): Promise<Record<string, number>>;
185
+ }
186
+ declare class GraphClient {
187
+ private http;
188
+ constructor(http: HttpClient);
189
+ addEntity(userId: string, name: string, entityType?: string, properties?: Record<string, unknown>): Promise<Entity>;
190
+ addTriple(userId: string, subject: string, predicate: string, object: string, options?: {
191
+ validFrom?: string;
192
+ validTo?: string;
193
+ confidence?: number;
194
+ }): Promise<Triple>;
195
+ query(userId: string, options?: {
196
+ subject?: string;
197
+ predicate?: string;
198
+ object?: string;
199
+ validAt?: string;
200
+ limit?: number;
201
+ }): Promise<Triple[]>;
202
+ getEntityFacts(userId: string, entityName: string): Promise<Triple[]>;
203
+ }
204
+ declare class PersonalityClient {
205
+ private http;
206
+ constructor(http: HttpClient);
207
+ getOcean(userId: string): Promise<OceanProfile>;
208
+ analyzeOcean(userId: string, text: string): Promise<OceanProfile>;
209
+ getFingerprint(userId: string): Promise<LinguisticFingerprint>;
210
+ }
211
+ export type AiState = 'idle' | 'thinking' | 'chatting' | 'creating' | 'learning' | 'dreaming' | 'evolving';
212
+ export interface AiStatus {
213
+ state: AiState;
214
+ detail: string;
215
+ since: number;
216
+ bgProcesses: string[];
217
+ }
218
+ export interface BrainHealth {
219
+ state: string;
220
+ memories: number;
221
+ memoriesWithEmbeddings: number;
222
+ memoryBlocks: number;
223
+ kgEntities: number;
224
+ hasOcean: boolean;
225
+ hasFingerprint: boolean;
226
+ healthy: boolean;
227
+ uptime: number;
228
+ }
229
+ export interface QuotaUsage {
230
+ tier: string;
231
+ memory_entries: number;
232
+ max_memories: number;
233
+ shade_count: number;
234
+ max_shades: number;
235
+ used_bytes: number;
236
+ max_bytes: number;
237
+ storage_used_mb: number;
238
+ storage_limit_mb: number;
239
+ }
240
+ export type ConsentStatus = 'synced' | 'paused' | 'pending' | 'declined';
241
+ export interface SyncSettings {
242
+ userId: string;
243
+ enabled: boolean;
244
+ categories: Record<string, boolean>;
245
+ updatedAt: string;
246
+ }
247
+ export interface SyncConsent {
248
+ id: string;
249
+ domain: string;
250
+ name: string;
251
+ memberCount: number;
252
+ consentStatus: ConsentStatus;
253
+ lastSync: string;
254
+ }
255
+ declare class StatusClient {
256
+ private http;
257
+ constructor(http: HttpClient);
258
+ /** Get current AI cognitive state (for orb rendering) */
259
+ getStatus(userId?: string): Promise<AiStatus>;
260
+ /** Get detailed brain health metrics (for settings page) */
261
+ getBrainHealth(userId?: string): Promise<BrainHealth>;
262
+ /** Get quota usage and limits */
263
+ getQuota(userId?: string): Promise<QuotaUsage>;
264
+ }
265
+ declare class SyncClient {
266
+ private http;
267
+ constructor(http: HttpClient);
268
+ /** Get user's global sync settings */
269
+ getSettings(userId?: string): Promise<SyncSettings>;
270
+ /** Update sync settings (global toggle + category toggles) */
271
+ updateSettings(input: {
272
+ userId?: string;
273
+ enabled?: boolean;
274
+ categories?: Record<string, boolean>;
275
+ }): Promise<SyncSettings>;
276
+ /** Get consent status for all partner workspaces */
277
+ getConsents(userId?: string, appId?: string): Promise<SyncConsent[]>;
278
+ /** Accept, pause, resume, or decline sync with a target workspace */
279
+ updateConsent(input: {
280
+ userId?: string;
281
+ targetWorkspaceId: string;
282
+ action: 'accept' | 'pause' | 'resume' | 'decline';
283
+ domain?: string;
284
+ name?: string;
285
+ }): Promise<SyncConsent>;
286
+ /** Get privacy exposure toggles */
287
+ getExposure(userId?: string, appId?: string): Promise<Record<string, boolean>>;
288
+ /** Update privacy exposure toggles */
289
+ updateExposure(toggles: Record<string, boolean>, userId?: string): Promise<Record<string, boolean>>;
290
+ }
291
+ declare class ContextClient {
292
+ private http;
293
+ constructor(http: HttpClient);
294
+ /** Get pre-built context string for injection into LLM prompts */
295
+ getContext(userId: string): Promise<{
296
+ context: string;
297
+ memories: number;
298
+ personality: string;
299
+ }>;
300
+ /** Before-chat hook: enrich messages with context (for non-middleware integrations) */
301
+ beforeChat(input: {
302
+ userId: string;
303
+ messages: Array<{
304
+ role: string;
305
+ content: string;
306
+ }>;
307
+ }): Promise<Array<{
308
+ role: string;
309
+ content: string;
310
+ }>>;
311
+ /** After-chat hook: queue conversation for sleeptime processing */
312
+ afterChat(input: {
313
+ userId: string;
314
+ messages: Array<{
315
+ role: string;
316
+ content: string;
317
+ }>;
318
+ }): Promise<{
319
+ queued: number;
320
+ }>;
321
+ }
322
+ /** Pre-built UI badge for displaying AI tier in partner apps */
323
+ export interface MeterBadge {
324
+ /** Tier key: 'efficient' | 'smart' | 'genius' */
325
+ tier: string;
326
+ /** Display icon emoji */
327
+ icon: string;
328
+ /** Human-readable label (e.g., "Smart AI") */
329
+ label: string;
330
+ /** CSS-ready hex color for the badge */
331
+ color: string;
332
+ /** Short description of the tier */
333
+ description: string;
334
+ /** Primary model name (for transparency) */
335
+ model: string;
336
+ /** Whether the user can upgrade to a higher tier */
337
+ canUpgrade: boolean;
338
+ /** The next tier name if upgradeable */
339
+ nextTier?: string;
340
+ /** A ready-to-use upgrade CTA message */
341
+ upgradeMessage?: string;
342
+ }
343
+ declare class MeterClient {
344
+ private http;
345
+ constructor(http: HttpClient);
346
+ /** Get current model tier status for the authenticated user */
347
+ getStatus(userId?: string): Promise<MeterStatus>;
348
+ /** Get detailed usage history */
349
+ getUsage(userId: string, options?: {
350
+ days?: number;
351
+ limit?: number;
352
+ }): Promise<MeterUsage>;
353
+ /**
354
+ * Get a ready-to-use UI badge for displaying the AI tier.
355
+ * Partners can drop this directly into their app UI.
356
+ *
357
+ * @example
358
+ * ```tsx
359
+ * const badge = await dreaming.meter.getBadge('user-123');
360
+ * return (
361
+ * <div style={{ background: badge.color, borderRadius: 12, padding: '4px 12px' }}>
362
+ * {badge.icon} {badge.label}
363
+ * </div>
364
+ * );
365
+ * ```
366
+ */
367
+ getBadge(userId?: string): Promise<MeterBadge>;
368
+ /** Quick check: is this user on the highest AI tier? */
369
+ isGeniusTier(userId?: string): Promise<boolean>;
370
+ /** Quick check: can this user upgrade to a better AI tier? */
371
+ canUpgrade(userId?: string): Promise<boolean>;
372
+ /**
373
+ * Get a formatted usage summary string for dashboards.
374
+ *
375
+ * @example
376
+ * ```
377
+ * "🔵 Smart AI — 45 calls, 12.5k tokens this month (avg 230ms)"
378
+ * ```
379
+ */
380
+ getUsageSummary(userId?: string): Promise<string>;
381
+ }
382
+ export declare class DreamingClient {
383
+ readonly memories: MemoriesClient;
384
+ readonly dreaming: DreamingApiClient;
385
+ readonly graph: GraphClient;
386
+ readonly personality: PersonalityClient;
387
+ readonly status: StatusClient;
388
+ readonly sync: SyncClient;
389
+ readonly context: ContextClient;
390
+ readonly meter: MeterClient;
391
+ readonly activities: ActivityClient;
392
+ readonly constraints: ConstraintClient;
393
+ readonly chat: ChatClient;
394
+ readonly knowledge: KnowledgeClient;
395
+ readonly web: WebClient;
396
+ readonly identity: IdentityClient;
397
+ readonly friends: FriendsClient;
398
+ readonly proactive: ProactiveClient;
399
+ readonly notifications: NotificationsClient;
400
+ readonly evolution: EvolutionClient;
401
+ readonly dna: DnaClient;
402
+ readonly partnerTokens: PartnerTokensClient;
403
+ constructor(config: DreamingClientConfig);
404
+ /**
405
+ * Flush any buffered activity events before shutdown.
406
+ * Call this in your app's cleanup/beforeunload handler.
407
+ */
408
+ flush(): Promise<void>;
409
+ }
410
+ export interface KnowledgeDoc {
411
+ docId: string;
412
+ title: string;
413
+ chunkCount: number;
414
+ fileSizeBytes: number;
415
+ format: string;
416
+ domain: string;
417
+ status: string;
418
+ }
419
+ export interface KnowledgeChunk {
420
+ id: number;
421
+ doc_id: string;
422
+ content: string;
423
+ chunk_index: number;
424
+ domain: string;
425
+ topic: string;
426
+ importance: number;
427
+ doc_title?: string;
428
+ relevance?: number;
429
+ }
430
+ export interface KnowledgeModule {
431
+ module_id: string;
432
+ enabled: boolean;
433
+ priority: number;
434
+ doc_count: number;
435
+ chunk_count: number;
436
+ }
437
+ declare class KnowledgeClient {
438
+ private http;
439
+ constructor(http: HttpClient);
440
+ /**
441
+ * Upload a document to the knowledge base.
442
+ * Supports: text, markdown, CSV, JSON, HTML, URL, base64, PDF.
443
+ * Auto-detects format from filename/content if sourceType is 'auto' or omitted.
444
+ *
445
+ * @example
446
+ * ```typescript
447
+ * // Upload markdown
448
+ * await dreaming.knowledge.upload({
449
+ * appId: 'my-app',
450
+ * title: 'Training Guide',
451
+ * content: '# Running Tips\n\nStart slow...',
452
+ * });
453
+ *
454
+ * // Upload CSV data
455
+ * await dreaming.knowledge.upload({
456
+ * appId: 'my-app',
457
+ * title: 'Workout Log',
458
+ * content: 'date,distance,time\n2024-01-01,5km,28min',
459
+ * sourceType: 'csv',
460
+ * });
461
+ *
462
+ * // Upload with constraint auto-linking
463
+ * await dreaming.knowledge.upload({
464
+ * appId: 'my-app',
465
+ * userId: 'user-1',
466
+ * title: 'Fitness Plan',
467
+ * content: pdfBase64,
468
+ * sourceType: 'base64',
469
+ * feedConstraints: true, // Auto-creates tags from content
470
+ * });
471
+ * ```
472
+ */
473
+ upload(options: {
474
+ appId: string;
475
+ title: string;
476
+ content: string;
477
+ userId?: string;
478
+ moduleId?: string;
479
+ sourceType?: string;
480
+ sourceUrl?: string;
481
+ filename?: string;
482
+ scope?: 'app' | 'user';
483
+ feedConstraints?: boolean;
484
+ metadata?: Record<string, unknown>;
485
+ }): Promise<KnowledgeDoc>;
486
+ /**
487
+ * Upload content from a URL. Fetches and parses automatically.
488
+ *
489
+ * @example
490
+ * ```typescript
491
+ * await dreaming.knowledge.uploadUrl({
492
+ * appId: 'my-app',
493
+ * title: 'Running Tips Article',
494
+ * url: 'https://example.com/running-tips',
495
+ * });
496
+ * ```
497
+ */
498
+ uploadUrl(options: {
499
+ appId: string;
500
+ title: string;
501
+ url: string;
502
+ moduleId?: string;
503
+ userId?: string;
504
+ }): Promise<KnowledgeDoc>;
505
+ /** List uploaded documents. */
506
+ listDocs(options?: {
507
+ appId?: string;
508
+ moduleId?: string;
509
+ }): Promise<KnowledgeDoc[]>;
510
+ /** Get document details. */
511
+ getDoc(docId: string): Promise<KnowledgeDoc>;
512
+ /** View chunks of a document. */
513
+ getChunks(docId: string): Promise<KnowledgeChunk[]>;
514
+ /**
515
+ * Search knowledge base with semantic + keyword fallback.
516
+ *
517
+ * @example
518
+ * ```typescript
519
+ * const results = await dreaming.knowledge.search('running tips', {
520
+ * appId: 'active365',
521
+ * limit: 5,
522
+ * domain: 'fitness',
523
+ * });
524
+ * ```
525
+ */
526
+ search(query: string, options: {
527
+ appId: string;
528
+ domain?: string;
529
+ limit?: number;
530
+ }): Promise<KnowledgeChunk[]>;
531
+ /** Delete a document and all its chunks. */
532
+ deleteDoc(docId: string): Promise<void>;
533
+ /**
534
+ * Enable or disable a document (soft toggle).
535
+ * Disabled docs are excluded from search and chat context.
536
+ */
537
+ toggleDoc(docId: string, enabled: boolean): Promise<void>;
538
+ /**
539
+ * List knowledge modules with doc/chunk counts.
540
+ *
541
+ * @example
542
+ * ```typescript
543
+ * const modules = await dreaming.knowledge.listModules('active365');
544
+ * // [{ module_id: 'fitness-guides', enabled: true, doc_count: 3, chunk_count: 45 }]
545
+ * ```
546
+ */
547
+ listModules(appId: string): Promise<KnowledgeModule[]>;
548
+ /**
549
+ * Enable or disable an entire knowledge module.
550
+ * All docs in a disabled module are excluded from search.
551
+ */
552
+ toggleModule(moduleId: string, options: {
553
+ appId: string;
554
+ enabled: boolean;
555
+ }): Promise<void>;
556
+ /**
557
+ * Re-chunk a document with different settings.
558
+ */
559
+ reprocess(docId: string, options?: {
560
+ chunkSize?: number;
561
+ overlap?: number;
562
+ }): Promise<KnowledgeDoc>;
563
+ }
564
+ /** Chat context returned from enrich() */
565
+ export interface ChatContext {
566
+ messages: Array<{
567
+ role: string;
568
+ content: string;
569
+ }>;
570
+ system?: string;
571
+ memories: any[];
572
+ metadata: {
573
+ memoriesUsed: number;
574
+ hasPersonality: boolean;
575
+ hasConstraints: boolean;
576
+ hasKnowledge: boolean;
577
+ appPersona: string | null;
578
+ };
579
+ }
580
+ /** Options for enrich() */
581
+ export interface EnrichOptions {
582
+ maxMemories?: number;
583
+ includePersonality?: boolean;
584
+ includeConstraints?: boolean;
585
+ includeKnowledge?: boolean;
586
+ webGrounding?: boolean;
587
+ format?: 'openai' | 'anthropic' | 'raw';
588
+ }
589
+ /** Options for learn() */
590
+ export interface LearnOptions {
591
+ metadata?: Record<string, unknown>;
592
+ }
593
+ declare class ChatClient {
594
+ private http;
595
+ constructor(http: HttpClient);
596
+ /**
597
+ * BEFORE your LLM call: get memory/personality/goal context.
598
+ *
599
+ * Returns messages you inject into your conversation.
600
+ * Default format is OpenAI-compatible.
601
+ *
602
+ * @example
603
+ * ```typescript
604
+ * const ctx = await dreaming.chat.enrich('user-1', 'How should I train today?');
605
+ *
606
+ * // Inject into your OpenAI call:
607
+ * const response = await openai.chat.completions.create({
608
+ * model: 'gpt-4o',
609
+ * messages: [...ctx.messages, ...yourConversation],
610
+ * });
611
+ * ```
612
+ */
613
+ enrich(userId: string, query: string, options?: EnrichOptions): Promise<ChatContext>;
614
+ /**
615
+ * AFTER your LLM responds: tell Dreaming to extract memories.
616
+ *
617
+ * This queues background tasks: memory extraction, entity detection,
618
+ * insight generation (goal-aware), and personality evolution.
619
+ *
620
+ * @example
621
+ * ```typescript
622
+ * await dreaming.chat.learn('user-1', userMessage, aiResponse);
623
+ * ```
624
+ */
625
+ learn(userId: string, userMessage: string, aiResponse: string, options?: LearnOptions): Promise<{
626
+ learned: boolean;
627
+ jobsQueued: string[];
628
+ }>;
629
+ /**
630
+ * Full conversation version of learn.
631
+ */
632
+ learnFromMessages(userId: string, messages: Array<{
633
+ role: string;
634
+ content: string;
635
+ }>, options?: LearnOptions): Promise<{
636
+ learned: boolean;
637
+ jobsQueued: string[];
638
+ }>;
639
+ /**
640
+ * Wrap an OpenAI client call. Memory + personality + goals, one line.
641
+ *
642
+ * @example
643
+ * ```typescript
644
+ * import OpenAI from 'openai';
645
+ * const openai = new OpenAI();
646
+ * const dreaming = new DreamingClient({ ... });
647
+ *
648
+ * // This one line gives your GPT memory, personality, and goals:
649
+ * const reply = await dreaming.chat.wrapOpenAI(openai, 'user-1', [
650
+ * { role: 'user', content: 'How should I train today?' }
651
+ * ], { model: 'gpt-4o' });
652
+ *
653
+ * console.log(reply); // Goal-aware, memory-enriched response
654
+ * ```
655
+ */
656
+ wrapOpenAI(openai: any, userId: string, messages: Array<{
657
+ role: string;
658
+ content: string;
659
+ }>, options?: {
660
+ model?: string;
661
+ temperature?: number;
662
+ maxTokens?: number;
663
+ }): Promise<string>;
664
+ /**
665
+ * Wrap a Google Gemini call. Memory + personality + goals, one line.
666
+ *
667
+ * @example
668
+ * ```typescript
669
+ * import { GoogleGenerativeAI } from '@google/generative-ai';
670
+ * const genAI = new GoogleGenerativeAI('YOUR_API_KEY');
671
+ * const dreaming = new DreamingClient({ ... });
672
+ *
673
+ * const reply = await dreaming.chat.wrapGemini(genAI, 'user-1',
674
+ * 'How should I train today?',
675
+ * { model: 'gemini-2.0-flash' }
676
+ * );
677
+ * ```
678
+ */
679
+ wrapGemini(genAI: any, userId: string, userMessage: string, options?: {
680
+ model?: string;
681
+ history?: Array<{
682
+ role: string;
683
+ parts: Array<{
684
+ text: string;
685
+ }>;
686
+ }>;
687
+ }): Promise<string>;
688
+ /**
689
+ * Wrap an Anthropic Claude call. Memory + personality + goals, one line.
690
+ *
691
+ * @example
692
+ * ```typescript
693
+ * import Anthropic from '@anthropic-ai/sdk';
694
+ * const anthropic = new Anthropic();
695
+ * const dreaming = new DreamingClient({ ... });
696
+ *
697
+ * const reply = await dreaming.chat.wrapAnthropic(anthropic, 'user-1', [
698
+ * { role: 'user', content: 'How should I train today?' }
699
+ * ], { model: 'claude-sonnet-4-20250514' });
700
+ * ```
701
+ */
702
+ wrapAnthropic(anthropic: any, userId: string, messages: Array<{
703
+ role: string;
704
+ content: string;
705
+ }>, options?: {
706
+ model?: string;
707
+ maxTokens?: number;
708
+ }): Promise<string>;
709
+ /**
710
+ * Generic wrapper for any LLM. You provide the call function.
711
+ *
712
+ * @example
713
+ * ```typescript
714
+ * const reply = await dreaming.chat.wrap(
715
+ * 'user-1',
716
+ * 'How should I train today?',
717
+ * async (systemPrompt, userMsg) => {
718
+ * // Call your LLM however you want
719
+ * return await myCustomLLM.generate(systemPrompt + '\n' + userMsg);
720
+ * }
721
+ * );
722
+ * ```
723
+ */
724
+ wrap(userId: string, userMessage: string, llmCall: (systemPrompt: string, userMessage: string) => Promise<string>, options?: EnrichOptions): Promise<string>;
725
+ }
726
+ /** Constraint types */
727
+ export type ConstraintType = 'goal' | 'sub_goal' | 'task' | 'checkpoint' | 'achievement';
728
+ export type ConstraintStatus = 'active' | 'completed' | 'cancelled' | 'paused' | 'deleted';
729
+ export interface Constraint {
730
+ id: string;
731
+ userId: string;
732
+ appId: string;
733
+ parentId?: string;
734
+ constraintType: ConstraintType;
735
+ title: string;
736
+ description: string;
737
+ status: ConstraintStatus;
738
+ weight: number;
739
+ priority: number;
740
+ category: string;
741
+ domain: string;
742
+ progress: number;
743
+ targetValue?: number;
744
+ currentValue: number;
745
+ unit: string;
746
+ deadline?: string;
747
+ completedAt?: string;
748
+ cancelledAt?: string;
749
+ pinned: boolean;
750
+ createdBy: string;
751
+ tags?: Array<{
752
+ tagKey: string;
753
+ label: string;
754
+ weight: number;
755
+ status: string;
756
+ pinned: boolean;
757
+ }>;
758
+ childCount?: number;
759
+ completedChildren?: number;
760
+ metadata: Record<string, unknown>;
761
+ createdAt: string;
762
+ updatedAt: string;
763
+ }
764
+ export interface ConstraintTag {
765
+ id: string;
766
+ userId: string;
767
+ appId: string;
768
+ tagKey: string;
769
+ label: string;
770
+ category: string;
771
+ weight: number;
772
+ status: string;
773
+ pinned: boolean;
774
+ source: string;
775
+ birthReason: string;
776
+ matchCount: number;
777
+ constraintCount?: number;
778
+ createdAt: string;
779
+ }
780
+ export interface ConstraintContext {
781
+ constraints: Constraint[];
782
+ tags: ConstraintTag[];
783
+ contextString: string;
784
+ totalWeight: number;
785
+ }
786
+ declare class ConstraintClient {
787
+ private http;
788
+ constructor(http: HttpClient);
789
+ /**
790
+ * Create a goal, sub-goal, task, checkpoint, or achievement.
791
+ *
792
+ * @example
793
+ * ```typescript
794
+ * await dreaming.constraints.setGoal('user-1', 'Run 5K under 25min', {
795
+ * category: 'fitness', weight: 90,
796
+ * targetValue: 25, unit: 'min',
797
+ * deadline: '2026-06-01',
798
+ * tags: ['running', 'cardio'],
799
+ * });
800
+ * ```
801
+ */
802
+ setGoal(userId: string, title: string, options?: {
803
+ type?: ConstraintType;
804
+ parentId?: string;
805
+ description?: string;
806
+ weight?: number;
807
+ priority?: number;
808
+ category?: string;
809
+ domain?: string;
810
+ targetValue?: number;
811
+ unit?: string;
812
+ deadline?: string;
813
+ pinned?: boolean;
814
+ tags?: string[];
815
+ metadata?: Record<string, unknown>;
816
+ }): Promise<Constraint>;
817
+ /** Create a sub-goal under a parent goal */
818
+ addSubGoal(userId: string, parentId: string, title: string, options?: Parameters<ConstraintClient['setGoal']>[2]): Promise<Constraint>;
819
+ /** Create a task under a goal or sub-goal */
820
+ addTask(userId: string, parentId: string, title: string, options?: Parameters<ConstraintClient['setGoal']>[2]): Promise<Constraint>;
821
+ /** Create a checkpoint (milestone) */
822
+ addCheckpoint(userId: string, parentId: string, title: string, options?: Parameters<ConstraintClient['setGoal']>[2]): Promise<Constraint>;
823
+ /** Record an achievement */
824
+ addAchievement(userId: string, title: string, options?: Parameters<ConstraintClient['setGoal']>[2]): Promise<Constraint>;
825
+ /**
826
+ * List constraints with optional filters.
827
+ */
828
+ list(userId: string, options?: {
829
+ type?: ConstraintType;
830
+ status?: ConstraintStatus | 'all';
831
+ category?: string;
832
+ parentId?: string;
833
+ pinned?: boolean;
834
+ }): Promise<Constraint[]>;
835
+ /**
836
+ * Update a constraint's weight, status, progress, or other fields.
837
+ *
838
+ * @example
839
+ * ```typescript
840
+ * // Update progress
841
+ * await dreaming.constraints.update(goalId, { progress: 75 });
842
+ *
843
+ * // Change weight (influences how much AI focuses on this)
844
+ * await dreaming.constraints.update(goalId, { weight: 30 });
845
+ *
846
+ * // Complete a goal
847
+ * await dreaming.constraints.update(goalId, { status: 'completed' });
848
+ * ```
849
+ */
850
+ update(constraintId: string, updates: {
851
+ title?: string;
852
+ description?: string;
853
+ status?: ConstraintStatus;
854
+ weight?: number;
855
+ priority?: number;
856
+ category?: string;
857
+ progress?: number;
858
+ currentValue?: number;
859
+ targetValue?: number;
860
+ deadline?: string;
861
+ pinned?: boolean;
862
+ reason?: string;
863
+ metadata?: Record<string, unknown>;
864
+ }): Promise<Constraint>;
865
+ /** Complete a constraint */
866
+ complete(constraintId: string): Promise<Constraint>;
867
+ /** Cancel a constraint */
868
+ cancel(constraintId: string, reason?: string): Promise<Constraint>;
869
+ /** Pause a constraint (keeps weight but AI won't actively suggest) */
870
+ pause(constraintId: string): Promise<Constraint>;
871
+ /** Resume a paused constraint */
872
+ resume(constraintId: string): Promise<Constraint>;
873
+ /** Pin a constraint (locks it from fading) */
874
+ pin(constraintId: string): Promise<Constraint>;
875
+ /** Unpin a constraint */
876
+ unpin(constraintId: string): Promise<Constraint>;
877
+ /** Set the weight (0-100) — how much the AI focuses on this */
878
+ setWeight(constraintId: string, weight: number, reason?: string): Promise<Constraint>;
879
+ /** Delete a constraint (soft delete) */
880
+ delete(constraintId: string): Promise<void>;
881
+ /** Get change history for a constraint */
882
+ getHistory(constraintId: string): Promise<Array<{
883
+ changeType: string;
884
+ oldValue: string;
885
+ newValue: string;
886
+ reason: string;
887
+ createdAt: string;
888
+ }>>;
889
+ /**
890
+ * Create or update a focus tag.
891
+ *
892
+ * @example
893
+ * ```typescript
894
+ * await dreaming.constraints.addTag('user-1', 'mindfulness', {
895
+ * category: 'wellness', weight: 70, pinned: true,
896
+ * });
897
+ * ```
898
+ */
899
+ addTag(userId: string, tagKey: string, options?: {
900
+ label?: string;
901
+ category?: string;
902
+ weight?: number;
903
+ pinned?: boolean;
904
+ birthReason?: string;
905
+ }): Promise<ConstraintTag>;
906
+ /** List tags */
907
+ listTags(userId: string, options?: {
908
+ status?: string;
909
+ category?: string;
910
+ pinned?: boolean;
911
+ }): Promise<ConstraintTag[]>;
912
+ /** Update a tag (weight, pin, category) */
913
+ updateTag(tagId: string, updates: {
914
+ weight?: number;
915
+ pinned?: boolean;
916
+ status?: string;
917
+ category?: string;
918
+ label?: string;
919
+ }): Promise<ConstraintTag>;
920
+ /** Pin a tag */
921
+ pinTag(tagId: string): Promise<ConstraintTag>;
922
+ /** Set tag weight */
923
+ setTagWeight(tagId: string, weight: number): Promise<ConstraintTag>;
924
+ /**
925
+ * Get the weighted constraint context that the AI uses.
926
+ * Shows exactly how constraints + tags influence dreaming.
927
+ */
928
+ getContext(userId: string): Promise<ConstraintContext>;
929
+ }
930
+ /** A single activity event to track */
931
+ export interface ActivityEvent {
932
+ userId: string;
933
+ /** Category of activity: 'screen_view', 'button_click', 'feature_use', 'gesture', etc. */
934
+ activityType: string;
935
+ /** Specific name: 'ProductDetail', 'AddToCart', 'SearchQuery', etc. */
936
+ activityName: string;
937
+ /** Life domain: 'fitness', 'shopping', 'finance', 'social', etc. */
938
+ domain?: string;
939
+ /** Arbitrary data payload */
940
+ data?: Record<string, unknown>;
941
+ /** Duration in ms (for timed activities like screen dwell time) */
942
+ durationMs?: number;
943
+ /** Session ID (auto-generated if not provided) */
944
+ sessionId?: string;
945
+ }
946
+ /** Activity summary for a time period */
947
+ export interface ActivitySummary {
948
+ activityType: string;
949
+ activityName: string;
950
+ count: number;
951
+ totalDurationMs: number;
952
+ lastAt: string;
953
+ }
954
+ /** Configuration for the activity buffer */
955
+ export interface ActivityBufferConfig {
956
+ /** Max events to buffer before auto-flush (default: 20) */
957
+ bufferSize?: number;
958
+ /** Auto-flush interval in ms (default: 5000 = 5 seconds) */
959
+ flushIntervalMs?: number;
960
+ /** Disable auto-flush (for manual control) */
961
+ disableAutoFlush?: boolean;
962
+ }
963
+ declare class ActivityClient {
964
+ private http;
965
+ private buffer;
966
+ private flushTimer;
967
+ private sessionId;
968
+ private bufferSize;
969
+ private isFlushing;
970
+ constructor(http: HttpClient, config: DreamingClientConfig & {
971
+ activityBuffer?: ActivityBufferConfig;
972
+ });
973
+ /**
974
+ * Track a user activity event — SYNCHRONOUS, zero overhead.
975
+ * Events are queued locally and flushed as a batch automatically.
976
+ *
977
+ * @example
978
+ * ```typescript
979
+ * // Track a screen view
980
+ * dreaming.activities.track('user-123', 'screen_view', 'Dashboard');
981
+ *
982
+ * // Track a feature interaction with data
983
+ * dreaming.activities.track('user-123', 'feature_use', 'AIChat', {
984
+ * domain: 'productivity',
985
+ * data: { messageCount: 5, topic: 'project planning' },
986
+ * durationMs: 45000,
987
+ * });
988
+ *
989
+ * // Track a button click
990
+ * dreaming.activities.track('user-123', 'button_click', 'UpgradeToProBtn', {
991
+ * domain: 'billing',
992
+ * });
993
+ * ```
994
+ */
995
+ track(userId: string, activityType: string, activityName: string, options?: Omit<ActivityEvent, 'userId' | 'activityType' | 'activityName'>): void;
996
+ /**
997
+ * Flush buffered events to the server.
998
+ * Called automatically by the timer/buffer-full, but you can call manually.
999
+ */
1000
+ flush(): Promise<number>;
1001
+ /**
1002
+ * Query activity history for a user.
1003
+ */
1004
+ getHistory(userId: string, options?: {
1005
+ type?: string;
1006
+ domain?: string;
1007
+ days?: number;
1008
+ limit?: number;
1009
+ }): Promise<{
1010
+ data: ActivityEvent[];
1011
+ summary: ActivitySummary[];
1012
+ total: number;
1013
+ }>;
1014
+ /** Get the current auto-generated session ID */
1015
+ getSessionId(): string;
1016
+ /** Start a new session (generates a new session ID) */
1017
+ newSession(): string;
1018
+ /** Get the number of buffered (unflushed) events */
1019
+ get pendingCount(): number;
1020
+ /** Stop the auto-flush timer (call before app shutdown after flush) */
1021
+ destroy(): void;
1022
+ }
1023
+ export interface WebSearchResult {
1024
+ title: string;
1025
+ url: string;
1026
+ content: string;
1027
+ description?: string;
1028
+ publishedDate?: string;
1029
+ source: string;
1030
+ }
1031
+ export interface WebCrawlResult {
1032
+ url: string;
1033
+ content: string;
1034
+ title?: string;
1035
+ description?: string;
1036
+ source: string;
1037
+ length: number;
1038
+ }
1039
+ export interface WebAccessPolicy {
1040
+ enabled: boolean;
1041
+ maxDailySearches: number;
1042
+ allowedCategories: string[];
1043
+ blockedDomains: string[];
1044
+ requireRelevance: boolean;
1045
+ }
1046
+ export interface WebDailyUsage {
1047
+ appId: string;
1048
+ date: string;
1049
+ searchCount: number;
1050
+ crawlCount: number;
1051
+ tokensUsed: number;
1052
+ }
1053
+ declare class WebClient {
1054
+ private http;
1055
+ constructor(http: HttpClient);
1056
+ /**
1057
+ * Search the web. Respects DNA guardrails (must be enabled for the app).
1058
+ * Results are cached for 24h.
1059
+ *
1060
+ * @example
1061
+ * ```typescript
1062
+ * const results = await dreaming.web.search('5K running tips', {
1063
+ * appId: 'active365',
1064
+ * limit: 5,
1065
+ * });
1066
+ * ```
1067
+ */
1068
+ search(query: string, options: {
1069
+ appId: string;
1070
+ limit?: number;
1071
+ format?: 'results' | 'prompt';
1072
+ skipCache?: boolean;
1073
+ }): Promise<WebSearchResult[]>;
1074
+ /**
1075
+ * Search and return formatted system prompt (for direct LLM injection).
1076
+ */
1077
+ searchForPrompt(query: string, appId: string): Promise<string>;
1078
+ /** Crawl a specific URL for content. */
1079
+ crawl(url: string, appId: string): Promise<WebCrawlResult | null>;
1080
+ /** Get the web access policy for an app. */
1081
+ getPolicy(appId: string): Promise<WebAccessPolicy>;
1082
+ /**
1083
+ * Update web access policy.
1084
+ *
1085
+ * @example
1086
+ * ```typescript
1087
+ * await dreaming.web.updatePolicy('active365', {
1088
+ * enabled: true,
1089
+ * maxDailySearches: 100,
1090
+ * blockedDomains: ['facebook.com'],
1091
+ * });
1092
+ * ```
1093
+ */
1094
+ updatePolicy(appId: string, policy: Partial<WebAccessPolicy>): Promise<WebAccessPolicy>;
1095
+ /** Get daily web usage stats for budget monitoring. */
1096
+ getUsage(appId: string, date?: string): Promise<WebDailyUsage>;
1097
+ /** Get user dreaming settings (all toggles). */
1098
+ getSettings(userId: string, appId?: string): Promise<Record<string, boolean>>;
1099
+ /** Update user dreaming settings (toggle features on/off). */
1100
+ updateSettings(userId: string, settings: Record<string, boolean>, appId?: string): Promise<Record<string, boolean>>;
1101
+ }
1102
+ export interface UserIdentity {
1103
+ userId: string;
1104
+ appId: string;
1105
+ userDisplayName: string;
1106
+ userPreferredName: string;
1107
+ userFullName: string;
1108
+ aiName: string;
1109
+ aiDefaultName: string;
1110
+ source: string;
1111
+ syncToHq: boolean;
1112
+ syncFromHq: boolean;
1113
+ effectiveAiName?: string;
1114
+ effectiveUserName?: string;
1115
+ }
1116
+ export interface SocialPerson {
1117
+ id: string;
1118
+ userId: string;
1119
+ appId: string;
1120
+ personName: string;
1121
+ relationship: string;
1122
+ relationshipDetail: string;
1123
+ nickname: string;
1124
+ status: string;
1125
+ mentionCount: number;
1126
+ sentiment: number;
1127
+ isCrossApp: boolean;
1128
+ source: string;
1129
+ }
1130
+ declare class IdentityClient {
1131
+ private http;
1132
+ constructor(http: HttpClient);
1133
+ /** Get user identity (names, AI name, sync status). */
1134
+ get(userId: string, appId?: string): Promise<UserIdentity>;
1135
+ /** Update user identity (display name, preferred name, etc). */
1136
+ update(userId: string, appId: string, updates: Partial<UserIdentity>): Promise<UserIdentity>;
1137
+ /** Get the effective AI name for this user in this app. */
1138
+ getAiName(userId: string, appId?: string): Promise<string>;
1139
+ /** Set a custom AI name (user-chosen or partner default). */
1140
+ setAiName(userId: string, appId: string, aiName: string, isPartnerDefault?: boolean): Promise<string>;
1141
+ /** Get people the user knows (family, friends, colleagues). */
1142
+ getSocialCircle(userId: string, appId?: string, relationship?: string): Promise<SocialPerson[]>;
1143
+ /** Add a person to the user's social circle. */
1144
+ addPerson(userId: string, appId: string, person: {
1145
+ name: string;
1146
+ relationship: string;
1147
+ relationshipDetail?: string;
1148
+ nickname?: string;
1149
+ sentiment?: number;
1150
+ }): Promise<SocialPerson>;
1151
+ /** Sync identity from HQ to a partner app. */
1152
+ syncFromHq(userId: string, appId: string): Promise<UserIdentity>;
1153
+ }
1154
+ export interface FriendConnection {
1155
+ id: string;
1156
+ user_a_id: string;
1157
+ user_b_id: string;
1158
+ status: string;
1159
+ connection_type: string;
1160
+ trust_level: number;
1161
+ interaction_count: number;
1162
+ friend_user_id?: string;
1163
+ shared_count?: number;
1164
+ exchange_count?: number;
1165
+ }
1166
+ export interface SharedMemory {
1167
+ id: number;
1168
+ connection_id: string;
1169
+ source_user_id: string;
1170
+ content: string;
1171
+ domain: string;
1172
+ memory_type: string;
1173
+ importance: number;
1174
+ }
1175
+ declare class FriendsClient {
1176
+ private http;
1177
+ constructor(http: HttpClient);
1178
+ /** Send a friend request. */
1179
+ request(userId: string, friendUserId: string, options?: {
1180
+ connectionType?: string;
1181
+ sharedDomains?: string[];
1182
+ message?: string;
1183
+ }): Promise<FriendConnection>;
1184
+ /** Accept a friend connection. */
1185
+ accept(connectionId: string, options?: {
1186
+ sharedDomains?: string[];
1187
+ autoCommunicate?: boolean;
1188
+ }): Promise<FriendConnection>;
1189
+ /** Reject or block a connection. */
1190
+ reject(connectionId: string, block?: boolean): Promise<void>;
1191
+ /** List all connections for a user. */
1192
+ list(userId: string): Promise<FriendConnection[]>;
1193
+ /** Get connection details. */
1194
+ get(connectionId: string): Promise<FriendConnection>;
1195
+ /** Trigger an AI-to-AI exchange. */
1196
+ exchange(connectionId: string, topic?: string, maxRounds?: number): Promise<{
1197
+ connectionId: string;
1198
+ exchangeRounds: number;
1199
+ exchanges: any[];
1200
+ trustLevel: number;
1201
+ }>;
1202
+ /** Get exchange conversation history. */
1203
+ conversations(connectionId: string, limit?: number): Promise<any[]>;
1204
+ /** Get shared memories for a connection. */
1205
+ sharedMemories(connectionId: string, limit?: number): Promise<SharedMemory[]>;
1206
+ /** Share a specific memory with a friend. */
1207
+ shareMemory(connectionId: string, userId: string, content: string, domain?: string, importance?: number): Promise<SharedMemory>;
1208
+ /** Update connection settings. */
1209
+ update(connectionId: string, settings: {
1210
+ userId?: string;
1211
+ autoCommunicate?: boolean;
1212
+ communicationFreq?: string;
1213
+ connectionType?: string;
1214
+ sharedDomains?: string[];
1215
+ }): Promise<void>;
1216
+ }
1217
+ export interface ProactiveSuggestion {
1218
+ id: number;
1219
+ userId: string;
1220
+ appId: string;
1221
+ type: string;
1222
+ content: string;
1223
+ priority: number;
1224
+ trigger: string;
1225
+ createdAt: string;
1226
+ }
1227
+ declare class ProactiveClient {
1228
+ private http;
1229
+ constructor(http: HttpClient);
1230
+ /** Trigger proactive evaluation for a user. */
1231
+ evaluate(userId: string, appId?: string): Promise<{
1232
+ triggered: boolean;
1233
+ suggestion?: ProactiveSuggestion;
1234
+ }>;
1235
+ /** Get pending proactive suggestions. */
1236
+ getSuggestions(userId: string, appId?: string, limit?: number): Promise<ProactiveSuggestion[]>;
1237
+ /** Dismiss a proactive suggestion. */
1238
+ dismiss(suggestionId: number | string): Promise<void>;
1239
+ }
1240
+ export interface NotificationPrefs {
1241
+ channel: string;
1242
+ pushToken: string;
1243
+ pushPlatform: string;
1244
+ quietStart: string;
1245
+ quietEnd: string;
1246
+ maxDaily: number;
1247
+ enabled: boolean;
1248
+ }
1249
+ export interface BehaviorSignal {
1250
+ id: number;
1251
+ userId: string;
1252
+ signalType: string;
1253
+ value: number;
1254
+ context: Record<string, unknown>;
1255
+ createdAt: string;
1256
+ }
1257
+ declare class NotificationsClient {
1258
+ private http;
1259
+ constructor(http: HttpClient);
1260
+ /** Mark notifications as read. */
1261
+ markRead(ids: (number | string)[]): Promise<void>;
1262
+ /** Act on a proactive suggestion. */
1263
+ act(suggestionId: number | string, action: string): Promise<any>;
1264
+ /** Get notification preferences. */
1265
+ getPrefs(userId: string, appId?: string): Promise<NotificationPrefs>;
1266
+ /** Update notification preferences. */
1267
+ updatePrefs(userId: string, prefs: Partial<NotificationPrefs>, appId?: string): Promise<NotificationPrefs>;
1268
+ /** Register a push notification token. */
1269
+ registerPushToken(userId: string, token: string, platform: 'ios' | 'android' | 'web', appId?: string): Promise<void>;
1270
+ /** Get behavior timeline (activity/mood history). */
1271
+ getTimeline(userId: string, options?: {
1272
+ days?: number;
1273
+ limit?: number;
1274
+ }): Promise<any[]>;
1275
+ /** Get behavior signals. */
1276
+ getSignals(userId: string, type?: string): Promise<BehaviorSignal[]>;
1277
+ /** Get behavior summary. */
1278
+ getSummary(userId: string): Promise<any>;
1279
+ }
1280
+ export interface LifeDomain {
1281
+ id: string;
1282
+ userId: string;
1283
+ name: string;
1284
+ category: string;
1285
+ importance: number;
1286
+ progress: number;
1287
+ status: string;
1288
+ }
1289
+ export interface AppFeature {
1290
+ id: string;
1291
+ appId: string;
1292
+ featureName: string;
1293
+ category: string;
1294
+ description: string;
1295
+ }
1296
+ declare class EvolutionClient {
1297
+ private http;
1298
+ constructor(http: HttpClient);
1299
+ /** Track a single activity event. */
1300
+ trackActivity(activity: {
1301
+ userId: string;
1302
+ appId?: string;
1303
+ activityType: string;
1304
+ category?: string;
1305
+ duration?: number;
1306
+ intensity?: number;
1307
+ metadata?: Record<string, unknown>;
1308
+ }): Promise<any>;
1309
+ /** Track a batch of activities. */
1310
+ trackBatch(activities: Array<{
1311
+ userId: string;
1312
+ appId?: string;
1313
+ activityType: string;
1314
+ category?: string;
1315
+ duration?: number;
1316
+ metadata?: Record<string, unknown>;
1317
+ }>): Promise<{
1318
+ inserted: number;
1319
+ }>;
1320
+ /** Get activity history. */
1321
+ getActivities(userId: string, options?: {
1322
+ category?: string;
1323
+ limit?: number;
1324
+ days?: number;
1325
+ }): Promise<any[]>;
1326
+ /** Get user's life domains. */
1327
+ getDomains(userId: string): Promise<LifeDomain[]>;
1328
+ /** Create a life domain. */
1329
+ createDomain(domain: {
1330
+ userId: string;
1331
+ name: string;
1332
+ category?: string;
1333
+ importance?: number;
1334
+ }): Promise<LifeDomain>;
1335
+ /** Update domain progress. */
1336
+ updateProgress(domainId: string, progress: number, note?: string): Promise<any>;
1337
+ /** Get domain progress history. */
1338
+ getDomainHistory(domainId: string, limit?: number): Promise<any[]>;
1339
+ /** Register an app feature. */
1340
+ registerFeature(appId: string, feature: {
1341
+ featureName: string;
1342
+ category?: string;
1343
+ description?: string;
1344
+ }): Promise<AppFeature>;
1345
+ /** Emit an app event. */
1346
+ emitEvent(appId: string, event: {
1347
+ eventType: string;
1348
+ userId?: string;
1349
+ payload?: Record<string, unknown>;
1350
+ }): Promise<any>;
1351
+ /** Get app context (features, recent events). */
1352
+ getAppContext(appId: string, userId?: string): Promise<any>;
1353
+ /** Get or set user state (mood, role, context). */
1354
+ getUserState(userId: string): Promise<any>;
1355
+ /** Update user state. */
1356
+ setUserState(userId: string, state: Record<string, unknown>): Promise<any>;
1357
+ }
1358
+ export interface AppDna {
1359
+ appId: string;
1360
+ appName: string;
1361
+ discipline: string;
1362
+ personaName: string;
1363
+ boundaries: string;
1364
+ defaultDomains: string[];
1365
+ rootKnowledge: string[];
1366
+ webAccess: Record<string, unknown>;
1367
+ }
1368
+ declare class DnaClient {
1369
+ private http;
1370
+ constructor(http: HttpClient);
1371
+ /** Get app DNA configuration. */
1372
+ get(appId: string): Promise<AppDna>;
1373
+ /** Register or update app DNA. */
1374
+ update(appId: string, dna: Partial<AppDna>): Promise<AppDna>;
1375
+ /** Seed a new user's brain with app defaults. */
1376
+ seedUser(appId: string, userId: string): Promise<any>;
1377
+ /** List all registered apps. */
1378
+ listApps(): Promise<AppDna[]>;
1379
+ }
1380
+ export interface PartnerToken {
1381
+ id: string;
1382
+ name: string;
1383
+ key: string;
1384
+ status: number;
1385
+ quotaLimit: number;
1386
+ usedQuota: number;
1387
+ expiresAt?: string;
1388
+ }
1389
+ declare class PartnerTokensClient {
1390
+ private http;
1391
+ constructor(http: HttpClient);
1392
+ /** Create a child token. */
1393
+ create(options: {
1394
+ name: string;
1395
+ quotaLimit?: number;
1396
+ models?: string[];
1397
+ expiresIn?: string;
1398
+ group?: string;
1399
+ }): Promise<PartnerToken>;
1400
+ /** List partner's tokens. */
1401
+ list(): Promise<PartnerToken[]>;
1402
+ /** Revoke a token. */
1403
+ revoke(tokenId: string): Promise<void>;
1404
+ /** Update token settings. */
1405
+ update(tokenId: string, updates: Partial<{
1406
+ quotaLimit: number;
1407
+ group: string;
1408
+ expiresAt: string;
1409
+ }>): Promise<PartnerToken>;
1410
+ /** Get token usage stats. */
1411
+ getUsage(tokenId: string): Promise<any>;
1412
+ }
1413
+ export default DreamingClient;
1414
+ //# sourceMappingURL=index.d.ts.map