@maximem/synap-js-sdk 0.5.4 → 0.5.6

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/dist/index.d.cts CHANGED
@@ -60,6 +60,11 @@ declare const ENDPOINTS: {
60
60
  readonly path: "/api/v1/memories/{memory_id}";
61
61
  readonly idempotent: true;
62
62
  };
63
+ readonly memories_forget: {
64
+ readonly method: "POST";
65
+ readonly path: "/api/v1/memories/forget";
66
+ readonly idempotent: false;
67
+ };
63
68
  readonly context_fetch_user: {
64
69
  readonly method: "POST";
65
70
  readonly path: "/v1/context/user/fetch";
@@ -372,6 +377,12 @@ interface RawContextItem {
372
377
  valid_until?: string | null;
373
378
  temporal_category?: string | null;
374
379
  temporal_confidence?: number;
380
+ /**
381
+ * The search queries of the fetch that found this item, in the order they
382
+ * were sent. Absent from a server that predates the field, and on an item
383
+ * served from the prefetch cache.
384
+ */
385
+ matched_queries?: string[];
375
386
  [key: string]: unknown;
376
387
  }
377
388
  interface RawConversationContext {
@@ -402,7 +413,15 @@ interface TemporalFields {
402
413
  temporalCategory: string | null;
403
414
  temporalConfidence: number;
404
415
  }
405
- interface Fact extends TemporalFields {
416
+ /**
417
+ * Which of the fetch's search queries found an item. A fetch can carry several
418
+ * and returns one set for all of them. Always an array: empty when the fetch
419
+ * named no query or the server predates the field.
420
+ */
421
+ interface QueryAttribution {
422
+ matchedQueries: string[];
423
+ }
424
+ interface Fact extends TemporalFields, QueryAttribution {
406
425
  id: string;
407
426
  content: string;
408
427
  confidence: number;
@@ -410,7 +429,7 @@ interface Fact extends TemporalFields {
410
429
  extractedAt: string | null;
411
430
  metadata: Json;
412
431
  }
413
- interface Preference extends TemporalFields {
432
+ interface Preference extends TemporalFields, QueryAttribution {
414
433
  id: string;
415
434
  category: string;
416
435
  content: string;
@@ -419,7 +438,7 @@ interface Preference extends TemporalFields {
419
438
  extractedAt: string | null;
420
439
  metadata: Json;
421
440
  }
422
- interface Episode extends TemporalFields {
441
+ interface Episode extends TemporalFields, QueryAttribution {
423
442
  id: string;
424
443
  summary: string;
425
444
  occurredAt: string | null;
@@ -427,7 +446,7 @@ interface Episode extends TemporalFields {
427
446
  participants: unknown[];
428
447
  metadata: Json;
429
448
  }
430
- interface Emotion extends TemporalFields {
449
+ interface Emotion extends TemporalFields, QueryAttribution {
431
450
  id: string;
432
451
  emotionType: string;
433
452
  intensity: number;
@@ -435,7 +454,7 @@ interface Emotion extends TemporalFields {
435
454
  context: string;
436
455
  metadata: Json;
437
456
  }
438
- interface TemporalEvent {
457
+ interface TemporalEvent extends QueryAttribution {
439
458
  id: string;
440
459
  content: string;
441
460
  eventDate: string | null;
@@ -516,6 +535,18 @@ interface FetchOptions {
516
535
  */
517
536
  query_date?: string;
518
537
  queryDate?: string;
538
+ /**
539
+ * How many items each search query may contribute when `search_query` holds
540
+ * more than one, so a query with many strong matches cannot take every
541
+ * place. `max_results` stays the ceiling on the whole response: three
542
+ * queries at five each under `max_results: 10` return ten.
543
+ *
544
+ * Sent only when provided, like `query_date`. Left out, or with one query,
545
+ * the response is the best `max_results` items overall, as before. `0` is
546
+ * treated as left out.
547
+ */
548
+ max_results_per_query?: number;
549
+ maxResultsPerQuery?: number;
519
550
  /** Sent only when explicitly false, matching the Python controllers. */
520
551
  include_conversation_context?: boolean;
521
552
  /**
@@ -664,6 +695,44 @@ interface BatchCreateOptions {
664
695
  fail_fast?: boolean;
665
696
  failFast?: boolean;
666
697
  }
698
+ /** Mirrors the Python ForgetMode enum. */
699
+ declare const FORGET_MODES: readonly ["preview", "direct"];
700
+ type ForgetMode = (typeof FORGET_MODES)[number];
701
+ interface ForgetOptions {
702
+ /** What to forget, in the user's own words (3 to 500 characters). */
703
+ description: string;
704
+ user_id?: string | null;
705
+ userId?: string | null;
706
+ customer_id?: string | null;
707
+ customerId?: string | null;
708
+ /**
709
+ * The level to search, named in full, one entry per level down to it:
710
+ * `{ customer: "acme", team: "payments", user: "dana" }`. Only needed when
711
+ * your scope ladder has a level between customer and user.
712
+ */
713
+ scope?: Record<string, string> | null;
714
+ /** `"preview"` (default) or `"direct"`. See `MemoriesInterface.forget`. */
715
+ mode?: ForgetMode | string;
716
+ }
717
+ /** A memory the description matched. Mirrors Python's `ForgetCandidate`. */
718
+ interface ForgetCandidate {
719
+ memory_id: string;
720
+ content: string;
721
+ memory_type?: string | null;
722
+ /** `"memory"`, or where a copy lives: chunk, sentence, entity, triple, profile, candidate. */
723
+ store?: string;
724
+ }
725
+ type ForgetStatus = 'nothing_matches' | 'preview' | 'deleted' | 'partial';
726
+ /** Result of `memories.forget`. Mirrors Python's `ForgetResponse`. */
727
+ interface ForgetResult {
728
+ status: ForgetStatus;
729
+ request_id: string | null;
730
+ candidates: ForgetCandidate[];
731
+ deleted_ids: string[];
732
+ failed_ids: string[];
733
+ still_present_in: string[];
734
+ may_be_incomplete: boolean;
735
+ }
667
736
  interface MemoriesInterface {
668
737
  create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
669
738
  batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
@@ -671,6 +740,35 @@ interface MemoriesInterface {
671
740
  get(memoryId: string): Promise<Json>;
672
741
  update(options: UpdateMemoryOptions): Promise<Json>;
673
742
  delete(memoryId: string): Promise<Json>;
743
+ /**
744
+ * Forget memories by describing them in the user's own words. Use it when
745
+ * you do not hold memory ids; to delete one memory by id, use `delete()`.
746
+ *
747
+ * The call must be scoped to exactly one user: pass `user_id`, plus
748
+ * `customer_id` on a B2B instance. Otherwise the server answers 400, raised
749
+ * as `InvalidInputError`.
750
+ *
751
+ * Modes:
752
+ * - `"preview"` (default): files a pending request that a person approves in
753
+ * the dashboard under Deletion requests. Deletes nothing. `candidates`
754
+ * lists what matched.
755
+ * - `"direct"`: finds and soft-deletes in one call. Not idempotent as a
756
+ * request: a repeat is harmless and finds nothing new, but it is a new
757
+ * request.
758
+ *
759
+ * `status` is `"nothing_matches"`, `"preview"`, `"deleted"` or `"partial"`.
760
+ * `"partial"` means the memories are hidden but a store named in
761
+ * `still_present_in` may still hold the text, so do not tell an end user it
762
+ * was removed unless `status === "deleted"`. `failed_ids` lists memories that
763
+ * could not be deleted; `may_be_incomplete` is true when the match may not
764
+ * have covered everything.
765
+ *
766
+ * Errors: `InvalidInputError` for 400/422 or a bad `description`/`mode`
767
+ * caught before sending; `ServiceUnavailableError` for 503 (the matcher was
768
+ * unavailable and nothing was deleted, so trying again is safe; the
769
+ * transport applies its normal retry policy first); `RateLimitError` for 429.
770
+ */
771
+ forget(options: ForgetOptions): Promise<ForgetResult>;
674
772
  status(ingestionId: string): Promise<Json>;
675
773
  wait_for_completion(ingestionId: string, options?: WaitOptions): Promise<Json>;
676
774
  }
@@ -1384,6 +1482,8 @@ interface UnifiedFetchOptions {
1384
1482
  precision_level?: string;
1385
1483
  /** The moment the question is being asked. See FetchOptions.query_date. */
1386
1484
  query_date?: string;
1485
+ /** A share of the response per search query. See FetchOptions.max_results_per_query. */
1486
+ max_results_per_query?: number;
1387
1487
  include_conversation_context?: boolean;
1388
1488
  scopes?: string[];
1389
1489
  include_scope_labels?: boolean;
@@ -1554,7 +1654,7 @@ declare class SynapClient {
1554
1654
  * build when the two disagree, which is the only thing that makes a manual
1555
1655
  * publish safe.
1556
1656
  */
1557
- declare const SDK_VERSION = "0.5.4";
1657
+ declare const SDK_VERSION = "0.5.6";
1558
1658
 
1559
1659
  /**
1560
1660
  * BM25 scorer for the anticipation cache.
@@ -1710,4 +1810,4 @@ interface SynapSdkLike {
1710
1810
  };
1711
1811
  }
1712
1812
 
1713
- export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, type MemoriesInterface, type NormalisedContext, type OpenAiToolDefinition, type Preference, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDK_VERSION, type Scope, type SendMessageOptions, SynapClient, type SynapClientOptions, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, type TranscriptIngestResult, type TranscriptTurn, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
1813
+ export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FlatMemory, type ForgetCandidate, type ForgetMode, type ForgetOptions, type ForgetResult, type ForgetStatus, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, type MemoriesInterface, type NormalisedContext, type OpenAiToolDefinition, type Preference, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDK_VERSION, type Scope, type SendMessageOptions, SynapClient, type SynapClientOptions, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, type TranscriptIngestResult, type TranscriptTurn, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
package/dist/index.d.ts CHANGED
@@ -60,6 +60,11 @@ declare const ENDPOINTS: {
60
60
  readonly path: "/api/v1/memories/{memory_id}";
61
61
  readonly idempotent: true;
62
62
  };
63
+ readonly memories_forget: {
64
+ readonly method: "POST";
65
+ readonly path: "/api/v1/memories/forget";
66
+ readonly idempotent: false;
67
+ };
63
68
  readonly context_fetch_user: {
64
69
  readonly method: "POST";
65
70
  readonly path: "/v1/context/user/fetch";
@@ -372,6 +377,12 @@ interface RawContextItem {
372
377
  valid_until?: string | null;
373
378
  temporal_category?: string | null;
374
379
  temporal_confidence?: number;
380
+ /**
381
+ * The search queries of the fetch that found this item, in the order they
382
+ * were sent. Absent from a server that predates the field, and on an item
383
+ * served from the prefetch cache.
384
+ */
385
+ matched_queries?: string[];
375
386
  [key: string]: unknown;
376
387
  }
377
388
  interface RawConversationContext {
@@ -402,7 +413,15 @@ interface TemporalFields {
402
413
  temporalCategory: string | null;
403
414
  temporalConfidence: number;
404
415
  }
405
- interface Fact extends TemporalFields {
416
+ /**
417
+ * Which of the fetch's search queries found an item. A fetch can carry several
418
+ * and returns one set for all of them. Always an array: empty when the fetch
419
+ * named no query or the server predates the field.
420
+ */
421
+ interface QueryAttribution {
422
+ matchedQueries: string[];
423
+ }
424
+ interface Fact extends TemporalFields, QueryAttribution {
406
425
  id: string;
407
426
  content: string;
408
427
  confidence: number;
@@ -410,7 +429,7 @@ interface Fact extends TemporalFields {
410
429
  extractedAt: string | null;
411
430
  metadata: Json;
412
431
  }
413
- interface Preference extends TemporalFields {
432
+ interface Preference extends TemporalFields, QueryAttribution {
414
433
  id: string;
415
434
  category: string;
416
435
  content: string;
@@ -419,7 +438,7 @@ interface Preference extends TemporalFields {
419
438
  extractedAt: string | null;
420
439
  metadata: Json;
421
440
  }
422
- interface Episode extends TemporalFields {
441
+ interface Episode extends TemporalFields, QueryAttribution {
423
442
  id: string;
424
443
  summary: string;
425
444
  occurredAt: string | null;
@@ -427,7 +446,7 @@ interface Episode extends TemporalFields {
427
446
  participants: unknown[];
428
447
  metadata: Json;
429
448
  }
430
- interface Emotion extends TemporalFields {
449
+ interface Emotion extends TemporalFields, QueryAttribution {
431
450
  id: string;
432
451
  emotionType: string;
433
452
  intensity: number;
@@ -435,7 +454,7 @@ interface Emotion extends TemporalFields {
435
454
  context: string;
436
455
  metadata: Json;
437
456
  }
438
- interface TemporalEvent {
457
+ interface TemporalEvent extends QueryAttribution {
439
458
  id: string;
440
459
  content: string;
441
460
  eventDate: string | null;
@@ -516,6 +535,18 @@ interface FetchOptions {
516
535
  */
517
536
  query_date?: string;
518
537
  queryDate?: string;
538
+ /**
539
+ * How many items each search query may contribute when `search_query` holds
540
+ * more than one, so a query with many strong matches cannot take every
541
+ * place. `max_results` stays the ceiling on the whole response: three
542
+ * queries at five each under `max_results: 10` return ten.
543
+ *
544
+ * Sent only when provided, like `query_date`. Left out, or with one query,
545
+ * the response is the best `max_results` items overall, as before. `0` is
546
+ * treated as left out.
547
+ */
548
+ max_results_per_query?: number;
549
+ maxResultsPerQuery?: number;
519
550
  /** Sent only when explicitly false, matching the Python controllers. */
520
551
  include_conversation_context?: boolean;
521
552
  /**
@@ -664,6 +695,44 @@ interface BatchCreateOptions {
664
695
  fail_fast?: boolean;
665
696
  failFast?: boolean;
666
697
  }
698
+ /** Mirrors the Python ForgetMode enum. */
699
+ declare const FORGET_MODES: readonly ["preview", "direct"];
700
+ type ForgetMode = (typeof FORGET_MODES)[number];
701
+ interface ForgetOptions {
702
+ /** What to forget, in the user's own words (3 to 500 characters). */
703
+ description: string;
704
+ user_id?: string | null;
705
+ userId?: string | null;
706
+ customer_id?: string | null;
707
+ customerId?: string | null;
708
+ /**
709
+ * The level to search, named in full, one entry per level down to it:
710
+ * `{ customer: "acme", team: "payments", user: "dana" }`. Only needed when
711
+ * your scope ladder has a level between customer and user.
712
+ */
713
+ scope?: Record<string, string> | null;
714
+ /** `"preview"` (default) or `"direct"`. See `MemoriesInterface.forget`. */
715
+ mode?: ForgetMode | string;
716
+ }
717
+ /** A memory the description matched. Mirrors Python's `ForgetCandidate`. */
718
+ interface ForgetCandidate {
719
+ memory_id: string;
720
+ content: string;
721
+ memory_type?: string | null;
722
+ /** `"memory"`, or where a copy lives: chunk, sentence, entity, triple, profile, candidate. */
723
+ store?: string;
724
+ }
725
+ type ForgetStatus = 'nothing_matches' | 'preview' | 'deleted' | 'partial';
726
+ /** Result of `memories.forget`. Mirrors Python's `ForgetResponse`. */
727
+ interface ForgetResult {
728
+ status: ForgetStatus;
729
+ request_id: string | null;
730
+ candidates: ForgetCandidate[];
731
+ deleted_ids: string[];
732
+ failed_ids: string[];
733
+ still_present_in: string[];
734
+ may_be_incomplete: boolean;
735
+ }
667
736
  interface MemoriesInterface {
668
737
  create(options: CreateMemoryOptions): Promise<CreateMemoryResult>;
669
738
  batch_create(options: BatchCreateOptions): Promise<BatchCreateResult>;
@@ -671,6 +740,35 @@ interface MemoriesInterface {
671
740
  get(memoryId: string): Promise<Json>;
672
741
  update(options: UpdateMemoryOptions): Promise<Json>;
673
742
  delete(memoryId: string): Promise<Json>;
743
+ /**
744
+ * Forget memories by describing them in the user's own words. Use it when
745
+ * you do not hold memory ids; to delete one memory by id, use `delete()`.
746
+ *
747
+ * The call must be scoped to exactly one user: pass `user_id`, plus
748
+ * `customer_id` on a B2B instance. Otherwise the server answers 400, raised
749
+ * as `InvalidInputError`.
750
+ *
751
+ * Modes:
752
+ * - `"preview"` (default): files a pending request that a person approves in
753
+ * the dashboard under Deletion requests. Deletes nothing. `candidates`
754
+ * lists what matched.
755
+ * - `"direct"`: finds and soft-deletes in one call. Not idempotent as a
756
+ * request: a repeat is harmless and finds nothing new, but it is a new
757
+ * request.
758
+ *
759
+ * `status` is `"nothing_matches"`, `"preview"`, `"deleted"` or `"partial"`.
760
+ * `"partial"` means the memories are hidden but a store named in
761
+ * `still_present_in` may still hold the text, so do not tell an end user it
762
+ * was removed unless `status === "deleted"`. `failed_ids` lists memories that
763
+ * could not be deleted; `may_be_incomplete` is true when the match may not
764
+ * have covered everything.
765
+ *
766
+ * Errors: `InvalidInputError` for 400/422 or a bad `description`/`mode`
767
+ * caught before sending; `ServiceUnavailableError` for 503 (the matcher was
768
+ * unavailable and nothing was deleted, so trying again is safe; the
769
+ * transport applies its normal retry policy first); `RateLimitError` for 429.
770
+ */
771
+ forget(options: ForgetOptions): Promise<ForgetResult>;
674
772
  status(ingestionId: string): Promise<Json>;
675
773
  wait_for_completion(ingestionId: string, options?: WaitOptions): Promise<Json>;
676
774
  }
@@ -1384,6 +1482,8 @@ interface UnifiedFetchOptions {
1384
1482
  precision_level?: string;
1385
1483
  /** The moment the question is being asked. See FetchOptions.query_date. */
1386
1484
  query_date?: string;
1485
+ /** A share of the response per search query. See FetchOptions.max_results_per_query. */
1486
+ max_results_per_query?: number;
1387
1487
  include_conversation_context?: boolean;
1388
1488
  scopes?: string[];
1389
1489
  include_scope_labels?: boolean;
@@ -1554,7 +1654,7 @@ declare class SynapClient {
1554
1654
  * build when the two disagree, which is the only thing that makes a manual
1555
1655
  * publish safe.
1556
1656
  */
1557
- declare const SDK_VERSION = "0.5.4";
1657
+ declare const SDK_VERSION = "0.5.6";
1558
1658
 
1559
1659
  /**
1560
1660
  * BM25 scorer for the anticipation cache.
@@ -1710,4 +1810,4 @@ interface SynapSdkLike {
1710
1810
  };
1711
1811
  }
1712
1812
 
1713
- export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, type Fact, type FetchOptions, type FlatMemory, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, type MemoriesInterface, type NormalisedContext, type OpenAiToolDefinition, type Preference, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDK_VERSION, type Scope, type SendMessageOptions, SynapClient, type SynapClientOptions, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, type TranscriptIngestResult, type TranscriptTurn, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
1813
+ export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DocumentType, ENDPOINTS, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FlatMemory, type ForgetCandidate, type ForgetMode, type ForgetOptions, type ForgetResult, type ForgetStatus, type FormatOptions, HttpTransport, type HttpTransportOptions, INGEST_MODES, ITEM_COLLECTIONS, type IngestMode, type IngestTranscriptOptions, type InstanceNamespace, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, type MemoriesInterface, type NormalisedContext, type OpenAiToolDefinition, type Preference, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDK_VERSION, type Scope, type SendMessageOptions, SynapClient, type SynapClientOptions, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, type TranscriptIngestResult, type TranscriptTurn, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
package/dist/index.js CHANGED
@@ -49,6 +49,7 @@ var ENDPOINTS = {
49
49
  memories_get: { method: "GET", path: "/api/v1/memories/{memory_id}", idempotent: true },
50
50
  memories_update: { method: "PATCH", path: "/api/v1/memories/{memory_id}", idempotent: false },
51
51
  memories_delete: { method: "DELETE", path: "/api/v1/memories/{memory_id}", idempotent: true },
52
+ memories_forget: { method: "POST", path: "/api/v1/memories/forget", idempotent: false },
52
53
  context_fetch_user: { method: "POST", path: "/v1/context/user/fetch", idempotent: true },
53
54
  context_fetch_customer: { method: "POST", path: "/v1/context/customer/fetch", idempotent: true },
54
55
  context_fetch_client: { method: "POST", path: "/v1/context/client/fetch", idempotent: true },
@@ -537,6 +538,7 @@ function buildFetchRequest(scope, options) {
537
538
  const maxResults = opt(options, "max_results", "maxResults") ?? 10;
538
539
  const precisionLevel = opt(options, "precision_level", "precisionLevel") ?? "high";
539
540
  const queryDate = opt(options, "query_date", "queryDate");
541
+ const perQuery = opt(options, "max_results_per_query", "maxResultsPerQuery");
540
542
  const mode = options.mode ?? "fast";
541
543
  if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
542
544
  throw new InvalidInputError("search_query must be an array when provided");
@@ -553,6 +555,7 @@ function buildFetchRequest(scope, options) {
553
555
  };
554
556
  if (precisionLevel !== "high") body["precision_level"] = precisionLevel;
555
557
  if (queryDate) body["query_date"] = queryDate;
558
+ if (perQuery) body["max_results_per_query"] = perQuery;
556
559
  if (options.include_conversation_context === false) {
557
560
  body["include_conversation_context"] = false;
558
561
  }
@@ -628,6 +631,10 @@ function pick(...values) {
628
631
  return pickDefined(...values);
629
632
  }
630
633
  var obj = (v) => v ?? {};
634
+ function matchedQueries(item = {}) {
635
+ const raw = item["matchedQueries"] ?? item.matched_queries;
636
+ return Array.isArray(raw) ? raw : [];
637
+ }
631
638
  function normalizeTemporalFields(item = {}) {
632
639
  return {
633
640
  eventDate: pick(item["eventDate"], item.event_date, null),
@@ -644,7 +651,8 @@ function normalizeFact(item = {}) {
644
651
  source: item.source || "",
645
652
  extractedAt: pick(item["extractedAt"], item.extracted_at, null),
646
653
  metadata: obj(item.metadata),
647
- ...normalizeTemporalFields(item)
654
+ ...normalizeTemporalFields(item),
655
+ matchedQueries: matchedQueries(item)
648
656
  };
649
657
  }
650
658
  function normalizePreference(item = {}) {
@@ -656,7 +664,8 @@ function normalizePreference(item = {}) {
656
664
  source: item.source || "",
657
665
  extractedAt: pick(item["extractedAt"], item.extracted_at, null),
658
666
  metadata: obj(item.metadata),
659
- ...normalizeTemporalFields(item)
667
+ ...normalizeTemporalFields(item),
668
+ matchedQueries: matchedQueries(item)
660
669
  };
661
670
  }
662
671
  function normalizeEpisode(item = {}) {
@@ -667,7 +676,8 @@ function normalizeEpisode(item = {}) {
667
676
  significance: pick(item["significance"], item.confidence, 0),
668
677
  participants: item["participants"] || [],
669
678
  metadata: obj(item.metadata),
670
- ...normalizeTemporalFields(item)
679
+ ...normalizeTemporalFields(item),
680
+ matchedQueries: matchedQueries(item)
671
681
  };
672
682
  }
673
683
  function normalizeEmotion(item = {}) {
@@ -678,7 +688,8 @@ function normalizeEmotion(item = {}) {
678
688
  detectedAt: pick(item["detectedAt"], item["detected_at"], null),
679
689
  context: item["context"] || "",
680
690
  metadata: obj(item.metadata),
681
- ...normalizeTemporalFields(item)
691
+ ...normalizeTemporalFields(item),
692
+ matchedQueries: matchedQueries(item)
682
693
  };
683
694
  }
684
695
  function normalizeTemporalEvent(item = {}) {
@@ -692,7 +703,8 @@ function normalizeTemporalEvent(item = {}) {
692
703
  confidence: pick(item.confidence, 0),
693
704
  source: item.source || "",
694
705
  extractedAt: pick(item["extractedAt"], item.extracted_at, null),
695
- metadata: obj(item.metadata)
706
+ metadata: obj(item.metadata),
707
+ matchedQueries: matchedQueries(item)
696
708
  };
697
709
  }
698
710
  function normalizeContextMetadata(metadata = {}) {
@@ -866,8 +878,33 @@ function buildCreateBody(options) {
866
878
  metadata: options.metadata ?? {}
867
879
  };
868
880
  }
881
+ var FORGET_MODES = ["preview", "direct"];
882
+ var FORGET_DESCRIPTION_MIN = 3;
883
+ var FORGET_DESCRIPTION_MAX = 500;
884
+ function buildForgetBody(options) {
885
+ const description = options.description;
886
+ if (typeof description !== "string" || description.length < FORGET_DESCRIPTION_MIN || description.length > FORGET_DESCRIPTION_MAX) {
887
+ throw new InvalidInputError(
888
+ `description must be between ${FORGET_DESCRIPTION_MIN} and ${FORGET_DESCRIPTION_MAX} characters`
889
+ );
890
+ }
891
+ const mode = options.mode ?? "preview";
892
+ if (!FORGET_MODES.includes(mode)) {
893
+ throw new InvalidInputError(
894
+ `Invalid mode '${mode}'. Expected one of: ${FORGET_MODES.join(", ")}`
895
+ );
896
+ }
897
+ const o2 = options;
898
+ return {
899
+ description,
900
+ user_id: either(o2, "user_id", "userId") ?? null,
901
+ customer_id: either(o2, "customer_id", "customerId") ?? null,
902
+ scope: options.scope ?? null,
903
+ mode
904
+ };
905
+ }
869
906
  var TERMINAL_STATUSES = /* @__PURE__ */ new Set(["completed", "failed", "error", "cancelled"]);
870
- function createMemoriesInterface(transport) {
907
+ function createMemoriesInterface(transport, onForgotten) {
871
908
  return {
872
909
  async create(options) {
873
910
  const o2 = options;
@@ -953,6 +990,23 @@ function createMemoriesInterface(transport) {
953
990
  }
954
991
  return transport.request("memories_delete", { pathParams: { memory_id: memoryId } });
955
992
  },
993
+ async forget(options) {
994
+ const o2 = options;
995
+ transport.checkCustomerId(o2["customer_id"] ?? o2["customerId"], "memories.forget");
996
+ const body = buildForgetBody(options);
997
+ const result = await transport.request("memories_forget", { body });
998
+ const removed = !!result?.deleted_ids?.length || result?.status === "deleted" || result?.status === "partial";
999
+ if (removed && onForgotten) {
1000
+ try {
1001
+ onForgotten({
1002
+ userId: body["user_id"] ?? null,
1003
+ customerId: body["customer_id"] ?? null
1004
+ });
1005
+ } catch {
1006
+ }
1007
+ }
1008
+ return result;
1009
+ },
956
1010
  async status(ingestionId) {
957
1011
  if (!ingestionId) throw new InvalidInputError("ingestion_id is required");
958
1012
  return transport.request("memories_status", {
@@ -1457,7 +1511,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1457
1511
  if (client !== null) {
1458
1512
  throw new ListeningAlreadyActiveError("Listening is already active on this instance");
1459
1513
  }
1460
- const { GrpcStreamClient } = await import("./stream-client-5CGJNTH4.js");
1514
+ const { GrpcStreamClient } = await import("./stream-client-Y5NFAMIH.js");
1461
1515
  const onContext = options.on_context ?? options.onContext;
1462
1516
  const onDisconnect = options.on_disconnect ?? options.onDisconnect;
1463
1517
  const onReconnect = options.on_reconnect ?? options.onReconnect;
@@ -1629,7 +1683,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
1629
1683
  }
1630
1684
 
1631
1685
  // src/version.ts
1632
- var SDK_VERSION = "0.5.4";
1686
+ var SDK_VERSION = "0.5.6";
1633
1687
 
1634
1688
  // src/registry.ts
1635
1689
  var instances = /* @__PURE__ */ new Map();
@@ -2132,6 +2186,10 @@ function tryServeFromCache(cache, scope, params, maxItems) {
2132
2186
  return { response: null, hit: null };
2133
2187
  }
2134
2188
  }
2189
+ function distinctQueryCount(searchQuery) {
2190
+ if (!Array.isArray(searchQuery)) return 0;
2191
+ return new Set(searchQuery.filter((q) => typeof q === "string" && q.length > 0)).size;
2192
+ }
2135
2193
 
2136
2194
  // src/context/assembled.ts
2137
2195
  var COLLECTIONS2 = ["facts", "preferences", "episodes", "emotions", "temporal_events"];
@@ -2629,6 +2687,7 @@ var SynapClient = class {
2629
2687
  beforeFetch: (scope, options2) => {
2630
2688
  const o2 = options2;
2631
2689
  if (o2["query_date"] ?? o2["queryDate"]) return null;
2690
+ if (o2["max_results_per_query"] ?? o2["maxResultsPerQuery"]) return null;
2632
2691
  const attempt = tryServeFromCache(
2633
2692
  this.#anticipationCache,
2634
2693
  scope,
@@ -2699,7 +2758,11 @@ var SynapClient = class {
2699
2758
  compacted: (conversationId, format) => this.#localCompacted(conversationId, format)
2700
2759
  }
2701
2760
  );
2702
- this.memories = createMemoriesInterface(this.#transport);
2761
+ this.memories = createMemoriesInterface(this.#transport, ({ userId, customerId }) => {
2762
+ for (const id of /* @__PURE__ */ new Set([userId, customerId])) {
2763
+ if (id) this.#anticipationCache.dropEntity(id);
2764
+ }
2765
+ });
2703
2766
  this.credits = createCreditsNamespace(this.#transport);
2704
2767
  this.cache = createCacheNamespace(this.#anticipationCache);
2705
2768
  this.instance = createInstanceNamespace(
@@ -2898,6 +2961,7 @@ var SynapClient = class {
2898
2961
  mode = "fast",
2899
2962
  precision_level: precisionLevel = "high",
2900
2963
  query_date: queryDate,
2964
+ max_results_per_query: maxResultsPerQuery,
2901
2965
  include_conversation_context: includeConversationContext = true,
2902
2966
  scopes,
2903
2967
  include_scope_labels: includeScopeLabels = false,
@@ -2916,7 +2980,8 @@ var SynapClient = class {
2916
2980
  // In `shared` so it reaches all four branches at once. The Python edit
2917
2981
  // threaded three call sites by hand and missed the client branch, which
2918
2982
  // sits one indent deeper; spreading removes that whole class of miss.
2919
- query_date: queryDate
2983
+ query_date: queryDate,
2984
+ max_results_per_query: maxResultsPerQuery
2920
2985
  };
2921
2986
  const labels = [];
2922
2987
  const tasks = [];
@@ -3026,7 +3091,12 @@ var SynapClient = class {
3026
3091
  served_item_ids: served.servedItemIds,
3027
3092
  scope,
3028
3093
  source_bundle_ids: served.bundleId ? [served.bundleId] : [],
3029
- timestamp_ms: Date.now()
3094
+ timestamp_ms: Date.now(),
3095
+ // How many distinct search queries the fetch carried. A hit never
3096
+ // reaches the fetch route, so this event is how the server learns it
3097
+ // happened and what it is charged by. The count only: this event must
3098
+ // not carry the caller's words.
3099
+ query_count: distinctQueryCount(options["search_query"] ?? options["searchQuery"])
3030
3100
  });
3031
3101
  } catch {
3032
3102
  }
@@ -3165,6 +3235,7 @@ export {
3165
3235
  DEFAULT_TIMEOUTS,
3166
3236
  DOCUMENT_TYPES,
3167
3237
  ENDPOINTS,
3238
+ FORGET_MODES,
3168
3239
  HttpTransport,
3169
3240
  INGEST_MODES,
3170
3241
  ITEM_COLLECTIONS,