@maximem/synap-js-sdk 0.7.2 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -75,6 +75,11 @@ declare const ENDPOINTS: {
75
75
  readonly path: "/v1/data/delete";
76
76
  readonly idempotent: true;
77
77
  };
78
+ readonly data_restore: {
79
+ readonly method: "POST";
80
+ readonly path: "/v1/data/restore";
81
+ readonly idempotent: true;
82
+ };
78
83
  readonly data_delete_status: {
79
84
  readonly method: "GET";
80
85
  readonly path: "/v1/data/delete/{deletion_id}";
@@ -1095,6 +1100,36 @@ interface ForgetCandidate {
1095
1100
  store?: string;
1096
1101
  }
1097
1102
  type ForgetStatus = 'nothing_matches' | 'preview' | 'deleted' | 'partial';
1103
+ /**
1104
+ * Result of `memories.delete`. Mirrors the dict Python's `memories.delete` returns.
1105
+ * `fully_removed` is false unless the server said true: a store named in
1106
+ * `still_present_in` may still serve the text, so do not tell an end user it is gone.
1107
+ */
1108
+ interface DeleteMemoryResult {
1109
+ memory_id: string;
1110
+ deleted_at: string;
1111
+ fully_removed: boolean;
1112
+ still_present_in: string[];
1113
+ /** The source document stays because other memories still rest on it. */
1114
+ source_text_kept: boolean;
1115
+ /**
1116
+ * `pending_purge` (the default soft delete: hidden now, restorable with
1117
+ * `data.restore([id])` until `purge_after`), `complete` (a permanent delete
1118
+ * finished) or `partial`. `complete` from a server older than soft delete.
1119
+ */
1120
+ status: string;
1121
+ /** When a soft-deleted memory is purged (ISO 8601), or null. */
1122
+ purge_after: string | null;
1123
+ permanent: boolean;
1124
+ }
1125
+ /** Options of `memories.delete`. */
1126
+ interface DeleteMemoryOptions {
1127
+ /**
1128
+ * Remove it now, with no restore period. Needs a management-level key
1129
+ * (delete:permanent, delete:*, management:* or *).
1130
+ */
1131
+ permanent?: boolean;
1132
+ }
1098
1133
  /** Result of `memories.forget`. Mirrors Python's `ForgetResponse`. */
1099
1134
  interface ForgetResult {
1100
1135
  status: ForgetStatus;
@@ -1118,7 +1153,7 @@ interface MemoriesInterface {
1118
1153
  create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
1119
1154
  get(memoryId: string): Promise<Json>;
1120
1155
  update(options: UpdateMemoryOptions): Promise<Json>;
1121
- delete(memoryId: string): Promise<Json>;
1156
+ delete(memoryId: string, options?: DeleteMemoryOptions): Promise<DeleteMemoryResult>;
1122
1157
  /**
1123
1158
  * Forget memories by describing them in the user's own words. Use it when
1124
1159
  * you do not hold memory ids; to delete one memory by id, use `delete()`.
@@ -1419,11 +1454,27 @@ interface DeleteDataOptions {
1419
1454
  confirm?: string | null;
1420
1455
  /** Repeat the call while the server says `continue` (default true, max 50 calls). */
1421
1456
  wait?: boolean;
1457
+ /**
1458
+ * Delete in several instances of the client at once: `"all"` or a list of
1459
+ * instance ids. Needs a management key not bound to one instance (a bound key
1460
+ * may only name its own). Omit it to delete in this SDK's instance only.
1461
+ * Mirrors Python's `instances`.
1462
+ */
1463
+ instances?: 'all' | string[] | null;
1464
+ /**
1465
+ * Remove the memories now instead of after the deletion period. Needs a
1466
+ * management-level key (delete:permanent, delete:*, management:* or *).
1467
+ */
1468
+ permanent?: boolean;
1422
1469
  }
1423
1470
  /** Result of `data.delete` / `data.status`. Mirrors Python's `DeleteDataResult`. */
1424
1471
  interface DeleteDataResult {
1425
1472
  deletion_id: string | null;
1426
- /** `complete`, `partial`, `in_progress` or `dry_run`. */
1473
+ /**
1474
+ * `complete`, `pending_purge`, `partial`, `in_progress` or `dry_run`.
1475
+ * `pending_purge`: hidden from every read now, restorable with
1476
+ * `data.restore` until `purge_after`, then removed for good.
1477
+ */
1427
1478
  status: string;
1428
1479
  scope: string | null;
1429
1480
  dry_run: boolean;
@@ -1435,23 +1486,59 @@ interface DeleteDataResult {
1435
1486
  /** True when the server's size cap stopped the call. */
1436
1487
  continue: boolean;
1437
1488
  kept: string[];
1489
+ /**
1490
+ * Stores this delete does not reach at all, in plain words. `complete` means every
1491
+ * store the delete targets was cleared, not that nothing is left in these. Empty
1492
+ * from servers that predate the field.
1493
+ */
1494
+ not_covered: string[];
1438
1495
  note: string | null;
1439
1496
  memories_kept: boolean;
1440
1497
  audit: string | null;
1441
1498
  /** What the SDK cleared on this machine after the server finished. */
1442
1499
  local_cleared: string[];
1500
+ /** Only with `instances`: one result per instance, plus `instance_id`. */
1501
+ instances: Record<string, unknown>[];
1502
+ /** Only with `instances`: instances the time budget did not reach yet. */
1503
+ not_started: string[];
1504
+ /** Only with `instances`: every audit id. */
1505
+ deletion_ids: string[];
1506
+ /** With status `pending_purge`: when the deleted memories are purged (ISO 8601, UTC). */
1507
+ purge_after: string | null;
1508
+ [key: string]: unknown;
1509
+ }
1510
+ /** The most ids one `data.restore` call takes. Same as Python's MAX_RESTORE_IDS. */
1511
+ declare const MAX_RESTORE_IDS = 200;
1512
+ /** Result of `data.restore`. Mirrors Python's `RestoreResult`. */
1513
+ interface RestoreResult {
1514
+ /** Live again; served by the next fetch. */
1515
+ restored_ids: string[];
1516
+ /** Not found in this instance, not deleted, or past the purge date. */
1517
+ not_restorable_ids: string[];
1518
+ /** A store that could not be brought back in line; the memory is restored either way. */
1519
+ still_missing_in: string[];
1520
+ reindexed_ids: string[];
1521
+ fully_restored: boolean;
1443
1522
  [key: string]: unknown;
1444
1523
  }
1524
+ /** What to restore: memory ids, or every memory one `data.delete` hid. */
1525
+ interface RestoreOptions {
1526
+ memory_ids?: string[] | null;
1527
+ memoryIds?: string[] | null;
1528
+ /** The `deletion_id` of a `data.delete` result. Send exactly one of the two. */
1529
+ deletion_id?: string | null;
1530
+ deletionId?: string | null;
1531
+ }
1445
1532
  interface DataInterface {
1446
1533
  /**
1447
- * Delete data for one user, one conversation or one customer. Permanent.
1534
+ * Delete data for one user, one conversation or one customer. Memories are
1535
+ * soft-deleted (restorable until `purge_after`) unless `permanent` is true.
1448
1536
  * scope 'conversation' removes turns, summaries, telemetry and the turn buffer ONLY;
1449
1537
  * memories learned from it are kept (use scope 'user' or memories.delete). Data in
1450
1538
  * another instance is never touched; stores that cannot be scoped by instance are
1451
1539
  * skipped and named in still_present_in.
1452
1540
  *
1453
1541
  * scope 'customer' needs a management key (management:* or *); a runtime key gets 403.
1454
- * LLM call traces are not removed (llm_call_bodies up to 14 days, llm_calls up to 180 days).
1455
1542
  *
1456
1543
  * A store that could not be cleared is in `still_present_in` and
1457
1544
  * `fully_removed` is false; it is a result, not an exception. Errors:
@@ -1461,6 +1548,15 @@ interface DataInterface {
1461
1548
  delete(options: DeleteDataOptions): Promise<DeleteDataResult>;
1462
1549
  /** The audit record of a delete (status, counts, still_present_in). */
1463
1550
  status(deletionId: string): Promise<DeleteDataResult>;
1551
+ /**
1552
+ * Bring deleted memories back, until their purge date (the instance's deletion
1553
+ * period, 0 to 30 days, 30 by default). Pass up to 200 ids, or
1554
+ * `{ deletionId }` for every memory one `data.delete` hid. Needs the same key
1555
+ * permissions as delete and reaches only this instance's memories. Ids that
1556
+ * could not be restored are in `not_restorable_ids`; that is a result, not an
1557
+ * exception.
1558
+ */
1559
+ restore(target: string[] | RestoreOptions): Promise<RestoreResult>;
1464
1560
  }
1465
1561
 
1466
1562
  /** User namespace. Mirrors `UserInterface` in the Python SDK. */
@@ -2216,7 +2312,7 @@ declare class SynapClient {
2216
2312
  deleteMemory(options: {
2217
2313
  memoryId?: string;
2218
2314
  memory_id?: string;
2219
- }): Promise<Json>;
2315
+ }): Promise<DeleteMemoryResult>;
2220
2316
  /**
2221
2317
  * Resolve `client_id` and `instance_id` from the API key.
2222
2318
  *
@@ -2340,7 +2436,7 @@ declare class SynapClient {
2340
2436
  * build when the two disagree, which is the only thing that makes a manual
2341
2437
  * publish safe.
2342
2438
  */
2343
- declare const SDK_VERSION = "0.7.2";
2439
+ declare const SDK_VERSION = "0.8.0";
2344
2440
 
2345
2441
  /**
2346
2442
  * `response_shape: "ranked"`: one list in the order the server ranked it.
@@ -2581,4 +2677,4 @@ interface SynapSdkLike {
2581
2677
  };
2582
2678
  }
2583
2679
 
2584
- export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, type AttachmentResult, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContentPart, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateDocument, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DATA_SCOPES, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DataInterface, type DataScope, type DeleteDataOptions, type DeleteDataResult, type DocumentType, ENDPOINTS, EXCERPT_CATEGORY, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FileData, type FilePart, type FilePartInit, 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, MEMORY_TYPES, type MacaGenerateOptions, type MacaJob, type MacaNamespace, type MacaRelationship, type MacaWaitOptions, type MemoriesInterface, type NormalisedContext, OBJECTIVES, type Objective, type OpenAiToolDefinition, type Preference, RESPONSE_SHAPES, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type ResponseShape, type RetryPolicy, SDK_VERSION, type Scope, ScopeAddress, ScopeLadder, type ScopeLevel, type SendMessageOptions, SynapClient, type SynapClientOptions, SynapError, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TextPart, 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, applyResponseShape, filePart, flattenContextItems, formatForPrompt, isOutcomeUnknown, mergeScopeResults, rankItems, resolvePath, shouldRetry, stem, textPart, tokenize, wireRankScore };
2680
+ export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, type AttachmentResult, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContentPart, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateDocument, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DATA_SCOPES, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DataInterface, type DataScope, type DeleteDataOptions, type DeleteDataResult, type DeleteMemoryOptions, type DeleteMemoryResult, type DocumentType, ENDPOINTS, EXCERPT_CATEGORY, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FileData, type FilePart, type FilePartInit, 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, MAX_RESTORE_IDS, MEMORY_TYPES, type MacaGenerateOptions, type MacaJob, type MacaNamespace, type MacaRelationship, type MacaWaitOptions, type MemoriesInterface, type NormalisedContext, OBJECTIVES, type Objective, type OpenAiToolDefinition, type Preference, RESPONSE_SHAPES, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type ResponseShape, type RestoreOptions, type RestoreResult, type RetryPolicy, SDK_VERSION, type Scope, ScopeAddress, ScopeLadder, type ScopeLevel, type SendMessageOptions, SynapClient, type SynapClientOptions, SynapError, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TextPart, 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, applyResponseShape, filePart, flattenContextItems, formatForPrompt, isOutcomeUnknown, mergeScopeResults, rankItems, resolvePath, shouldRetry, stem, textPart, tokenize, wireRankScore };
package/dist/index.d.ts CHANGED
@@ -75,6 +75,11 @@ declare const ENDPOINTS: {
75
75
  readonly path: "/v1/data/delete";
76
76
  readonly idempotent: true;
77
77
  };
78
+ readonly data_restore: {
79
+ readonly method: "POST";
80
+ readonly path: "/v1/data/restore";
81
+ readonly idempotent: true;
82
+ };
78
83
  readonly data_delete_status: {
79
84
  readonly method: "GET";
80
85
  readonly path: "/v1/data/delete/{deletion_id}";
@@ -1095,6 +1100,36 @@ interface ForgetCandidate {
1095
1100
  store?: string;
1096
1101
  }
1097
1102
  type ForgetStatus = 'nothing_matches' | 'preview' | 'deleted' | 'partial';
1103
+ /**
1104
+ * Result of `memories.delete`. Mirrors the dict Python's `memories.delete` returns.
1105
+ * `fully_removed` is false unless the server said true: a store named in
1106
+ * `still_present_in` may still serve the text, so do not tell an end user it is gone.
1107
+ */
1108
+ interface DeleteMemoryResult {
1109
+ memory_id: string;
1110
+ deleted_at: string;
1111
+ fully_removed: boolean;
1112
+ still_present_in: string[];
1113
+ /** The source document stays because other memories still rest on it. */
1114
+ source_text_kept: boolean;
1115
+ /**
1116
+ * `pending_purge` (the default soft delete: hidden now, restorable with
1117
+ * `data.restore([id])` until `purge_after`), `complete` (a permanent delete
1118
+ * finished) or `partial`. `complete` from a server older than soft delete.
1119
+ */
1120
+ status: string;
1121
+ /** When a soft-deleted memory is purged (ISO 8601), or null. */
1122
+ purge_after: string | null;
1123
+ permanent: boolean;
1124
+ }
1125
+ /** Options of `memories.delete`. */
1126
+ interface DeleteMemoryOptions {
1127
+ /**
1128
+ * Remove it now, with no restore period. Needs a management-level key
1129
+ * (delete:permanent, delete:*, management:* or *).
1130
+ */
1131
+ permanent?: boolean;
1132
+ }
1098
1133
  /** Result of `memories.forget`. Mirrors Python's `ForgetResponse`. */
1099
1134
  interface ForgetResult {
1100
1135
  status: ForgetStatus;
@@ -1118,7 +1153,7 @@ interface MemoriesInterface {
1118
1153
  create_from_file(options: CreateFromFileOptions): Promise<CreateMemoryResult>;
1119
1154
  get(memoryId: string): Promise<Json>;
1120
1155
  update(options: UpdateMemoryOptions): Promise<Json>;
1121
- delete(memoryId: string): Promise<Json>;
1156
+ delete(memoryId: string, options?: DeleteMemoryOptions): Promise<DeleteMemoryResult>;
1122
1157
  /**
1123
1158
  * Forget memories by describing them in the user's own words. Use it when
1124
1159
  * you do not hold memory ids; to delete one memory by id, use `delete()`.
@@ -1419,11 +1454,27 @@ interface DeleteDataOptions {
1419
1454
  confirm?: string | null;
1420
1455
  /** Repeat the call while the server says `continue` (default true, max 50 calls). */
1421
1456
  wait?: boolean;
1457
+ /**
1458
+ * Delete in several instances of the client at once: `"all"` or a list of
1459
+ * instance ids. Needs a management key not bound to one instance (a bound key
1460
+ * may only name its own). Omit it to delete in this SDK's instance only.
1461
+ * Mirrors Python's `instances`.
1462
+ */
1463
+ instances?: 'all' | string[] | null;
1464
+ /**
1465
+ * Remove the memories now instead of after the deletion period. Needs a
1466
+ * management-level key (delete:permanent, delete:*, management:* or *).
1467
+ */
1468
+ permanent?: boolean;
1422
1469
  }
1423
1470
  /** Result of `data.delete` / `data.status`. Mirrors Python's `DeleteDataResult`. */
1424
1471
  interface DeleteDataResult {
1425
1472
  deletion_id: string | null;
1426
- /** `complete`, `partial`, `in_progress` or `dry_run`. */
1473
+ /**
1474
+ * `complete`, `pending_purge`, `partial`, `in_progress` or `dry_run`.
1475
+ * `pending_purge`: hidden from every read now, restorable with
1476
+ * `data.restore` until `purge_after`, then removed for good.
1477
+ */
1427
1478
  status: string;
1428
1479
  scope: string | null;
1429
1480
  dry_run: boolean;
@@ -1435,23 +1486,59 @@ interface DeleteDataResult {
1435
1486
  /** True when the server's size cap stopped the call. */
1436
1487
  continue: boolean;
1437
1488
  kept: string[];
1489
+ /**
1490
+ * Stores this delete does not reach at all, in plain words. `complete` means every
1491
+ * store the delete targets was cleared, not that nothing is left in these. Empty
1492
+ * from servers that predate the field.
1493
+ */
1494
+ not_covered: string[];
1438
1495
  note: string | null;
1439
1496
  memories_kept: boolean;
1440
1497
  audit: string | null;
1441
1498
  /** What the SDK cleared on this machine after the server finished. */
1442
1499
  local_cleared: string[];
1500
+ /** Only with `instances`: one result per instance, plus `instance_id`. */
1501
+ instances: Record<string, unknown>[];
1502
+ /** Only with `instances`: instances the time budget did not reach yet. */
1503
+ not_started: string[];
1504
+ /** Only with `instances`: every audit id. */
1505
+ deletion_ids: string[];
1506
+ /** With status `pending_purge`: when the deleted memories are purged (ISO 8601, UTC). */
1507
+ purge_after: string | null;
1508
+ [key: string]: unknown;
1509
+ }
1510
+ /** The most ids one `data.restore` call takes. Same as Python's MAX_RESTORE_IDS. */
1511
+ declare const MAX_RESTORE_IDS = 200;
1512
+ /** Result of `data.restore`. Mirrors Python's `RestoreResult`. */
1513
+ interface RestoreResult {
1514
+ /** Live again; served by the next fetch. */
1515
+ restored_ids: string[];
1516
+ /** Not found in this instance, not deleted, or past the purge date. */
1517
+ not_restorable_ids: string[];
1518
+ /** A store that could not be brought back in line; the memory is restored either way. */
1519
+ still_missing_in: string[];
1520
+ reindexed_ids: string[];
1521
+ fully_restored: boolean;
1443
1522
  [key: string]: unknown;
1444
1523
  }
1524
+ /** What to restore: memory ids, or every memory one `data.delete` hid. */
1525
+ interface RestoreOptions {
1526
+ memory_ids?: string[] | null;
1527
+ memoryIds?: string[] | null;
1528
+ /** The `deletion_id` of a `data.delete` result. Send exactly one of the two. */
1529
+ deletion_id?: string | null;
1530
+ deletionId?: string | null;
1531
+ }
1445
1532
  interface DataInterface {
1446
1533
  /**
1447
- * Delete data for one user, one conversation or one customer. Permanent.
1534
+ * Delete data for one user, one conversation or one customer. Memories are
1535
+ * soft-deleted (restorable until `purge_after`) unless `permanent` is true.
1448
1536
  * scope 'conversation' removes turns, summaries, telemetry and the turn buffer ONLY;
1449
1537
  * memories learned from it are kept (use scope 'user' or memories.delete). Data in
1450
1538
  * another instance is never touched; stores that cannot be scoped by instance are
1451
1539
  * skipped and named in still_present_in.
1452
1540
  *
1453
1541
  * scope 'customer' needs a management key (management:* or *); a runtime key gets 403.
1454
- * LLM call traces are not removed (llm_call_bodies up to 14 days, llm_calls up to 180 days).
1455
1542
  *
1456
1543
  * A store that could not be cleared is in `still_present_in` and
1457
1544
  * `fully_removed` is false; it is a result, not an exception. Errors:
@@ -1461,6 +1548,15 @@ interface DataInterface {
1461
1548
  delete(options: DeleteDataOptions): Promise<DeleteDataResult>;
1462
1549
  /** The audit record of a delete (status, counts, still_present_in). */
1463
1550
  status(deletionId: string): Promise<DeleteDataResult>;
1551
+ /**
1552
+ * Bring deleted memories back, until their purge date (the instance's deletion
1553
+ * period, 0 to 30 days, 30 by default). Pass up to 200 ids, or
1554
+ * `{ deletionId }` for every memory one `data.delete` hid. Needs the same key
1555
+ * permissions as delete and reaches only this instance's memories. Ids that
1556
+ * could not be restored are in `not_restorable_ids`; that is a result, not an
1557
+ * exception.
1558
+ */
1559
+ restore(target: string[] | RestoreOptions): Promise<RestoreResult>;
1464
1560
  }
1465
1561
 
1466
1562
  /** User namespace. Mirrors `UserInterface` in the Python SDK. */
@@ -2216,7 +2312,7 @@ declare class SynapClient {
2216
2312
  deleteMemory(options: {
2217
2313
  memoryId?: string;
2218
2314
  memory_id?: string;
2219
- }): Promise<Json>;
2315
+ }): Promise<DeleteMemoryResult>;
2220
2316
  /**
2221
2317
  * Resolve `client_id` and `instance_id` from the API key.
2222
2318
  *
@@ -2340,7 +2436,7 @@ declare class SynapClient {
2340
2436
  * build when the two disagree, which is the only thing that makes a manual
2341
2437
  * publish safe.
2342
2438
  */
2343
- declare const SDK_VERSION = "0.7.2";
2439
+ declare const SDK_VERSION = "0.8.0";
2344
2440
 
2345
2441
  /**
2346
2442
  * `response_shape: "ranked"`: one list in the order the server ranked it.
@@ -2581,4 +2677,4 @@ interface SynapSdkLike {
2581
2677
  };
2582
2678
  }
2583
2679
 
2584
- export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, type AttachmentResult, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContentPart, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateDocument, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DATA_SCOPES, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DataInterface, type DataScope, type DeleteDataOptions, type DeleteDataResult, type DocumentType, ENDPOINTS, EXCERPT_CATEGORY, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FileData, type FilePart, type FilePartInit, 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, MEMORY_TYPES, type MacaGenerateOptions, type MacaJob, type MacaNamespace, type MacaRelationship, type MacaWaitOptions, type MemoriesInterface, type NormalisedContext, OBJECTIVES, type Objective, type OpenAiToolDefinition, type Preference, RESPONSE_SHAPES, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type ResponseShape, type RetryPolicy, SDK_VERSION, type Scope, ScopeAddress, ScopeLadder, type ScopeLevel, type SendMessageOptions, SynapClient, type SynapClientOptions, SynapError, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TextPart, 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, applyResponseShape, filePart, flattenContextItems, formatForPrompt, isOutcomeUnknown, mergeScopeResults, rankItems, resolvePath, shouldRetry, stem, textPart, tokenize, wireRankScore };
2680
+ export { type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, type AttachmentResult, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, type ContentPart, type ContextMetadata, type ConversationContext, type ConversationNamespace, type CreateDocument, type CreateFromFileOptions, type CreateMemoryOptions, type CreateMemoryResult, type Credentials, type CreditBalance, type CreditBucket, type CreditEstimate, type CreditLedgerEntry, type CreditLedgerPage, type CreditsNamespace, DATA_SCOPES, DEFAULT_BASE_URL, DEFAULT_DOCUMENT_TYPE, DEFAULT_INGEST_MODE, DEFAULT_RETRY_POLICY, DEFAULT_TIMEOUTS, DOCUMENT_TYPES, type DataInterface, type DataScope, type DeleteDataOptions, type DeleteDataResult, type DeleteMemoryOptions, type DeleteMemoryResult, type DocumentType, ENDPOINTS, EXCERPT_CATEGORY, type Emotion, type EndpointName, type EndpointSpec, type Episode, type EstimateOptions, FORGET_MODES, type Fact, type FetchOptions, type FileData, type FilePart, type FilePartInit, 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, MAX_RESTORE_IDS, MEMORY_TYPES, type MacaGenerateOptions, type MacaJob, type MacaNamespace, type MacaRelationship, type MacaWaitOptions, type MemoriesInterface, type NormalisedContext, OBJECTIVES, type Objective, type OpenAiToolDefinition, type Preference, RESPONSE_SHAPES, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type ResponseShape, type RestoreOptions, type RestoreResult, type RetryPolicy, SDK_VERSION, type Scope, ScopeAddress, ScopeLadder, type ScopeLevel, type SendMessageOptions, SynapClient, type SynapClientOptions, SynapError, type SynapLogLevel, type SynapLogger, type SynapSdkLike, THRESHOLDS, type TemporalEvent, type TemporalFields, type TextPart, 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, applyResponseShape, filePart, flattenContextItems, formatForPrompt, isOutcomeUnknown, mergeScopeResults, rankItems, resolvePath, shouldRetry, stem, textPart, tokenize, wireRankScore };
package/dist/index.js CHANGED
@@ -67,6 +67,7 @@ var ENDPOINTS = {
67
67
  memories_delete: { method: "DELETE", path: "/api/v1/memories/{memory_id}", idempotent: true },
68
68
  memories_forget: { method: "POST", path: "/api/v1/memories/forget", idempotent: false },
69
69
  data_delete: { method: "POST", path: "/v1/data/delete", idempotent: true },
70
+ data_restore: { method: "POST", path: "/v1/data/restore", idempotent: true },
70
71
  data_delete_status: { method: "GET", path: "/v1/data/delete/{deletion_id}", idempotent: true },
71
72
  context_fetch_user: { method: "POST", path: "/v1/context/user/fetch", idempotent: true },
72
73
  context_fetch_customer: { method: "POST", path: "/v1/context/customer/fetch", idempotent: true },
@@ -2130,13 +2131,28 @@ function createMemoriesInterface(transport, onForgotten) {
2130
2131
  body
2131
2132
  });
2132
2133
  },
2133
- async delete(memoryId) {
2134
+ async delete(memoryId, options) {
2135
+ const permanent = options?.permanent ?? false;
2136
+ if (typeof permanent !== "boolean") throw new InvalidInputError("permanent must be a boolean");
2134
2137
  if (!memoryId) {
2135
2138
  throw new InvalidInputError(
2136
2139
  "memory_id is required. Deleting by user is no longer supported: the previous implementation tracked ids in process memory, so it silently deleted nothing in any serverless or multi-process deployment while reporting success."
2137
2140
  );
2138
2141
  }
2139
- return transport.request("memories_delete", { pathParams: { memory_id: memoryId } });
2142
+ const r = await transport.request("memories_delete", {
2143
+ pathParams: { memory_id: memoryId },
2144
+ ...permanent ? { query: { permanent: "true" } } : {}
2145
+ });
2146
+ return {
2147
+ memory_id: String(r?.["memory_id"] ?? memoryId),
2148
+ deleted_at: String(r?.["deleted_at"] ?? ""),
2149
+ fully_removed: r?.["fully_removed"] === true,
2150
+ still_present_in: Array.isArray(r?.["still_present_in"]) ? r["still_present_in"] : [],
2151
+ source_text_kept: r?.["source_text_kept"] === true,
2152
+ status: typeof r?.["status"] === "string" && r["status"] ? r["status"] : "complete",
2153
+ purge_after: typeof r?.["purge_after"] === "string" ? r["purge_after"] : null,
2154
+ permanent: r?.["permanent"] === true
2155
+ };
2140
2156
  },
2141
2157
  async forget(options) {
2142
2158
  const o2 = options;
@@ -2633,6 +2649,7 @@ var ID_FIELD = {
2633
2649
  customer: "customer_id",
2634
2650
  conversation: "conversation_id"
2635
2651
  };
2652
+ var MAX_RESTORE_IDS = 200;
2636
2653
  function either3(o2, snake, camel) {
2637
2654
  const a = o2[snake];
2638
2655
  if (a !== void 0) return a;
@@ -2680,15 +2697,39 @@ function buildDeleteBody(options, instanceId) {
2680
2697
  throw new InvalidInputError(`confirm must equal the ${field} being deleted`);
2681
2698
  }
2682
2699
  }
2683
- return {
2700
+ const instances2 = options.instances === void 0 || options.instances === null ? null : checkInstances(options.instances);
2701
+ const permanent = options.permanent ?? false;
2702
+ if (typeof permanent !== "boolean") throw new InvalidInputError("permanent must be a boolean");
2703
+ const body = {
2684
2704
  scope,
2685
- instance_id: instanceId,
2705
+ // Without `instances` the body is byte-identical to earlier versions.
2706
+ instance_id: instances2 === null ? instanceId : null,
2686
2707
  user_id: ids["user_id"] ?? null,
2687
2708
  customer_id: ids["customer_id"] ?? null,
2688
2709
  conversation_id: ids["conversation_id"] ?? null,
2689
2710
  dry_run: dryRun,
2690
2711
  confirm
2691
2712
  };
2713
+ if (instances2 !== null) body["instance_ids"] = instances2;
2714
+ if (permanent) body["permanent"] = true;
2715
+ return body;
2716
+ }
2717
+ function checkInstances(instances2) {
2718
+ if (instances2 === "all") return "all";
2719
+ if (!Array.isArray(instances2)) {
2720
+ throw new InvalidInputError('instances must be "all" or a list of instance ids');
2721
+ }
2722
+ const out = [];
2723
+ for (const i of instances2) {
2724
+ if (typeof i !== "string" || i.trim() === "") {
2725
+ throw new InvalidInputError("instances must not contain an empty instance id");
2726
+ }
2727
+ if (!out.includes(i.trim())) out.push(i.trim());
2728
+ }
2729
+ if (out.length === 0) {
2730
+ throw new InvalidInputError('instances is empty: name at least one instance, or "all"');
2731
+ }
2732
+ return out;
2692
2733
  }
2693
2734
  function normalise(raw) {
2694
2735
  return {
@@ -2704,13 +2745,43 @@ function normalise(raw) {
2704
2745
  fully_removed: false,
2705
2746
  continue: false,
2706
2747
  kept: [],
2748
+ not_covered: [],
2707
2749
  note: null,
2708
2750
  memories_kept: false,
2709
2751
  audit: null,
2710
2752
  local_cleared: [],
2753
+ instances: [],
2754
+ not_started: [],
2755
+ deletion_ids: [],
2756
+ purge_after: null,
2711
2757
  ...raw
2712
2758
  };
2713
2759
  }
2760
+ function buildRestoreBody(memoryIds, instanceId, deletionId = null) {
2761
+ const noIds = memoryIds === null || memoryIds === void 0;
2762
+ const noDeletion = deletionId === null || deletionId === void 0;
2763
+ if (noIds === noDeletion) {
2764
+ throw new InvalidInputError("send exactly one of memory_ids or deletion_id");
2765
+ }
2766
+ if (!noDeletion) {
2767
+ if (typeof deletionId !== "string" || deletionId.trim() === "") {
2768
+ throw new InvalidInputError("deletion_id must not be empty");
2769
+ }
2770
+ return { deletion_id: deletionId.trim(), instance_id: instanceId };
2771
+ }
2772
+ if (typeof memoryIds === "string" || !Array.isArray(memoryIds)) {
2773
+ throw new InvalidInputError("memory_ids must be a list of memory ids");
2774
+ }
2775
+ const ids = memoryIds.map((i) => String(i));
2776
+ if (ids.length === 0) throw new InvalidInputError("memory_ids must not be empty");
2777
+ if (ids.length > MAX_RESTORE_IDS) {
2778
+ throw new InvalidInputError("at most " + String(MAX_RESTORE_IDS) + " memory_ids per call");
2779
+ }
2780
+ if (ids.some((i) => i.trim() === "")) {
2781
+ throw new InvalidInputError("memory_ids must not contain empty ids");
2782
+ }
2783
+ return { memory_ids: ids, instance_id: instanceId };
2784
+ }
2714
2785
  function createDataInterface(transport, onDeleted) {
2715
2786
  return {
2716
2787
  async delete(options) {
@@ -2730,7 +2801,7 @@ function createDataInterface(transport, onDeleted) {
2730
2801
  if (dryRun || !result.continue) break;
2731
2802
  }
2732
2803
  const final = result;
2733
- if (!dryRun && ["complete", "partial", "in_progress"].includes(final.status) && onDeleted) {
2804
+ if (!dryRun && ["complete", "pending_purge", "partial", "in_progress"].includes(final.status) && onDeleted) {
2734
2805
  try {
2735
2806
  final.local_cleared = onDeleted({
2736
2807
  scope: body["scope"],
@@ -2753,6 +2824,29 @@ function createDataInterface(transport, onDeleted) {
2753
2824
  query: { instance_id: transport.currentCredentials().instanceId }
2754
2825
  })
2755
2826
  );
2827
+ },
2828
+ async restore(target) {
2829
+ const instanceId = transport.currentCredentials().instanceId;
2830
+ let body;
2831
+ if (Array.isArray(target) || typeof target === "string" || target === null || target === void 0) {
2832
+ body = buildRestoreBody(target, instanceId);
2833
+ } else {
2834
+ const o2 = target;
2835
+ body = buildRestoreBody(
2836
+ either3(o2, "memory_ids", "memoryIds") ?? null,
2837
+ instanceId,
2838
+ either3(o2, "deletion_id", "deletionId") ?? null
2839
+ );
2840
+ }
2841
+ const raw = await transport.request("data_restore", { body });
2842
+ return {
2843
+ restored_ids: [],
2844
+ not_restorable_ids: [],
2845
+ still_missing_in: [],
2846
+ reindexed_ids: [],
2847
+ fully_restored: false,
2848
+ ...raw
2849
+ };
2756
2850
  }
2757
2851
  };
2758
2852
  }
@@ -3269,7 +3363,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
3269
3363
  }
3270
3364
 
3271
3365
  // src/version.ts
3272
- var SDK_VERSION = "0.7.2";
3366
+ var SDK_VERSION = "0.8.0";
3273
3367
 
3274
3368
  // src/registry.ts
3275
3369
  var instances = /* @__PURE__ */ new Map();
@@ -5969,6 +6063,7 @@ export {
5969
6063
  InvalidInstanceIdError,
5970
6064
  ListeningAlreadyActiveError,
5971
6065
  ListeningNotActiveError,
6066
+ MAX_RESTORE_IDS,
5972
6067
  MEMORY_TYPES,
5973
6068
  NetworkTimeoutError,
5974
6069
  OBJECTIVES,