@maximem/synap-js-sdk 0.4.8 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/anticipation-cache-LRE3TLK4.cjs.map +1 -1
  2. package/dist/{chunk-OCMM2Z5P.js → chunk-BWMPKLFG.js} +40 -2
  3. package/dist/chunk-BWMPKLFG.js.map +1 -0
  4. package/dist/{chunk-T5QQBJ6T.js → chunk-DJPYUPSV.js} +530 -7
  5. package/dist/chunk-DJPYUPSV.js.map +1 -0
  6. package/dist/{chunk-2TVL5IPQ.cjs → chunk-T372OL3Q.cjs} +41 -3
  7. package/dist/chunk-T372OL3Q.cjs.map +1 -0
  8. package/dist/chunk-T6U5PVAD.cjs.map +1 -1
  9. package/dist/{chunk-7CWBRHUO.cjs → chunk-WWTGJZA7.cjs} +542 -19
  10. package/dist/chunk-WWTGJZA7.cjs.map +1 -0
  11. package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
  12. package/dist/env-55ULHNJZ.cjs.map +1 -1
  13. package/dist/errors-Bl3vY1eb.d.cts +382 -0
  14. package/dist/errors-Bl3vY1eb.d.ts +382 -0
  15. package/dist/grpc/index.cjs +7 -7
  16. package/dist/grpc/index.cjs.map +1 -1
  17. package/dist/grpc/index.d.cts +50 -4
  18. package/dist/grpc/index.d.ts +50 -4
  19. package/dist/grpc/index.js +5 -5
  20. package/dist/index.cjs +278 -161
  21. package/dist/index.cjs.map +1 -1
  22. package/dist/index.d.cts +97 -148
  23. package/dist/index.d.ts +97 -148
  24. package/dist/index.js +171 -54
  25. package/dist/index.js.map +1 -1
  26. package/dist/stream-client-5CGJNTH4.js +16 -0
  27. package/dist/stream-client-GJM4YSXW.cjs +16 -0
  28. package/dist/stream-client-GJM4YSXW.cjs.map +1 -0
  29. package/package.json +1 -1
  30. package/dist/anticipation-cache-C1rUEpaW.d.cts +0 -211
  31. package/dist/anticipation-cache-C1rUEpaW.d.ts +0 -211
  32. package/dist/chunk-2TVL5IPQ.cjs.map +0 -1
  33. package/dist/chunk-7CWBRHUO.cjs.map +0 -1
  34. package/dist/chunk-OCMM2Z5P.js.map +0 -1
  35. package/dist/chunk-T5QQBJ6T.js.map +0 -1
  36. package/dist/stream-client-2C5KIOWP.js +0 -7
  37. package/dist/stream-client-GPU37E6F.cjs +0 -7
  38. package/dist/stream-client-GPU37E6F.cjs.map +0 -1
  39. /package/dist/{stream-client-2C5KIOWP.js.map → stream-client-5CGJNTH4.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as AnticipationCacheSnapshot } from './anticipation-cache-C1rUEpaW.cjs';
2
- export { b as ANY_SCOPE, A as AnticipationCache, c as AnticipationCacheOptions, B as BundleItem, C as ContextBundle, E as ExitReason, L as LookupParams, d as LookupResult, e as LookupTelemetry, S as SnapshotBundle, f as SnapshotItemPreview, g as SnapshotItemRecord } from './anticipation-cache-C1rUEpaW.cjs';
1
+ import { a as AnticipationCacheSnapshot } from './errors-Bl3vY1eb.cjs';
2
+ export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, E as ExitReason, I as InsufficientCreditsError, i as InvalidConversationIdError, j as InvalidInputError, k as InvalidInstanceIdError, L as ListeningAlreadyActiveError, l as ListeningNotActiveError, m as LookupParams, n as LookupResult, o as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, p as SDKError, q as ServiceUnavailableError, r as SessionExpiredError, s as SnapshotBundle, t as SnapshotItemPreview, u as SnapshotItemRecord, S as SynapError, v as SynapErrorCode, w as SynapErrorOptions, x as SynapPermanentError, y as SynapTransientError, T as TranscriptConflictError, z as TransientError, D as isSynapError } from './errors-Bl3vY1eb.cjs';
3
3
 
