@maximem/synap-js-sdk 0.5.7 → 0.5.9
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/README.md +5 -1
- package/dist/anticipation-cache-LPNKMRBH.cjs +20 -0
- package/dist/anticipation-cache-LPNKMRBH.cjs.map +1 -0
- package/dist/anticipation-cache-RWKF55J4.js +20 -0
- package/dist/{chunk-FXGLT6AT.js → chunk-I7TWR4S6.js} +59 -3
- package/dist/chunk-I7TWR4S6.js.map +1 -0
- package/dist/{chunk-T6U5PVAD.cjs → chunk-ICUFS3B5.cjs} +449 -12
- package/dist/chunk-ICUFS3B5.cjs.map +1 -0
- package/dist/{chunk-ODVOQOSO.js → chunk-R72YL6Q4.js} +445 -8
- package/dist/chunk-R72YL6Q4.js.map +1 -0
- package/dist/{chunk-HCULAVJC.cjs → chunk-RE4DDIWO.cjs} +66 -10
- package/dist/chunk-RE4DDIWO.cjs.map +1 -0
- package/dist/chunk-T372OL3Q.cjs.map +1 -1
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/{errors-Bl3vY1eb.d.cts → errors-Bdayqlzy.d.cts} +88 -2
- package/dist/{errors-Bl3vY1eb.d.ts → errors-Bdayqlzy.d.ts} +88 -2
- package/dist/grpc/index.cjs +4 -4
- package/dist/grpc/index.cjs.map +1 -1
- package/dist/grpc/index.d.cts +8 -3
- package/dist/grpc/index.d.ts +8 -3
- package/dist/grpc/index.js +3 -3
- package/dist/index.cjs +1304 -116
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +281 -5
- package/dist/index.d.ts +281 -5
- package/dist/index.js +1257 -69
- package/dist/index.js.map +1 -1
- package/dist/onnx-encoder-4RSL6ID4.cjs +103 -0
- package/dist/onnx-encoder-4RSL6ID4.cjs.map +1 -0
- package/dist/onnx-encoder-NP35KH4H.js +103 -0
- package/dist/onnx-encoder-NP35KH4H.js.map +1 -0
- package/dist/{stream-client-VWKINE47.js → stream-client-3WHXGW4U.js} +2 -2
- package/dist/stream-client-L6OQPZN7.cjs +16 -0
- package/dist/stream-client-L6OQPZN7.cjs.map +1 -0
- package/package.json +4 -2
- package/dist/anticipation-cache-LRE3TLK4.cjs +0 -14
- package/dist/anticipation-cache-LRE3TLK4.cjs.map +0 -1
- package/dist/anticipation-cache-WLU4NMD5.js +0 -14
- package/dist/chunk-FXGLT6AT.js.map +0 -1
- package/dist/chunk-HCULAVJC.cjs.map +0 -1
- package/dist/chunk-ODVOQOSO.js.map +0 -1
- package/dist/chunk-T6U5PVAD.cjs.map +0 -1
- package/dist/stream-client-N46JBT5A.cjs +0 -16
- package/dist/stream-client-N46JBT5A.cjs.map +0 -1
- /package/dist/{anticipation-cache-WLU4NMD5.js.map → anticipation-cache-RWKF55J4.js.map} +0 -0
- /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-
|
|
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,
|
|
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";
|
|
@@ -393,6 +398,15 @@ interface RawContextItem {
|
|
|
393
398
|
* served from the prefetch cache.
|
|
394
399
|
*/
|
|
395
400
|
matched_queries?: string[];
|
|
401
|
+
/**
|
|
402
|
+
* Anything the server sends that this SDK version has no named field for.
|
|
403
|
+
*
|
|
404
|
+
* This index signature already made unknown keys reachable in the TYPE; what
|
|
405
|
+
* dropped them was the normaliser, which built each item from a hand-picked
|
|
406
|
+
* list of keys. So `event_end` and `event_precision` were computed by the
|
|
407
|
+
* server, dropped by its own payload, and dropped a third time here, and a
|
|
408
|
+
* caller could not read "sometime in April" even once the server sent it.
|
|
409
|
+
*/
|
|
396
410
|
[key: string]: unknown;
|
|
397
411
|
}
|
|
398
412
|
interface RawConversationContext {
|
|
@@ -413,12 +427,31 @@ interface RawContext {
|
|
|
413
427
|
episodes?: RawContextItem[];
|
|
414
428
|
emotions?: RawContextItem[];
|
|
415
429
|
temporal_events?: RawContextItem[];
|
|
430
|
+
/**
|
|
431
|
+
* `response_shape: "ranked"` only: every item once, best first across
|
|
432
|
+
* types, each with `rank`, `category` and `metadata.rank_score`. The five
|
|
433
|
+
* lists above are then views of these same items, by type.
|
|
434
|
+
*/
|
|
435
|
+
items?: RawContextItem[];
|
|
436
|
+
/** `response_shape: "ranked"` only: the chunks, quotes from source documents. */
|
|
437
|
+
excerpts?: RawContextItem[];
|
|
416
438
|
conversation_context?: RawConversationContext | null;
|
|
417
439
|
metadata?: Json;
|
|
418
440
|
[key: string]: unknown;
|
|
419
441
|
}
|
|
420
442
|
interface TemporalFields {
|
|
421
443
|
eventDate: string | null;
|
|
444
|
+
/**
|
|
445
|
+
* The rest of the event window. `eventDate` is its START.
|
|
446
|
+
*
|
|
447
|
+
* "last month" is stored as 2023-04-01 to 2023-04-30 at precision "month",
|
|
448
|
+
* and reading only the start makes it look like the 1st, so arithmetic from
|
|
449
|
+
* it is wrong by up to the width of the window. `eventPrecision` carries the
|
|
450
|
+
* one distinction nothing else does: "approximate" has no end, so "around
|
|
451
|
+
* November 20" and "on November 20" differ only by this label.
|
|
452
|
+
*/
|
|
453
|
+
eventEnd: string | null;
|
|
454
|
+
eventPrecision: string | null;
|
|
422
455
|
/**
|
|
423
456
|
* The day the words were SAID, which is not the day the event happened.
|
|
424
457
|
*
|
|
@@ -478,6 +511,9 @@ interface TemporalEvent extends QueryAttribution {
|
|
|
478
511
|
id: string;
|
|
479
512
|
content: string;
|
|
480
513
|
eventDate: string | null;
|
|
514
|
+
/** The rest of the window. See the note on `TemporalFields.eventEnd`. */
|
|
515
|
+
eventEnd: string | null;
|
|
516
|
+
eventPrecision: string | null;
|
|
481
517
|
/** See the note on `TemporalFields.saidAt`. */
|
|
482
518
|
saidAt: string | null;
|
|
483
519
|
validUntil: string | null;
|
|
@@ -510,6 +546,25 @@ interface ContextMetadata {
|
|
|
510
546
|
retrievedAt: string | null;
|
|
511
547
|
compactionApplied: boolean | null;
|
|
512
548
|
}
|
|
549
|
+
/**
|
|
550
|
+
* Why a fetch may be thinner than the stores can support. Null when healthy.
|
|
551
|
+
*
|
|
552
|
+
* `degraded` says something went wrong, `level` how thin the answer is
|
|
553
|
+
* ("partial" | "minimal" | "failed"), and `code` whether a retry is worth it
|
|
554
|
+
* ("timeout" | "overloaded" | "unavailable" | "internal"). The server never
|
|
555
|
+
* names which of its services broke.
|
|
556
|
+
*
|
|
557
|
+
* It had no slot here, and that is how a real failure stayed invisible: a
|
|
558
|
+
* retrieval that lost its embedding call returned 200 with zero items for a
|
|
559
|
+
* user holding 122 memories, and the caller could not tell that from "no
|
|
560
|
+
* relevant memories".
|
|
561
|
+
*/
|
|
562
|
+
interface RetrievalHealth {
|
|
563
|
+
degraded: boolean;
|
|
564
|
+
level: string | null;
|
|
565
|
+
code: string | null;
|
|
566
|
+
warnings: string[];
|
|
567
|
+
}
|
|
513
568
|
interface NormalisedContext {
|
|
514
569
|
facts: Fact[];
|
|
515
570
|
preferences: Preference[];
|
|
@@ -518,7 +573,17 @@ interface NormalisedContext {
|
|
|
518
573
|
temporalEvents: TemporalEvent[];
|
|
519
574
|
conversationContext: ConversationContext | null;
|
|
520
575
|
metadata: ContextMetadata;
|
|
576
|
+
retrieval: RetrievalHealth | null;
|
|
521
577
|
rawResponse: Json;
|
|
578
|
+
/**
|
|
579
|
+
* `response_shape: "ranked"` only, and absent otherwise: every item once, best
|
|
580
|
+
* first across types, as the wire sends it (snake_case, with `rank`,
|
|
581
|
+
* `category` and `metadata.rank_score`). The five lists above hold the same
|
|
582
|
+
* items by type, except the chunks, which are in `excerpts`.
|
|
583
|
+
*/
|
|
584
|
+
items?: RawContextItem[];
|
|
585
|
+
/** `response_shape: "ranked"` only, and absent otherwise: the chunks, quotes from source documents. */
|
|
586
|
+
excerpts?: RawContextItem[];
|
|
522
587
|
}
|
|
523
588
|
/**
|
|
524
589
|
* Fetch options.
|
|
@@ -588,6 +653,18 @@ interface FetchOptions {
|
|
|
588
653
|
/** Explicit scope ladder. Sent as `scope` when supplied. */
|
|
589
654
|
scope_path?: Record<string, string>;
|
|
590
655
|
scopePath?: Record<string, string>;
|
|
656
|
+
/**
|
|
657
|
+
* `"by_type"` (default): the five typed lists, as every earlier SDK version
|
|
658
|
+
* got them. `"ranked"`: also `items`, every item once in the order the
|
|
659
|
+
* server ranked them across types, with chunks typed as `excerpts`; the
|
|
660
|
+
* typed lists are then views of those items.
|
|
661
|
+
*
|
|
662
|
+
* Sent only when `"ranked"`, so a default fetch sends the body it always
|
|
663
|
+
* did. A server that predates the parameter returns the five lists, and the
|
|
664
|
+
* SDK then builds `items` from them by `metadata.rank_score`.
|
|
665
|
+
*/
|
|
666
|
+
response_shape?: string;
|
|
667
|
+
responseShape?: string;
|
|
591
668
|
}
|
|
592
669
|
|
|
593
670
|
/**
|
|
@@ -890,6 +967,15 @@ interface RecordMessageOptions {
|
|
|
890
967
|
*/
|
|
891
968
|
scope_path?: Record<string, string>;
|
|
892
969
|
scopePath?: Record<string, string>;
|
|
970
|
+
/**
|
|
971
|
+
* The model the agent runs on, e.g. `'gpt-4o'`. Overrides the client's
|
|
972
|
+
* `agent_model` for this turn. The server sizes compaction to this model's
|
|
973
|
+
* context window. Python's `model=`.
|
|
974
|
+
*/
|
|
975
|
+
model?: string;
|
|
976
|
+
/** The agent model's context window in tokens, for a model the server would not know. */
|
|
977
|
+
context_window?: number;
|
|
978
|
+
contextWindow?: number;
|
|
893
979
|
}
|
|
894
980
|
interface TranscriptTurn {
|
|
895
981
|
role: string;
|
|
@@ -972,6 +1058,11 @@ interface ConversationNamespace {
|
|
|
972
1058
|
conversation_id?: string;
|
|
973
1059
|
conversationId?: string;
|
|
974
1060
|
style?: string;
|
|
1061
|
+
/** Search the earlier turns locally after a compaction (default true). */
|
|
1062
|
+
search_history?: boolean;
|
|
1063
|
+
searchHistory?: boolean;
|
|
1064
|
+
/** What to search for; defaults to the latest user message. */
|
|
1065
|
+
query?: string;
|
|
975
1066
|
}): Promise<Json>;
|
|
976
1067
|
compact(options: CompactOptions): Promise<Json>;
|
|
977
1068
|
get_compacted(options: {
|
|
@@ -1172,6 +1263,10 @@ interface SendMessageOptions {
|
|
|
1172
1263
|
event_type?: string;
|
|
1173
1264
|
eventType?: string;
|
|
1174
1265
|
metadata?: Record<string, string>;
|
|
1266
|
+
/** The agent's model, as on `conversation.record_message`. Python's `model=`. */
|
|
1267
|
+
model?: string;
|
|
1268
|
+
context_window?: number;
|
|
1269
|
+
contextWindow?: number;
|
|
1175
1270
|
/**
|
|
1176
1271
|
* Report a tool call on the stream. Python's `send_message` takes both, and
|
|
1177
1272
|
* the proto has `tool_name` / `tool_args_json`; the JS surface simply never
|
|
@@ -1270,6 +1365,16 @@ interface InstanceInternals {
|
|
|
1270
1365
|
onCompactionUpdate(conversationId: string, bundle: Record<string, unknown>): void;
|
|
1271
1366
|
/** Set by the client so a compaction can prune the locally buffered tail. */
|
|
1272
1367
|
setCompactionApplier(apply: (bundle: Record<string, unknown>) => void): void;
|
|
1368
|
+
/**
|
|
1369
|
+
* Set by the client: called when `listen()` starts, which is when prefetched
|
|
1370
|
+
* bundles begin to arrive, so the local embedding model loads then.
|
|
1371
|
+
*/
|
|
1372
|
+
setOnListen(handle: () => void): void;
|
|
1373
|
+
/**
|
|
1374
|
+
* Set by the client. Receives the server's message count for a conversation
|
|
1375
|
+
* after each streamed write has been stored.
|
|
1376
|
+
*/
|
|
1377
|
+
setConversationStateHandler(handle: (conversationId: string, messageCount: number) => void): void;
|
|
1273
1378
|
/** Learning-loop event, fired after a fetch is served from the cache. */
|
|
1274
1379
|
sendContextUsed(event: Record<string, unknown>): void;
|
|
1275
1380
|
/** Audit event, fired after every fetch resolves. */
|
|
@@ -1298,6 +1403,13 @@ interface UnifiedContext {
|
|
|
1298
1403
|
episodes: RawContextItem[];
|
|
1299
1404
|
emotions: RawContextItem[];
|
|
1300
1405
|
temporal_events: RawContextItem[];
|
|
1406
|
+
/**
|
|
1407
|
+
* `response_shape: "ranked"` only: every item once, best first across
|
|
1408
|
+
* scopes and types, renumbered from 1. Empty for a by-type fetch.
|
|
1409
|
+
*/
|
|
1410
|
+
items: RawContextItem[];
|
|
1411
|
+
/** `response_shape: "ranked"` only: the chunks (quotes from source documents). */
|
|
1412
|
+
excerpts: RawContextItem[];
|
|
1301
1413
|
/** item id -> the scope that supplied it. */
|
|
1302
1414
|
scope_map: Record<string, string>;
|
|
1303
1415
|
conversation_context: Json | null;
|
|
@@ -1434,16 +1546,57 @@ interface SynapClientOptions {
|
|
|
1434
1546
|
*/
|
|
1435
1547
|
st_verbatim_overlay?: boolean | undefined;
|
|
1436
1548
|
stVerbatimOverlay?: boolean | undefined;
|
|
1549
|
+
/**
|
|
1550
|
+
* The model the agent runs on, and optionally its context window. Sent with
|
|
1551
|
+
* every recorded turn so the server sizes compaction to the agent's window
|
|
1552
|
+
* (it compacts at ~11.7% of it: 15K tokens on a 128K model). A name is
|
|
1553
|
+
* enough; the server knows common models' windows. Unset = 128K. Python's
|
|
1554
|
+
* `SDKConfig.agent_model` / `agent_context_window`; per-call `model` /
|
|
1555
|
+
* `context_window` override them.
|
|
1556
|
+
*/
|
|
1557
|
+
agent_model?: string | undefined;
|
|
1558
|
+
agentModel?: string | undefined;
|
|
1559
|
+
agent_context_window?: number | undefined;
|
|
1560
|
+
agentContextWindow?: number | undefined;
|
|
1437
1561
|
/**
|
|
1438
1562
|
* Let the SDK answer `get_context_for_prompt` and `get_compacted` from its
|
|
1439
1563
|
* own short-term store when the conversation is warm, skipping the cloud
|
|
1440
|
-
* round trip. Off by default. `SYNAP_SDK_ST_AUTHORITATIVE`
|
|
1564
|
+
* round trip. Off by default. `SYNAP_SDK_ST_AUTHORITATIVE` overrides this in
|
|
1565
|
+
* either direction.
|
|
1566
|
+
*
|
|
1567
|
+
* Leave it off for an application that runs more than one process against
|
|
1568
|
+
* the same conversation. A process learns the server's message count only
|
|
1569
|
+
* when it writes. If it reads before it writes (build the prompt, then
|
|
1570
|
+
* record the turn), it cannot know that another process recorded a turn in
|
|
1571
|
+
* between, and it answers without that turn. Turn it on where one process
|
|
1572
|
+
* owns a conversation for its whole life, such as a voice agent.
|
|
1441
1573
|
*
|
|
1442
1574
|
* This is the COST switch. `st_verbatim_overlay` is the correctness one and
|
|
1443
1575
|
* is independent of it.
|
|
1444
1576
|
*/
|
|
1445
1577
|
sdk_st_authoritative?: boolean | undefined;
|
|
1446
1578
|
sdkStAuthoritative?: boolean | undefined;
|
|
1579
|
+
/**
|
|
1580
|
+
* Your own embedding model for history search after compaction
|
|
1581
|
+
* (cache/history-search.ts), any `{ model, encode }`. It replaces the
|
|
1582
|
+
* SDK's model for history search; the anticipation cache uses it only if it
|
|
1583
|
+
* is the model its thresholds were tuned on (`history_search_model`).
|
|
1584
|
+
*/
|
|
1585
|
+
history_search_encoder?: Encoder | undefined;
|
|
1586
|
+
historySearchEncoder?: Encoder | undefined;
|
|
1587
|
+
/**
|
|
1588
|
+
* The local embedding model, as Python's `history_search_model`: history
|
|
1589
|
+
* search after compaction, and matching fetch queries to prefetched items by
|
|
1590
|
+
* meaning. "auto" (default) runs the SDK's multilingual model in Node when
|
|
1591
|
+
* the optional `onnxruntime-node` and `@huggingface/tokenizers` packages are
|
|
1592
|
+
* installed: downloaded once (about 135 MB) into ~/.synap/models when the
|
|
1593
|
+
* first stream starts or the first history search runs, then loaded in the
|
|
1594
|
+
* background. An "onnx:<repo>@<revision>/<file>" names another (history
|
|
1595
|
+
* search only). null keeps keyword matching. Never loaded on Edge or in a
|
|
1596
|
+
* browser.
|
|
1597
|
+
*/
|
|
1598
|
+
history_search_model?: string | null | undefined;
|
|
1599
|
+
historySearchModel?: string | null | undefined;
|
|
1447
1600
|
/**
|
|
1448
1601
|
* Where the SDK's diagnostics go. Defaults to `console.warn` prefixed with
|
|
1449
1602
|
* `[synap]`. Pass a no-op to silence them, or your own logger to route them.
|
|
@@ -1482,6 +1635,11 @@ interface ConfigureOptions {
|
|
|
1482
1635
|
session_timeout_minutes?: number;
|
|
1483
1636
|
/** Accepted and ignored. Python-only. */
|
|
1484
1637
|
log_level?: string;
|
|
1638
|
+
/** The agent's model; see `SynapClientOptions.agent_model`. */
|
|
1639
|
+
agent_model?: string;
|
|
1640
|
+
agentModel?: string;
|
|
1641
|
+
agent_context_window?: number;
|
|
1642
|
+
agentContextWindow?: number;
|
|
1485
1643
|
/** Replaces the diagnostic sink, same as the constructor option. */
|
|
1486
1644
|
logger?: SynapLogger | undefined;
|
|
1487
1645
|
}
|
|
@@ -1514,6 +1672,13 @@ interface UnifiedFetchOptions {
|
|
|
1514
1672
|
context_mode?: string;
|
|
1515
1673
|
include_profile?: boolean;
|
|
1516
1674
|
last_n_conversations?: number;
|
|
1675
|
+
/**
|
|
1676
|
+
* `"by_type"` (default) or `"ranked"`. Ranked asks every scope for its
|
|
1677
|
+
* ranked list and merges them into `items`, best first across scopes and
|
|
1678
|
+
* types, by each item's `rank_score`; `formatted_context` is then one
|
|
1679
|
+
* numbered list in that order. The typed lists are filled either way.
|
|
1680
|
+
*/
|
|
1681
|
+
response_shape?: string;
|
|
1517
1682
|
}
|
|
1518
1683
|
declare class SynapClient {
|
|
1519
1684
|
#private;
|
|
@@ -1660,6 +1825,19 @@ declare class SynapClient {
|
|
|
1660
1825
|
* snake_case shape, since this output gets logged and compared across SDKs.
|
|
1661
1826
|
*/
|
|
1662
1827
|
anticipation_cache_snapshot(): AnticipationCacheSnapshot;
|
|
1828
|
+
/**
|
|
1829
|
+
* Keep what a tool returned in this process's turn archive, so history search
|
|
1830
|
+
* can find it after a compaction. Never sent anywhere: the server's
|
|
1831
|
+
* conversation holds what people said, and a compaction is made from that.
|
|
1832
|
+
* `instance.record_tool_result` calls this too. Python: `archive_tool_result`.
|
|
1833
|
+
*/
|
|
1834
|
+
archive_tool_result(conversationId: string, result: unknown, options?: {
|
|
1835
|
+
tool_name?: string | null;
|
|
1836
|
+
toolName?: string | null;
|
|
1837
|
+
timestamp?: string;
|
|
1838
|
+
}): void;
|
|
1839
|
+
static readonly BACKFILL_COOLDOWN_MS = 60000;
|
|
1840
|
+
static readonly BACKFILL_PAGE = 500;
|
|
1663
1841
|
/** Release timers and connections. Safe to call more than once. */
|
|
1664
1842
|
shutdown(): Promise<void>;
|
|
1665
1843
|
}
|
|
@@ -1678,7 +1856,55 @@ declare class SynapClient {
|
|
|
1678
1856
|
* build when the two disagree, which is the only thing that makes a manual
|
|
1679
1857
|
* publish safe.
|
|
1680
1858
|
*/
|
|
1681
|
-
declare const SDK_VERSION = "0.5.
|
|
1859
|
+
declare const SDK_VERSION = "0.5.9";
|
|
1860
|
+
|
|
1861
|
+
/**
|
|
1862
|
+
* `response_shape: "ranked"`: one list in the order the server ranked it.
|
|
1863
|
+
*
|
|
1864
|
+
* Ports the ranked half of Python's `models/context.py` (`rank_items`,
|
|
1865
|
+
* `_wire_rank_score`, `_wire_category` and the ranked branch of
|
|
1866
|
+
* `ContextResponse.from_cloud_response`). The cases are pinned in
|
|
1867
|
+
* `CONTRACT/conformance/ranked_shape.json`, captured from Python.
|
|
1868
|
+
*
|
|
1869
|
+
* Opt-in. A by-type fetch, the default, is returned exactly as the server sent
|
|
1870
|
+
* it, so nothing here touches a caller who does not ask for the ranked shape.
|
|
1871
|
+
*/
|
|
1872
|
+
|
|
1873
|
+
/** The two shapes a context fetch can ask for. */
|
|
1874
|
+
declare const RESPONSE_SHAPES: readonly ["by_type", "ranked"];
|
|
1875
|
+
type ResponseShape = (typeof RESPONSE_SHAPES)[number];
|
|
1876
|
+
/** The memory types, in the order the by-type response lists them. */
|
|
1877
|
+
declare const MEMORY_TYPES: readonly ["facts", "preferences", "episodes", "emotions", "temporal_events"];
|
|
1878
|
+
/**
|
|
1879
|
+
* The type of a chunk in a ranked response: a quote from a source document,
|
|
1880
|
+
* not an extracted memory. A by-type response files it under `facts`.
|
|
1881
|
+
*/
|
|
1882
|
+
declare const EXCERPT_CATEGORY = "excerpts";
|
|
1883
|
+
/**
|
|
1884
|
+
* An item's rank score: `metadata.rank_score` on the HTTP response, a
|
|
1885
|
+
* top-level `rank_score` on a prefetched (gRPC) item. `null` when neither is a
|
|
1886
|
+
* number, which is how a server that predates ranking reads.
|
|
1887
|
+
*/
|
|
1888
|
+
declare function wireRankScore(item: RawContextItem): number | null;
|
|
1889
|
+
/**
|
|
1890
|
+
* Merge per-type item lists into one list in rank order, numbered from 1.
|
|
1891
|
+
*
|
|
1892
|
+
* For a server that predates `response_shape` (it returned the five lists) and
|
|
1893
|
+
* for a prefetched cache hit. Each returned item is a copy carrying `rank`,
|
|
1894
|
+
* `category` and `id` (a prefetched item names it `item_id`), so the input is
|
|
1895
|
+
* not changed. `Array.prototype.sort` is stable, like Python's.
|
|
1896
|
+
*/
|
|
1897
|
+
declare function rankItems(byType: RawContext): RawContextItem[];
|
|
1898
|
+
/**
|
|
1899
|
+
* The raw context in the shape the caller asked for.
|
|
1900
|
+
*
|
|
1901
|
+
* "ranked": `items` in rank order (the server's own list, or one rebuilt by
|
|
1902
|
+
* rank score when the server or the cache predates the parameter), the five
|
|
1903
|
+
* typed lists as views of those items, and `excerpts` for the chunks. A
|
|
1904
|
+
* response that already carries `items` is read the same way even when the
|
|
1905
|
+
* caller did not ask, as Python does. Anything else is returned untouched.
|
|
1906
|
+
*/
|
|
1907
|
+
declare function applyResponseShape(raw: RawContext, shape?: string): RawContext;
|
|
1682
1908
|
|
|
1683
1909
|
/**
|
|
1684
1910
|
* BM25 scorer for the anticipation cache.
|
|
@@ -1783,6 +2009,56 @@ interface BehaviorContract {
|
|
|
1783
2009
|
note: string;
|
|
1784
2010
|
};
|
|
1785
2011
|
};
|
|
2012
|
+
semantic_match: {
|
|
2013
|
+
model: string;
|
|
2014
|
+
mode: 'bm25' | 'semantic';
|
|
2015
|
+
min_cosine: number;
|
|
2016
|
+
serve_min_cosine: number;
|
|
2017
|
+
asked_kind: boolean;
|
|
2018
|
+
max_queries: number;
|
|
2019
|
+
item_questions: boolean;
|
|
2020
|
+
canonical_query: 'off' | 'canon' | 'both';
|
|
2021
|
+
self_pronouns: Record<string, [string, string][] | string>;
|
|
2022
|
+
asked_details: Record<string, {
|
|
2023
|
+
query: string;
|
|
2024
|
+
value: string;
|
|
2025
|
+
} | string>;
|
|
2026
|
+
bundle_serve_min_cosine: number;
|
|
2027
|
+
sure_min_cosine: number;
|
|
2028
|
+
race_deadline_ms: number;
|
|
2029
|
+
};
|
|
2030
|
+
history_search: {
|
|
2031
|
+
max_excerpts: number;
|
|
2032
|
+
max_words_per_excerpt: number;
|
|
2033
|
+
min_matched_terms: number;
|
|
2034
|
+
rrf_k: number;
|
|
2035
|
+
recency_weight: number;
|
|
2036
|
+
min_cosine?: number;
|
|
2037
|
+
previous_turns?: number;
|
|
2038
|
+
previous_turn_words?: number;
|
|
2039
|
+
rare_term_max_share?: number;
|
|
2040
|
+
tool_result_max_chars?: number;
|
|
2041
|
+
passages?: boolean;
|
|
2042
|
+
passages_per_turn?: number;
|
|
2043
|
+
early_query?: {
|
|
2044
|
+
pattern: string;
|
|
2045
|
+
flags?: string;
|
|
2046
|
+
note?: string;
|
|
2047
|
+
};
|
|
2048
|
+
asked_kinds?: Record<string, {
|
|
2049
|
+
query: string;
|
|
2050
|
+
value: string;
|
|
2051
|
+
} | string>;
|
|
2052
|
+
irregular_forms?: Record<string, string>;
|
|
2053
|
+
heading: string;
|
|
2054
|
+
store_limits: {
|
|
2055
|
+
max_conversations: number;
|
|
2056
|
+
max_turns_per_conversation: number;
|
|
2057
|
+
max_bytes_per_conversation: number;
|
|
2058
|
+
idle_ttl_seconds: number;
|
|
2059
|
+
max_file_bytes: number;
|
|
2060
|
+
};
|
|
2061
|
+
};
|
|
1786
2062
|
}
|
|
1787
2063
|
declare const CONTRACT: BehaviorContract;
|
|
1788
2064
|
declare const THRESHOLDS: {
|
|
@@ -1834,4 +2110,4 @@ interface SynapSdkLike {
|
|
|
1834
2110
|
};
|
|
1835
2111
|
}
|
|
1836
2112
|
|
|
1837
|
-
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 };
|
|
2113
|
+
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 };
|