@maximem/synap-js-sdk 0.5.8 → 0.5.10

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 (47) hide show
  1. package/README.md +5 -1
  2. package/dist/anticipation-cache-LPNKMRBH.cjs +20 -0
  3. package/dist/anticipation-cache-LPNKMRBH.cjs.map +1 -0
  4. package/dist/anticipation-cache-RWKF55J4.js +20 -0
  5. package/dist/{chunk-FXGLT6AT.js → chunk-I7TWR4S6.js} +59 -3
  6. package/dist/chunk-I7TWR4S6.js.map +1 -0
  7. package/dist/{chunk-T6U5PVAD.cjs → chunk-ICUFS3B5.cjs} +449 -12
  8. package/dist/chunk-ICUFS3B5.cjs.map +1 -0
  9. package/dist/{chunk-ODVOQOSO.js → chunk-R72YL6Q4.js} +445 -8
  10. package/dist/chunk-R72YL6Q4.js.map +1 -0
  11. package/dist/{chunk-HCULAVJC.cjs → chunk-RE4DDIWO.cjs} +66 -10
  12. package/dist/chunk-RE4DDIWO.cjs.map +1 -0
  13. package/dist/chunk-T372OL3Q.cjs.map +1 -1
  14. package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
  15. package/dist/env-55ULHNJZ.cjs.map +1 -1
  16. package/dist/{errors-Bl3vY1eb.d.cts → errors-Bdayqlzy.d.cts} +88 -2
  17. package/dist/{errors-Bl3vY1eb.d.ts → errors-Bdayqlzy.d.ts} +88 -2
  18. package/dist/grpc/index.cjs +4 -4
  19. package/dist/grpc/index.cjs.map +1 -1
  20. package/dist/grpc/index.d.cts +8 -3
  21. package/dist/grpc/index.d.ts +8 -3
  22. package/dist/grpc/index.js +3 -3
  23. package/dist/index.cjs +1357 -128
  24. package/dist/index.cjs.map +1 -1
  25. package/dist/index.d.cts +277 -11
  26. package/dist/index.d.ts +277 -11
  27. package/dist/index.js +1309 -80
  28. package/dist/index.js.map +1 -1
  29. package/dist/onnx-encoder-4RSL6ID4.cjs +103 -0
  30. package/dist/onnx-encoder-4RSL6ID4.cjs.map +1 -0
  31. package/dist/onnx-encoder-NP35KH4H.js +103 -0
  32. package/dist/onnx-encoder-NP35KH4H.js.map +1 -0
  33. package/dist/{stream-client-VWKINE47.js → stream-client-3WHXGW4U.js} +2 -2
  34. package/dist/stream-client-L6OQPZN7.cjs +16 -0
  35. package/dist/stream-client-L6OQPZN7.cjs.map +1 -0
  36. package/package.json +4 -2
  37. package/dist/anticipation-cache-LRE3TLK4.cjs +0 -14
  38. package/dist/anticipation-cache-LRE3TLK4.cjs.map +0 -1
  39. package/dist/anticipation-cache-WLU4NMD5.js +0 -14
  40. package/dist/chunk-FXGLT6AT.js.map +0 -1
  41. package/dist/chunk-HCULAVJC.cjs.map +0 -1
  42. package/dist/chunk-ODVOQOSO.js.map +0 -1
  43. package/dist/chunk-T6U5PVAD.cjs.map +0 -1
  44. package/dist/stream-client-N46JBT5A.cjs +0 -16
  45. package/dist/stream-client-N46JBT5A.cjs.map +0 -1
  46. /package/dist/{anticipation-cache-WLU4NMD5.js.map → anticipation-cache-RWKF55J4.js.map} +0 -0
  47. /package/dist/{stream-client-VWKINE47.js.map → stream-client-3WHXGW4U.js.map} +0 -0
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ import { E as Encoder, a as AnticipationCacheSnapshot } from './errors-Bdayqlzy.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, i as ExitReason, I as InsufficientCreditsError, j as InvalidConversationIdError, k as InvalidInputError, l as InvalidInstanceIdError, L as ListeningAlreadyActiveError, m as ListeningNotActiveError, n as LookupParams, o as LookupResult, p as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, q as SDKError, r as ServiceUnavailableError, s as SessionExpiredError, t as SnapshotBundle, u as SnapshotItemPreview, v as SnapshotItemRecord, S as SynapError, w as SynapErrorCode, x as SynapErrorOptions, y as SynapPermanentError, z as SynapTransientError, T as TranscriptConflictError, D as TransientError, F as isSynapError } from './errors-Bdayqlzy.cjs';
3
3
 