4
4
  /**
5
5
  * AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
@@ -739,6 +739,20 @@ interface RecordMessageOptions {
739
739
  session_id?: string;
740
740
  sessionId?: string;
741
741
  metadata?: Json;
742
+ /**
743
+ * The rung this conversation belongs to, named in full, e.g.
744
+ * `{ tenant: 'acme', practice: 'high_street' }`.
745
+ *
746
+ * Only relevant to a client whose ladder is deeper than the default three
747
+ * rungs (root, tenant, person). On the default ladder `customer_id` and
748
+ * `user_id` already say everything a path could.
749
+ *
750
+ * Sent as `scope` on the wire, matching Python's `scope_path`. Sending it
751
+ * once per conversation is enough: the server fills a missing path and never
752
+ * overwrites one.
753
+ */
754
+ scope_path?: Record<string, string>;
755
+ scopePath?: Record<string, string>;
742
756
  }
743
757
  interface TranscriptTurn {
744
758
  role: string;
@@ -761,6 +775,20 @@ interface IngestTranscriptOptions {
761
775
  startedAt?: string | Date;
762
776
  ended_at?: string | Date;
763
777
  endedAt?: string | Date;
778
+ /**
779
+ * The rung this conversation belongs to, named in full, e.g.
780
+ * `{ tenant: 'acme', practice: 'high_street' }`.
781
+ *
782
+ * Only relevant to a client whose ladder is deeper than the default three
783
+ * rungs (root, tenant, person). On the default ladder `customer_id` and
784
+ * `user_id` already say everything a path could.
785
+ *
786
+ * Sent as `scope` on the wire, matching Python's `scope_path`. Sending it
787
+ * once per conversation is enough: the server fills a missing path and never
788
+ * overwrites one.
789
+ */
790
+ scope_path?: Record<string, string>;
791
+ scopePath?: Record<string, string>;
764
792
  }
765
793
  /**
766
794
  * Compaction levels, mirroring Python's `CompactionLevel` enum. The JS SDK
@@ -1016,6 +1044,16 @@ interface SendMessageOptions {
1016
1044
  toolName?: string;
1017
1045
  tool_args?: Record<string, unknown>;
1018
1046
  toolArgs?: Record<string, unknown>;
1047
+ /**
1048
+ * What a tool returned. Travels in its own proto field, not in `content`: a
1049
+ * result is not something a person said, and everything that filters on
1050
+ * messages reads `content`.
1051
+ */
1052
+ tool_result?: unknown;
1053
+ toolResult?: unknown;
1054
+ /** Ties a result to the call that asked for it. */
1055
+ tool_call_id?: string;
1056
+ toolCallId?: string;
1019
1057
  search_queries?: string[];
1020
1058
  searchQueries?: string[];
1021
1059
  context_types?: string[];
@@ -1043,11 +1081,48 @@ interface RecordThinkingOptions {
1043
1081
  sessionId?: string;
1044
1082
  metadata?: Record<string, string>;
1045
1083
  }
1084
+ interface RecordToolCallOptions {
1085
+ tool_name?: string;
1086
+ toolName?: string;
1087
+ tool_args?: Record<string, unknown>;
1088
+ toolArgs?: Record<string, unknown>;
1089
+ tool_call_id?: string;
1090
+ toolCallId?: string;
1091
+ conversation_id?: string;
1092
+ conversationId?: string;
1093
+ user_id?: string;
1094
+ userId?: string;
1095
+ customer_id?: string;
1096
+ customerId?: string;
1097
+ session_id?: string;
1098
+ sessionId?: string;
1099
+ metadata?: Record<string, string>;
1100
+ }
1101
+ interface RecordToolResultOptions {
1102
+ /** JSON-encodable, or a plain string. A string is sent as itself. */
1103
+ result: unknown;
1104
+ tool_name?: string;
1105
+ toolName?: string;
1106
+ tool_call_id?: string;
1107
+ toolCallId?: string;
1108
+ conversation_id?: string;
1109
+ conversationId?: string;
1110
+ user_id?: string;
1111
+ userId?: string;
1112
+ customer_id?: string;
1113
+ customerId?: string;
1114
+ session_id?: string;
1115
+ sessionId?: string;
1116
+ metadata?: Record<string, string>;
1117
+ }
1046
1118
  interface InstanceNamespace {
1047
1119
  listen(options?: ListenOptions): Promise<void>;
1048
1120
  stop_listening(): Promise<void>;
1049
1121
  send_message(options: SendMessageOptions): Promise<void>;
1050
1122
  record_thinking(options: RecordThinkingOptions): Promise<void>;
1123
+ record_tool_call(options: RecordToolCallOptions): Promise<void>;
1124
+ record_tool_result(options: RecordToolResultOptions): Promise<void>;
1125
+ end_session(conversationId: string): Promise<void>;
1051
1126
  /** Property, not a method, matching Python's InstanceInterface.is_listening. */
1052
1127
  readonly is_listening: boolean;
1053
1128
  /** Not in Python: lets the compaction subscriptions share this one stream. */
@@ -1273,11 +1348,20 @@ interface ConfigureOptions {
1273
1348
  /** Replaces the diagnostic sink, same as the constructor option. */
1274
1349
  logger?: SynapLogger | undefined;
1275
1350
  }
1276
- /** Options for the cross-scope `fetch()`. Snake_case, matching Python's kwargs. */
1351
+ /** Options for the cross-scope `fetch()`. Snake_case, matching Python's kwargs.
1352
+ *
1353
+ * The three identifiers accept `null` as well as `undefined`, because that is
1354
+ * what callers actually pass: `conversation_id: convId || null` is the normal
1355
+ * way to say "there is no conversation here", and `validateConversationId`
1356
+ * has always treated `null` as absent. The declared type said otherwise, so
1357
+ * the `SynapClient`-to-`SynapSdkLike` assignability test in
1358
+ * `synap-claude-agent` (TS) could not typecheck, and the scope guards below
1359
+ * did not agree with the validator either. See the guards for that half.
1360
+ */
1277
1361
  interface UnifiedFetchOptions {
1278
- conversation_id?: string;
1279
- user_id?: string;
1280
- customer_id?: string;
1362
+ conversation_id?: string | null;
1363
+ user_id?: string | null;
1364
+ customer_id?: string | null;
1281
1365
  search_query?: string[];
1282
1366
  max_results?: number;
1283
1367
  types?: string[];
@@ -1446,149 +1530,14 @@ declare class SynapClient {
1446
1530
  * Until that step existed nothing kept it in sync, so this constant sat at
1447
1531
  * 1.0.0-beta.0 while the package shipped 0.4.x, and every request's User-Agent
1448
1532
  * and every telemetry event reported a version that was never released.
1449
- */
1450
- declare const SDK_VERSION = "0.4.7";
1451
-
1452
- /**
1453
- * Synap SDK error taxonomy.
1454
- *
1455
- * Mirrors `maximem_synap/models/errors.py` 1:1, including the four
1456
- * backward-compatibility aliases at the bottom. If you add an error to one
1457
- * SDK, add it to the other in the same change.
1458
- *
1459
- * ## Why every error carries a `.code`
1460
- *
1461
- * This package ships dual ESM + CJS. A consumer whose dependency graph pulls
1462
- * in both formats gets *two* copies of every class in this file, and then:
1463
- *
1464
- * try { ... } catch (e) { if (e instanceof SynapError) { ... } }
1465
- *
1466
- * silently evaluates to `false` against the copy from the other format. Error
1467
- * handling stops working and nothing throws to tell you. `.code` is a plain
1468
- * string, so it is immune. Prefer it at package boundaries:
1469
- *
1470
- * if (isSynapError(e) && e.code === 'rate_limit') { ... }
1471
- *
1472
- * `Symbol.hasInstance` is also wired up on the base class, so `instanceof`
1473
- * works across realms too -- but `.code` is the documented contract.
1474
- */
1475
- /** Stable, format-independent discriminators. Never renumber or reuse. */
1476
- type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
1477
- interface SynapErrorOptions {
1478
- correlationId?: string | null;
1479
- cause?: unknown;
1480
- }
1481
- declare class SynapError extends Error {
1482
- /**
1483
- * The single declaration site for each subclass's code.
1484
- *
1485
- * It is `static` rather than a class field on purpose. Under
1486
- * `useDefineForClassFields` (the default at our ES2022 target) a class field
1487
- * is an *instance* property, so it is invisible from the constructor object.
1488
- * `Symbol.hasInstance` below only has the constructor to work with, so a
1489
- * field would leave it unable to tell `AuthenticationError` from
1490
- * `RateLimitError` -- it would report every Synap error as an instance of
1491
- * every other one.
1492
- */
1493
- static readonly errorCode: SynapErrorCode;
1494
- /** True for errors where a retry may succeed. Static for the same reason. */
1495
- static readonly isTransient: boolean;
1496
- /** Own, enumerable, so logs and JSON.stringify include it. */
1497
- readonly code: SynapErrorCode;
1498
- readonly correlationId: string | null;
1499
- readonly transient: boolean;
1500
- constructor(message: string, options?: SynapErrorOptions);
1501
- static [Symbol.hasInstance](instance: unknown): boolean;
1502
- }
1503
- /** Type guard that works across ESM/CJS copies and realms. */
1504
- declare function isSynapError(e: unknown): e is SynapError;
1505
- declare class SynapTransientError extends SynapError {
1506
- static readonly errorCode: SynapErrorCode;
1507
- static readonly isTransient: boolean;
1508
- }
1509
- declare class SynapPermanentError extends SynapError {
1510
- static readonly errorCode: SynapErrorCode;
1511
- static readonly isTransient: boolean;
1512
- }
1513
- declare class NetworkTimeoutError extends SynapTransientError {
1514
- static readonly errorCode: SynapErrorCode;
1515
- }
1516
- declare class RateLimitError extends SynapTransientError {
1517
- static readonly errorCode: SynapErrorCode;
1518
- readonly retryAfterSeconds: number | null;
1519
- constructor(message: string, options?: SynapErrorOptions & {
1520
- retryAfterSeconds?: number | null;
1521
- });
1522
- }
1523
- declare class ServiceUnavailableError extends SynapTransientError {
1524
- static readonly errorCode: SynapErrorCode;
1525
- }
1526
- declare class AgentUnavailableError extends SynapTransientError {
1527
- static readonly errorCode: SynapErrorCode;
1528
- constructor(message?: string, options?: SynapErrorOptions);
1529
- }
1530
- /**
1531
- * The caller's credit wallet cannot cover this request.
1532
1533
  *
1533
- * HTTP 402, and gRPC RESOURCE_EXHAUSTED with credit-related trailing metadata.
1534
- * Permanent by design: retrying without topping up burns quota and never
1535
- * succeeds. This is the error behind "the agent forgot" reports where retrieval
1536
- * silently returns nothing.
1537
- */
1538
- declare class InsufficientCreditsError extends SynapPermanentError {
1539
- static readonly errorCode: SynapErrorCode;
1540
- readonly balanceCredits: number | null;
1541
- readonly requiredCredits: number | null;
1542
- /** Where the balance can be viewed. Python calls this `recovery_url`. */
1543
- readonly recoveryUrl: string | null;
1544
- /** Where a redeem code can be entered. Python calls this `redeem_url`. */
1545
- readonly redeemUrl: string | null;
1546
- constructor(message: string, options?: SynapErrorOptions & {
1547
- balanceCredits?: number | null;
1548
- requiredCredits?: number | null;
1549
- recoveryUrl?: string | null;
1550
- redeemUrl?: string | null;
1551
- });
1552
- }
1553
- declare class InvalidInputError extends SynapPermanentError {
1554
- static readonly errorCode: SynapErrorCode;
1555
- }
1556
- /**
1557
- * Raised by `validateInstanceId` before any network call, matching Python's
1558
- * `utils/validators.py`. The message text is identical in both SDKs.
1534
+ * ⚠ The workflow only covers a workflow release. 0.4.8 was published by hand
1535
+ * and shipped reporting 0.4.7, so every request from it carries a User-Agent
1536
+ * for a version it is not. `version-matches-package.test.ts` now fails the
1537
+ * build when the two disagree, which is the only thing that makes a manual
1538
+ * publish safe.
1559
1539
  */
1560
- declare class InvalidInstanceIdError extends InvalidInputError {
1561
- static readonly errorCode: SynapErrorCode;
1562
- }
1563
- /** See the note on InvalidInstanceIdError. Raised by `validateConversationId`. */
1564
- declare class InvalidConversationIdError extends InvalidInputError {
1565
- static readonly errorCode: SynapErrorCode;
1566
- }
1567
- declare class AuthenticationError extends SynapPermanentError {
1568
- static readonly errorCode: SynapErrorCode;
1569
- }
1570
- declare class ContextNotFoundError extends SynapPermanentError {
1571
- static readonly errorCode: SynapErrorCode;
1572
- }
1573
- declare class ConflictError extends SynapPermanentError {
1574
- static readonly errorCode: SynapErrorCode;
1575
- }
1576
- declare class TranscriptConflictError extends ConflictError {
1577
- static readonly errorCode: SynapErrorCode;
1578
- }
1579
- declare class SessionExpiredError extends SynapPermanentError {
1580
- static readonly errorCode: SynapErrorCode;
1581
- }
1582
- declare class ListeningAlreadyActiveError extends SynapPermanentError {
1583
- static readonly errorCode: SynapErrorCode;
1584
- }
1585
- declare class ListeningNotActiveError extends SynapPermanentError {
1586
- static readonly errorCode: SynapErrorCode;
1587
- }
1588
- declare const SDKError: typeof SynapError;
1589
- declare const TransientError: typeof SynapTransientError;
1590
- declare const PermanentError: typeof SynapPermanentError;
1591
- declare const ConnectionError: typeof NetworkTimeoutError;
1540
+ declare const SDK_VERSION = "0.5.2";
1592
1541
 
1593
1542
  /**
1594
1543
  * BM25 scorer for the anticipation cache.
@@ -1744,4 +1693,4 @@ interface SynapSdkLike {
1744
1693
  };
1745
1694
  }
1746
1695
 
1747
- export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, 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, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, type SynapLogLevel, type SynapLogger, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptIngestResult, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
1696
+ 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 };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as AnticipationCacheSnapshot } from './anticipation-cache-C1rUEpaW.js';
2
- export { b as ANY_SCOPE, A as AnticipationCache, c as AnticipationCacheOptions, B as BundleItem, C as ContextBundle, E as ExitReason, L as LookupParams, d as LookupResult, e as LookupTelemetry, S as SnapshotBundle, f as SnapshotItemPreview, g as SnapshotItemRecord } from './anticipation-cache-C1rUEpaW.js';
1
+ import { a as AnticipationCacheSnapshot } from './errors-Bl3vY1eb.js';
2
+ export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, E as ExitReason, I as InsufficientCreditsError, i as InvalidConversationIdError, j as InvalidInputError, k as InvalidInstanceIdError, L as ListeningAlreadyActiveError, l as ListeningNotActiveError, m as LookupParams, n as LookupResult, o as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, p as SDKError, q as ServiceUnavailableError, r as SessionExpiredError, s as SnapshotBundle, t as SnapshotItemPreview, u as SnapshotItemRecord, S as SynapError, v as SynapErrorCode, w as SynapErrorOptions, x as SynapPermanentError, y as SynapTransientError, T as TranscriptConflictError, z as TransientError, D as isSynapError } from './errors-Bl3vY1eb.js';
3
3
 
4
4
  /**
5
5
  * AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
@@ -739,6 +739,20 @@ interface RecordMessageOptions {
739
739
  session_id?: string;
740
740
  sessionId?: string;
741
741
  metadata?: Json;
742
+ /**
743
+ * The rung this conversation belongs to, named in full, e.g.
744
+ * `{ tenant: 'acme', practice: 'high_street' }`.
745
+ *
746
+ * Only relevant to a client whose ladder is deeper than the default three
747
+ * rungs (root, tenant, person). On the default ladder `customer_id` and
748
+ * `user_id` already say everything a path could.
749
+ *
750
+ * Sent as `scope` on the wire, matching Python's `scope_path`. Sending it
751
+ * once per conversation is enough: the server fills a missing path and never
752
+ * overwrites one.
753
+ */
754
+ scope_path?: Record<string, string>;
755
+ scopePath?: Record<string, string>;
742
756
  }
743
757
  interface TranscriptTurn {
744
758
  role: string;
@@ -761,6 +775,20 @@ interface IngestTranscriptOptions {
761
775
  startedAt?: string | Date;
762
776
  ended_at?: string | Date;
763
777
  endedAt?: string | Date;
778
+ /**
779
+ * The rung this conversation belongs to, named in full, e.g.
780
+ * `{ tenant: 'acme', practice: 'high_street' }`.
781
+ *
782
+ * Only relevant to a client whose ladder is deeper than the default three
783
+ * rungs (root, tenant, person). On the default ladder `customer_id` and
784
+ * `user_id` already say everything a path could.
785
+ *
786
+ * Sent as `scope` on the wire, matching Python's `scope_path`. Sending it
787
+ * once per conversation is enough: the server fills a missing path and never
788
+ * overwrites one.
789
+ */
790
+ scope_path?: Record<string, string>;
791
+ scopePath?: Record<string, string>;
764
792
  }
765
793
  /**
766
794
  * Compaction levels, mirroring Python's `CompactionLevel` enum. The JS SDK
@@ -1016,6 +1044,16 @@ interface SendMessageOptions {
1016
1044
  toolName?: string;
1017
1045
  tool_args?: Record<string, unknown>;
1018
1046
  toolArgs?: Record<string, unknown>;
1047
+ /**
1048
+ * What a tool returned. Travels in its own proto field, not in `content`: a
1049
+ * result is not something a person said, and everything that filters on
1050
+ * messages reads `content`.
1051
+ */
1052
+ tool_result?: unknown;
1053
+ toolResult?: unknown;
1054
+ /** Ties a result to the call that asked for it. */
1055
+ tool_call_id?: string;
1056
+ toolCallId?: string;
1019
1057
  search_queries?: string[];
1020
1058
  searchQueries?: string[];
1021
1059
  context_types?: string[];
@@ -1043,11 +1081,48 @@ interface RecordThinkingOptions {
1043
1081
  sessionId?: string;
1044
1082
  metadata?: Record<string, string>;
1045
1083
  }
1084
+ interface RecordToolCallOptions {
1085
+ tool_name?: string;
1086
+ toolName?: string;
1087
+ tool_args?: Record<string, unknown>;
1088
+ toolArgs?: Record<string, unknown>;
1089
+ tool_call_id?: string;
1090
+ toolCallId?: string;
1091
+ conversation_id?: string;
1092
+ conversationId?: string;
1093
+ user_id?: string;
1094
+ userId?: string;
1095
+ customer_id?: string;
1096
+ customerId?: string;
1097
+ session_id?: string;
1098
+ sessionId?: string;
1099
+ metadata?: Record<string, string>;
1100
+ }
1101
+ interface RecordToolResultOptions {
1102
+ /** JSON-encodable, or a plain string. A string is sent as itself. */
1103
+ result: unknown;
1104
+ tool_name?: string;
1105
+ toolName?: string;
1106
+ tool_call_id?: string;
1107
+ toolCallId?: string;
1108
+ conversation_id?: string;
1109
+ conversationId?: string;
1110
+ user_id?: string;
1111
+ userId?: string;
1112
+ customer_id?: string;
1113
+ customerId?: string;
1114
+ session_id?: string;
1115
+ sessionId?: string;
1116
+ metadata?: Record<string, string>;
1117
+ }
1046
1118
  interface InstanceNamespace {
1047
1119
  listen(options?: ListenOptions): Promise<void>;
1048
1120
  stop_listening(): Promise<void>;
1049
1121
  send_message(options: SendMessageOptions): Promise<void>;
1050
1122
  record_thinking(options: RecordThinkingOptions): Promise<void>;
1123
+ record_tool_call(options: RecordToolCallOptions): Promise<void>;
1124
+ record_tool_result(options: RecordToolResultOptions): Promise<void>;
1125
+ end_session(conversationId: string): Promise<void>;
1051
1126
  /** Property, not a method, matching Python's InstanceInterface.is_listening. */
1052
1127
  readonly is_listening: boolean;
1053
1128
  /** Not in Python: lets the compaction subscriptions share this one stream. */
@@ -1273,11 +1348,20 @@ interface ConfigureOptions {
1273
1348
  /** Replaces the diagnostic sink, same as the constructor option. */
1274
1349
  logger?: SynapLogger | undefined;
1275
1350
  }
1276
- /** Options for the cross-scope `fetch()`. Snake_case, matching Python's kwargs. */
1351
+ /** Options for the cross-scope `fetch()`. Snake_case, matching Python's kwargs.
1352
+ *
1353
+ * The three identifiers accept `null` as well as `undefined`, because that is
1354
+ * what callers actually pass: `conversation_id: convId || null` is the normal
1355
+ * way to say "there is no conversation here", and `validateConversationId`
1356
+ * has always treated `null` as absent. The declared type said otherwise, so
1357
+ * the `SynapClient`-to-`SynapSdkLike` assignability test in
1358
+ * `synap-claude-agent` (TS) could not typecheck, and the scope guards below
1359
+ * did not agree with the validator either. See the guards for that half.
1360
+ */
1277
1361
  interface UnifiedFetchOptions {
1278
- conversation_id?: string;
1279
- user_id?: string;
1280
- customer_id?: string;
1362
+ conversation_id?: string | null;
1363
+ user_id?: string | null;
1364
+ customer_id?: string | null;
1281
1365
  search_query?: string[];
1282
1366
  max_results?: number;
1283
1367
  types?: string[];
@@ -1446,149 +1530,14 @@ declare class SynapClient {
1446
1530
  * Until that step existed nothing kept it in sync, so this constant sat at
1447
1531
  * 1.0.0-beta.0 while the package shipped 0.4.x, and every request's User-Agent
1448
1532
  * and every telemetry event reported a version that was never released.
1449
- */
1450
- declare const SDK_VERSION = "0.4.7";
1451
-
1452
- /**
1453
- * Synap SDK error taxonomy.
1454
- *
1455
- * Mirrors `maximem_synap/models/errors.py` 1:1, including the four
1456
- * backward-compatibility aliases at the bottom. If you add an error to one
1457
- * SDK, add it to the other in the same change.
1458
- *
1459
- * ## Why every error carries a `.code`
1460
- *
1461
- * This package ships dual ESM + CJS. A consumer whose dependency graph pulls
1462
- * in both formats gets *two* copies of every class in this file, and then:
1463
- *
1464
- * try { ... } catch (e) { if (e instanceof SynapError) { ... } }
1465
- *
1466
- * silently evaluates to `false` against the copy from the other format. Error
1467
- * handling stops working and nothing throws to tell you. `.code` is a plain
1468
- * string, so it is immune. Prefer it at package boundaries:
1469
- *
1470
- * if (isSynapError(e) && e.code === 'rate_limit') { ... }
1471
- *
1472
- * `Symbol.hasInstance` is also wired up on the base class, so `instanceof`
1473
- * works across realms too -- but `.code` is the documented contract.
1474
- */
1475
- /** Stable, format-independent discriminators. Never renumber or reuse. */
1476
- type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
1477
- interface SynapErrorOptions {
1478
- correlationId?: string | null;
1479
- cause?: unknown;
1480
- }
1481
- declare class SynapError extends Error {
1482
- /**
1483
- * The single declaration site for each subclass's code.
1484
- *
1485
- * It is `static` rather than a class field on purpose. Under
1486
- * `useDefineForClassFields` (the default at our ES2022 target) a class field
1487
- * is an *instance* property, so it is invisible from the constructor object.
1488
- * `Symbol.hasInstance` below only has the constructor to work with, so a
1489
- * field would leave it unable to tell `AuthenticationError` from
1490
- * `RateLimitError` -- it would report every Synap error as an instance of
1491
- * every other one.
1492
- */
1493
- static readonly errorCode: SynapErrorCode;
1494
- /** True for errors where a retry may succeed. Static for the same reason. */
1495
- static readonly isTransient: boolean;
1496
- /** Own, enumerable, so logs and JSON.stringify include it. */
1497
- readonly code: SynapErrorCode;
1498
- readonly correlationId: string | null;
1499
- readonly transient: boolean;
1500
- constructor(message: string, options?: SynapErrorOptions);
1501
- static [Symbol.hasInstance](instance: unknown): boolean;
1502
- }
1503
- /** Type guard that works across ESM/CJS copies and realms. */
1504
- declare function isSynapError(e: unknown): e is SynapError;
1505
- declare class SynapTransientError extends SynapError {
1506
- static readonly errorCode: SynapErrorCode;
1507
- static readonly isTransient: boolean;
1508
- }
1509
- declare class SynapPermanentError extends SynapError {
1510
- static readonly errorCode: SynapErrorCode;
1511
- static readonly isTransient: boolean;
1512
- }
1513
- declare class NetworkTimeoutError extends SynapTransientError {
1514
- static readonly errorCode: SynapErrorCode;
1515
- }
1516
- declare class RateLimitError extends SynapTransientError {
1517
- static readonly errorCode: SynapErrorCode;
1518
- readonly retryAfterSeconds: number | null;
1519
- constructor(message: string, options?: SynapErrorOptions & {
1520
- retryAfterSeconds?: number | null;
1521
- });
1522
- }
1523
- declare class ServiceUnavailableError extends SynapTransientError {
1524
- static readonly errorCode: SynapErrorCode;
1525
- }
1526
- declare class AgentUnavailableError extends SynapTransientError {
1527
- static readonly errorCode: SynapErrorCode;
1528
- constructor(message?: string, options?: SynapErrorOptions);
1529
- }
1530
- /**
1531
- * The caller's credit wallet cannot cover this request.
1532
1533
  *
1533
- * HTTP 402, and gRPC RESOURCE_EXHAUSTED with credit-related trailing metadata.
1534
- * Permanent by design: retrying without topping up burns quota and never
1535
- * succeeds. This is the error behind "the agent forgot" reports where retrieval
1536
- * silently returns nothing.
1537
- */
1538
- declare class InsufficientCreditsError extends SynapPermanentError {
1539
- static readonly errorCode: SynapErrorCode;
1540
- readonly balanceCredits: number | null;
1541
- readonly requiredCredits: number | null;
1542
- /** Where the balance can be viewed. Python calls this `recovery_url`. */
1543
- readonly recoveryUrl: string | null;
1544
- /** Where a redeem code can be entered. Python calls this `redeem_url`. */
1545
- readonly redeemUrl: string | null;
1546
- constructor(message: string, options?: SynapErrorOptions & {
1547
- balanceCredits?: number | null;
1548
- requiredCredits?: number | null;
1549
- recoveryUrl?: string | null;
1550
- redeemUrl?: string | null;
1551
- });
1552
- }
1553
- declare class InvalidInputError extends SynapPermanentError {
1554
- static readonly errorCode: SynapErrorCode;
1555
- }
1556
- /**
1557
- * Raised by `validateInstanceId` before any network call, matching Python's
1558
- * `utils/validators.py`. The message text is identical in both SDKs.
1534
+ * ⚠ The workflow only covers a workflow release. 0.4.8 was published by hand
1535
+ * and shipped reporting 0.4.7, so every request from it carries a User-Agent
1536
+ * for a version it is not. `version-matches-package.test.ts` now fails the
1537
+ * build when the two disagree, which is the only thing that makes a manual
1538
+ * publish safe.
1559
1539
  */
1560
- declare class InvalidInstanceIdError extends InvalidInputError {
1561
- static readonly errorCode: SynapErrorCode;
1562
- }
1563
- /** See the note on InvalidInstanceIdError. Raised by `validateConversationId`. */
1564
- declare class InvalidConversationIdError extends InvalidInputError {
1565
- static readonly errorCode: SynapErrorCode;
1566
- }
1567
- declare class AuthenticationError extends SynapPermanentError {
1568
- static readonly errorCode: SynapErrorCode;
1569
- }
1570
- declare class ContextNotFoundError extends SynapPermanentError {
1571
- static readonly errorCode: SynapErrorCode;
1572
- }
1573
- declare class ConflictError extends SynapPermanentError {
1574
- static readonly errorCode: SynapErrorCode;
1575
- }
1576
- declare class TranscriptConflictError extends ConflictError {
1577
- static readonly errorCode: SynapErrorCode;
1578
- }
1579
- declare class SessionExpiredError extends SynapPermanentError {
1580
- static readonly errorCode: SynapErrorCode;
1581
- }
1582
- declare class ListeningAlreadyActiveError extends SynapPermanentError {
1583
- static readonly errorCode: SynapErrorCode;
1584
- }
1585
- declare class ListeningNotActiveError extends SynapPermanentError {
1586
- static readonly errorCode: SynapErrorCode;
1587
- }
1588
- declare const SDKError: typeof SynapError;
1589
- declare const TransientError: typeof SynapTransientError;
1590
- declare const PermanentError: typeof SynapPermanentError;
1591
- declare const ConnectionError: typeof NetworkTimeoutError;
1540
+ declare const SDK_VERSION = "0.5.2";
1592
1541
 
1593
1542
  /**
1594
1543
  * BM25 scorer for the anticipation cache.
@@ -1744,4 +1693,4 @@ interface SynapSdkLike {
1744
1693
  };
1745
1694
  }
1746
1695
 
1747
- export { AgentUnavailableError, type AnthropicToolDefinition, AnticipationCacheSnapshot, type AsToolOptions, AuthenticationError, BM25, type BatchCreateResult, COMPACTION_LEVELS, CONTRACT, type CacheNamespace, type CacheStats, type CompactOptions, type CompactionCallback, type CompactionLevel, type ConfigureOptions, ConflictError, ConnectionError, type ContextMetadata, ContextNotFoundError, 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, InsufficientCreditsError, InvalidConversationIdError, InvalidInputError, InvalidInstanceIdError, type ItemCollection, type Json, type LedgerOptions, type ListenOptions, ListeningAlreadyActiveError, ListeningNotActiveError, type MemoriesInterface, NetworkTimeoutError, type NormalisedContext, type OpenAiToolDefinition, PermanentError, type Preference, RateLimitError, type RawContext, type RawContextItem, type RawConversationContext, type RecordMessageOptions, type RecordThinkingOptions, type RedeemResult, type RequestOptions, type RetryPolicy, SDKError, SDK_VERSION, type Scope, type SendMessageOptions, ServiceUnavailableError, SessionExpiredError, SynapClient, type SynapClientOptions, SynapError, type SynapErrorCode, type SynapErrorOptions, type SynapLogLevel, type SynapLogger, SynapPermanentError, type SynapSdkLike, SynapTransientError, THRESHOLDS, type TemporalEvent, type TemporalFields, type TimeoutConfig, type ToolDefinition, type ToolHandler, type ToolScope, type ToolStyle, TranscriptConflictError, type TranscriptIngestResult, type TranscriptTurn, TransientError, type UnifiedContext, type UnifiedFetchOptions, type UpdateMemoryOptions, type UserNamespace, type WaitOptions, type WriteInvalidator, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, isSynapError, mergeScopeResults, resolvePath, shouldRetry, stem, tokenize };
1696
+ 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 };