4
4
  /**
5
5
  * AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
@@ -90,6 +90,11 @@ declare const ENDPOINTS: {
90
90
  readonly path: "/v1/conversations/{conversation_id}/context-for-prompt";
91
91
  readonly idempotent: true;
92
92
  };
93
+ readonly conversation_turns: {
94
+ readonly method: "GET";
95
+ readonly path: "/v1/conversations/{conversation_id}/messages";
96
+ readonly idempotent: true;
97
+ };
93
98
  readonly conversations_ingest: {
94
99
  readonly method: "POST";
95
100
  readonly path: "/v1/conversations/ingest";
@@ -321,6 +326,15 @@ declare class HttpTransport {
321
326
  * deployment older than the field, and must mean "enforce nothing".
322
327
  */
323
328
  userContextIsolation: string | undefined;
329
+ /**
330
+ * Set by the client to its identity resolution (`initialize()`'s whoami).
331
+ * Python refuses every call before `initialize()`; here the first request
332
+ * runs it instead, so a caller who skips it gets the same identity-dependent
333
+ * behaviour (client-scope cache hits, the B2C check) rather than an error.
334
+ */
335
+ identityResolver: (() => Promise<void>) | undefined;
336
+ /** Resolve identity once, before the first request. Never throws. */
337
+ ready(): Promise<void>;
324
338
  /** Refuse a customer_id on a B2C instance, at the call site. */
325
339
  checkCustomerId(customerId: unknown, where: string): void;
326
340
  setTimeouts(timeouts: Partial<TimeoutConfig>): void;
@@ -422,6 +436,14 @@ interface RawContext {
422
436
  episodes?: RawContextItem[];
423
437
  emotions?: RawContextItem[];
424
438
  temporal_events?: RawContextItem[];
439
+ /**
440
+ * `response_shape: "ranked"` only: every item once, best first across
441
+ * types, each with `rank`, `category` and `metadata.rank_score`. The five
442
+ * lists above are then views of these same items, by type.
443
+ */
444
+ items?: RawContextItem[];
445
+ /** `response_shape: "ranked"` only: the chunks, quotes from source documents. */
446
+ excerpts?: RawContextItem[];
425
447
  conversation_context?: RawConversationContext | null;
426
448
  metadata?: Json;
427
449
  [key: string]: unknown;
@@ -533,6 +555,25 @@ interface ContextMetadata {
533
555
  retrievedAt: string | null;
534
556
  compactionApplied: boolean | null;
535
557
  }
558
+ /**
559
+ * Why a fetch may be thinner than the stores can support. Null when healthy.
560
+ *
561
+ * `degraded` says something went wrong, `level` how thin the answer is
562
+ * ("partial" | "minimal" | "failed"), and `code` whether a retry is worth it
563
+ * ("timeout" | "overloaded" | "unavailable" | "internal"). The server never
564
+ * names which of its services broke.
565
+ *
566
+ * It had no slot here, and that is how a real failure stayed invisible: a
567
+ * retrieval that lost its embedding call returned 200 with zero items for a
568
+ * user holding 122 memories, and the caller could not tell that from "no
569
+ * relevant memories".
570
+ */
571
+ interface RetrievalHealth {
572
+ degraded: boolean;
573
+ level: string | null;
574
+ code: string | null;
575
+ warnings: string[];
576
+ }
536
577
  interface NormalisedContext {
537
578
  facts: Fact[];
538
579
  preferences: Preference[];
@@ -541,7 +582,17 @@ interface NormalisedContext {
541
582
  temporalEvents: TemporalEvent[];
542
583
  conversationContext: ConversationContext | null;
543
584
  metadata: ContextMetadata;
585
+ retrieval: RetrievalHealth | null;
544
586
  rawResponse: Json;
587
+ /**
588
+ * `response_shape: "ranked"` only, and absent otherwise: every item once, best
589
+ * first across types, as the wire sends it (snake_case, with `rank`,
590
+ * `category` and `metadata.rank_score`). The five lists above hold the same
591
+ * items by type, except the chunks, which are in `excerpts`.
592
+ */
593
+ items?: RawContextItem[];
594
+ /** `response_shape: "ranked"` only, and absent otherwise: the chunks, quotes from source documents. */
595
+ excerpts?: RawContextItem[];
545
596
  }
546
597
  /**
547
598
  * Fetch options.
@@ -611,6 +662,18 @@ interface FetchOptions {
611
662
  /** Explicit scope ladder. Sent as `scope` when supplied. */
612
663
  scope_path?: Record<string, string>;
613
664
  scopePath?: Record<string, string>;
665
+ /**
666
+ * `"by_type"` (default): the five typed lists, as every earlier SDK version
667
+ * got them. `"ranked"`: also `items`, every item once in the order the
668
+ * server ranked them across types, with chunks typed as `excerpts`; the
669
+ * typed lists are then views of those items.
670
+ *
671
+ * Sent only when `"ranked"`, so a default fetch sends the body it always
672
+ * did. A server that predates the parameter returns the five lists, and the
673
+ * SDK then builds `items` from them by `metadata.rank_score`.
674
+ */
675
+ response_shape?: string;
676
+ responseShape?: string;
614
677
  }
615
678
 
616
679
  /**
@@ -913,6 +976,15 @@ interface RecordMessageOptions {
913
976
  */
914
977
  scope_path?: Record<string, string>;
915
978
  scopePath?: Record<string, string>;
979
+ /**
980
+ * The model the agent runs on, e.g. `'gpt-4o'`. Overrides the client's
981
+ * `agent_model` for this turn. The server sizes compaction to this model's
982
+ * context window. Python's `model=`.
983
+ */
984
+ model?: string;
985
+ /** The agent model's context window in tokens, for a model the server would not know. */
986
+ context_window?: number;
987
+ contextWindow?: number;
916
988
  }
917
989
  interface TranscriptTurn {
918
990
  role: string;
@@ -995,6 +1067,11 @@ interface ConversationNamespace {
995
1067
  conversation_id?: string;
996
1068
  conversationId?: string;
997
1069
  style?: string;
1070
+ /** Search the earlier turns locally after a compaction (default true). */
1071
+ search_history?: boolean;
1072
+ searchHistory?: boolean;
1073
+ /** What to search for; defaults to the latest user message. */
1074
+ query?: string;
998
1075
  }): Promise<Json>;
999
1076
  compact(options: CompactOptions): Promise<Json>;
1000
1077
  get_compacted(options: {
@@ -1195,6 +1272,10 @@ interface SendMessageOptions {
1195
1272
  event_type?: string;
1196
1273
  eventType?: string;
1197
1274
  metadata?: Record<string, string>;
1275
+ /** The agent's model, as on `conversation.record_message`. Python's `model=`. */
1276
+ model?: string;
1277
+ context_window?: number;
1278
+ contextWindow?: number;
1198
1279
  /**
1199
1280
  * Report a tool call on the stream. Python's `send_message` takes both, and
1200
1281
  * the proto has `tool_name` / `tool_args_json`; the JS surface simply never
@@ -1293,6 +1374,16 @@ interface InstanceInternals {
1293
1374
  onCompactionUpdate(conversationId: string, bundle: Record<string, unknown>): void;
1294
1375
  /** Set by the client so a compaction can prune the locally buffered tail. */
1295
1376
  setCompactionApplier(apply: (bundle: Record<string, unknown>) => void): void;
1377
+ /**
1378
+ * Set by the client: called when `listen()` starts, which is when prefetched
1379
+ * bundles begin to arrive, so the local embedding model loads then.
1380
+ */
1381
+ setOnListen(handle: () => void): void;
1382
+ /**
1383
+ * Set by the client. Receives the server's message count for a conversation
1384
+ * after each streamed write has been stored.
1385
+ */
1386
+ setConversationStateHandler(handle: (conversationId: string, messageCount: number) => void): void;
1296
1387
  /** Learning-loop event, fired after a fetch is served from the cache. */
1297
1388
  sendContextUsed(event: Record<string, unknown>): void;
1298
1389
  /** Audit event, fired after every fetch resolves. */
@@ -1321,6 +1412,13 @@ interface UnifiedContext {
1321
1412
  episodes: RawContextItem[];
1322
1413
  emotions: RawContextItem[];
1323
1414
  temporal_events: RawContextItem[];
1415
+ /**
1416
+ * `response_shape: "ranked"` only: every item once, best first across
1417
+ * scopes and types, renumbered from 1. Empty for a by-type fetch.
1418
+ */
1419
+ items: RawContextItem[];
1420
+ /** `response_shape: "ranked"` only: the chunks (quotes from source documents). */
1421
+ excerpts: RawContextItem[];
1324
1422
  /** item id -> the scope that supplied it. */
1325
1423
  scope_map: Record<string, string>;
1326
1424
  conversation_context: Json | null;
@@ -1457,16 +1555,57 @@ interface SynapClientOptions {
1457
1555
  */
1458
1556
  st_verbatim_overlay?: boolean | undefined;
1459
1557
  stVerbatimOverlay?: boolean | undefined;
1558
+ /**
1559
+ * The model the agent runs on, and optionally its context window. Sent with
1560
+ * every recorded turn so the server sizes compaction to the agent's window
1561
+ * (it compacts at ~11.7% of it: 15K tokens on a 128K model). A name is
1562
+ * enough; the server knows common models' windows. Unset = 128K. Python's
1563
+ * `SDKConfig.agent_model` / `agent_context_window`; per-call `model` /
1564
+ * `context_window` override them.
1565
+ */
1566
+ agent_model?: string | undefined;
1567
+ agentModel?: string | undefined;
1568
+ agent_context_window?: number | undefined;
1569
+ agentContextWindow?: number | undefined;
1460
1570
  /**
1461
1571
  * Let the SDK answer `get_context_for_prompt` and `get_compacted` from its
1462
1572
  * own short-term store when the conversation is warm, skipping the cloud
1463
- * round trip. Off by default. `SYNAP_SDK_ST_AUTHORITATIVE` also enables it.
1573
+ * round trip. Off by default. `SYNAP_SDK_ST_AUTHORITATIVE` overrides this in
1574
+ * either direction.
1575
+ *
1576
+ * Leave it off for an application that runs more than one process against
1577
+ * the same conversation. A process learns the server's message count only
1578
+ * when it writes. If it reads before it writes (build the prompt, then
1579
+ * record the turn), it cannot know that another process recorded a turn in
1580
+ * between, and it answers without that turn. Turn it on where one process
1581
+ * owns a conversation for its whole life, such as a voice agent.
1464
1582
  *
1465
1583
  * This is the COST switch. `st_verbatim_overlay` is the correctness one and
1466
1584
  * is independent of it.
1467
1585
  */
1468
1586
  sdk_st_authoritative?: boolean | undefined;
1469
1587
  sdkStAuthoritative?: boolean | undefined;
1588
+ /**
1589
+ * Your own embedding model for history search after compaction
1590
+ * (cache/history-search.ts), any `{ model, encode }`. It replaces the
1591
+ * SDK's model for history search; the anticipation cache uses it only if it
1592
+ * is the model its thresholds were tuned on (`history_search_model`).
1593
+ */
1594
+ history_search_encoder?: Encoder | undefined;
1595
+ historySearchEncoder?: Encoder | undefined;
1596
+ /**
1597
+ * The local embedding model, as Python's `history_search_model`: history
1598
+ * search after compaction, and matching fetch queries to prefetched items by
1599
+ * meaning. "auto" (default) runs the SDK's multilingual model in Node when
1600
+ * the optional `onnxruntime-node` and `@huggingface/tokenizers` packages are
1601
+ * installed: downloaded once (about 135 MB) into ~/.synap/models when the
1602
+ * first stream starts or the first history search runs, then loaded in the
1603
+ * background. An "onnx:<repo>@<revision>/<file>" names another (history
1604
+ * search only). null keeps keyword matching. Never loaded on Edge or in a
1605
+ * browser.
1606
+ */
1607
+ history_search_model?: string | null | undefined;
1608
+ historySearchModel?: string | null | undefined;
1470
1609
  /**
1471
1610
  * Where the SDK's diagnostics go. Defaults to `console.warn` prefixed with
1472
1611
  * `[synap]`. Pass a no-op to silence them, or your own logger to route them.
@@ -1505,6 +1644,11 @@ interface ConfigureOptions {
1505
1644
  session_timeout_minutes?: number;
1506
1645
  /** Accepted and ignored. Python-only. */
1507
1646
  log_level?: string;
1647
+ /** The agent's model; see `SynapClientOptions.agent_model`. */
1648
+ agent_model?: string;
1649
+ agentModel?: string;
1650
+ agent_context_window?: number;
1651
+ agentContextWindow?: number;
1508
1652
  /** Replaces the diagnostic sink, same as the constructor option. */
1509
1653
  logger?: SynapLogger | undefined;
1510
1654
  }
@@ -1537,6 +1681,13 @@ interface UnifiedFetchOptions {
1537
1681
  context_mode?: string;
1538
1682
  include_profile?: boolean;
1539
1683
  last_n_conversations?: number;
1684
+ /**
1685
+ * `"by_type"` (default) or `"ranked"`. Ranked asks every scope for its
1686
+ * ranked list and merges them into `items`, best first across scopes and
1687
+ * types, by each item's `rank_score`; `formatted_context` is then one
1688
+ * numbered list in that order. The typed lists are filled either way.
1689
+ */
1690
+ response_shape?: string;
1540
1691
  }
1541
1692
  declare class SynapClient {
1542
1693
  #private;
@@ -1617,12 +1768,16 @@ declare class SynapClient {
1617
1768
  /**
1618
1769
  * Resolve `client_id` and `instance_id` from the API key.
1619
1770
  *
1620
- * Mirrors Python's `initialize()`. Calling it is optional here (unlike
1621
- * Python, which raises "SDK not initialized" from `_ensure_initialized`)
1622
- * because every HTTP route authenticates on the API key alone. It matters
1623
- * for the anticipation cache: a bundle shared at client scope is filtered on
1624
- * `client_id`, and an empty one fails that filter for every bundle. That was
1625
- * a silent cache-scope bug in Python before whoami bootstrapping existed.
1771
+ * Mirrors Python's `initialize()`. Python raises "SDK not initialized" on
1772
+ * any call made before it; here the first request runs the same resolution
1773
+ * instead (`identityResolver` on the transport), so skipping this call costs
1774
+ * nothing and breaks no existing caller. It matters for the anticipation
1775
+ * cache: a bundle shared at client scope is filtered on `client_id`, and an
1776
+ * empty one fails that filter for every bundle.
1777
+ *
1778
+ * Calling it explicitly still locks `configure()`, as in Python. Resolving
1779
+ * on first use does not, because a caller who never called it could always
1780
+ * configure after a request, and that keeps working.
1626
1781
  *
1627
1782
  * Best-effort and idempotent. A whoami failure leaves whatever the
1628
1783
  * constructor resolved and is not fatal.
@@ -1683,6 +1838,19 @@ declare class SynapClient {
1683
1838
  * snake_case shape, since this output gets logged and compared across SDKs.
1684
1839
  */
1685
1840
  anticipation_cache_snapshot(): AnticipationCacheSnapshot;
1841
+ /**
1842
+ * Keep what a tool returned in this process's turn archive, so history search
1843
+ * can find it after a compaction. Never sent anywhere: the server's
1844
+ * conversation holds what people said, and a compaction is made from that.
1845
+ * `instance.record_tool_result` calls this too. Python: `archive_tool_result`.
1846
+ */
1847
+ archive_tool_result(conversationId: string, result: unknown, options?: {
1848
+ tool_name?: string | null;
1849
+ toolName?: string | null;
1850
+ timestamp?: string;
1851
+ }): void;
1852
+ static readonly BACKFILL_COOLDOWN_MS = 60000;
1853
+ static readonly BACKFILL_PAGE = 500;
1686
1854
  /** Release timers and connections. Safe to call more than once. */
1687
1855
  shutdown(): Promise<void>;
1688
1856
  }
@@ -1701,7 +1869,55 @@ declare class SynapClient {
1701
1869
  * build when the two disagree, which is the only thing that makes a manual
1702
1870
  * publish safe.
1703
1871
  */
1704
- declare const SDK_VERSION = "0.5.8";
1872
+ declare const SDK_VERSION = "0.5.10";
1873
+
1874
+ /**
1875
+ * `response_shape: "ranked"`: one list in the order the server ranked it.
1876
+ *
1877
+ * Ports the ranked half of Python's `models/context.py` (`rank_items`,
1878
+ * `_wire_rank_score`, `_wire_category` and the ranked branch of
1879
+ * `ContextResponse.from_cloud_response`). The cases are pinned in
1880
+ * `CONTRACT/conformance/ranked_shape.json`, captured from Python.
1881
+ *
1882
+ * Opt-in. A by-type fetch, the default, is returned exactly as the server sent
1883
+ * it, so nothing here touches a caller who does not ask for the ranked shape.
1884
+ */
1885
+
1886
+ /** The two shapes a context fetch can ask for. */
1887
+ declare const RESPONSE_SHAPES: readonly ["by_type", "ranked"];
1888
+ type ResponseShape = (typeof RESPONSE_SHAPES)[number];
1889
+ /** The memory types, in the order the by-type response lists them. */
1890
+ declare const MEMORY_TYPES: readonly ["facts", "preferences", "episodes", "emotions", "temporal_events"];
1891
+ /**
1892
+ * The type of a chunk in a ranked response: a quote from a source document,
1893
+ * not an extracted memory. A by-type response files it under `facts`.
1894
+ */
1895
+ declare const EXCERPT_CATEGORY = "excerpts";
1896
+ /**
1897
+ * An item's rank score: `metadata.rank_score` on the HTTP response, a
1898
+ * top-level `rank_score` on a prefetched (gRPC) item. `null` when neither is a
1899
+ * number, which is how a server that predates ranking reads.
1900
+ */
1901
+ declare function wireRankScore(item: RawContextItem): number | null;
1902
+ /**
1903
+ * Merge per-type item lists into one list in rank order, numbered from 1.
1904
+ *
1905
+ * For a server that predates `response_shape` (it returned the five lists) and
1906
+ * for a prefetched cache hit. Each returned item is a copy carrying `rank`,
1907
+ * `category` and `id` (a prefetched item names it `item_id`), so the input is
1908
+ * not changed. `Array.prototype.sort` is stable, like Python's.
1909
+ */
1910
+ declare function rankItems(byType: RawContext): RawContextItem[];
1911
+ /**
1912
+ * The raw context in the shape the caller asked for.
1913
+ *
1914
+ * "ranked": `items` in rank order (the server's own list, or one rebuilt by
1915
+ * rank score when the server or the cache predates the parameter), the five
1916
+ * typed lists as views of those items, and `excerpts` for the chunks. A
1917
+ * response that already carries `items` is read the same way even when the
1918
+ * caller did not ask, as Python does. Anything else is returned untouched.
1919
+ */
1920
+ declare function applyResponseShape(raw: RawContext, shape?: string): RawContext;
1705
1921
 
1706
1922
  /**
1707
1923
  * BM25 scorer for the anticipation cache.
@@ -1806,6 +2022,56 @@ interface BehaviorContract {
1806
2022
  note: string;
1807
2023
  };
1808
2024
  };
2025
+ semantic_match: {
2026
+ model: string;
2027
+ mode: 'bm25' | 'semantic';
2028
+ min_cosine: number;
2029
+ serve_min_cosine: number;
2030
+ asked_kind: boolean;
2031
+ max_queries: number;
2032
+ item_questions: boolean;
2033
+ canonical_query: 'off' | 'canon' | 'both';
2034
+ self_pronouns: Record<string, [string, string][] | string>;
2035
+ asked_details: Record<string, {
2036
+ query: string;
2037
+ value: string;
2038
+ } | string>;
2039
+ bundle_serve_min_cosine: number;
2040
+ sure_min_cosine: number;
2041
+ race_deadline_ms: number;
2042
+ };
2043
+ history_search: {
2044
+ max_excerpts: number;
2045
+ max_words_per_excerpt: number;
2046
+ min_matched_terms: number;
2047
+ rrf_k: number;
2048
+ recency_weight: number;
2049
+ min_cosine?: number;
2050
+ previous_turns?: number;
2051
+ previous_turn_words?: number;
2052
+ rare_term_max_share?: number;
2053
+ tool_result_max_chars?: number;
2054
+ passages?: boolean;
2055
+ passages_per_turn?: number;
2056
+ early_query?: {
2057
+ pattern: string;
2058
+ flags?: string;
2059
+ note?: string;
2060
+ };
2061
+ asked_kinds?: Record<string, {
2062
+ query: string;
2063
+ value: string;
2064
+ } | string>;
2065
+ irregular_forms?: Record<string, string>;
2066
+ heading: string;
2067
+ store_limits: {
2068
+ max_conversations: number;
2069
+ max_turns_per_conversation: number;
2070
+ max_bytes_per_conversation: number;
2071
+ idle_ttl_seconds: number;
2072
+ max_file_bytes: number;
2073
+ };
2074
+ };
1809
2075
  }
1810
2076
  declare const CONTRACT: BehaviorContract;
1811
2077
  declare const THRESHOLDS: {
@@ -1857,4 +2123,4 @@ interface SynapSdkLike {
1857
2123
  };
1858
2124
  }
1859
2125
 
1860
- 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 };
2126
+ 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, EXCERPT_CATEGORY, 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, MEMORY_TYPES, type MemoriesInterface, type NormalisedContext, 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, 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, applyResponseShape, flattenContextItems, formatForPrompt, isOutcomeUnknown, isRecallQuery, mergeScopeResults, rankItems, resolvePath, shouldRetry, stem, tokenize, wireRankScore };