@maximem/synap-js-sdk 0.4.7 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{anticipation-cache-BMVF5sXb.d.cts → anticipation-cache-C1rUEpaW.d.cts} +22 -1
- package/dist/{anticipation-cache-BMVF5sXb.d.ts → anticipation-cache-C1rUEpaW.d.ts} +22 -1
- package/dist/anticipation-cache-LRE3TLK4.cjs +14 -0
- package/dist/anticipation-cache-LRE3TLK4.cjs.map +1 -0
- package/dist/anticipation-cache-WLU4NMD5.js +14 -0
- package/dist/chunk-2TVL5IPQ.cjs.map +1 -1
- package/dist/{chunk-3JSE64GW.cjs → chunk-7CWBRHUO.cjs} +15 -2
- package/dist/chunk-7CWBRHUO.cjs.map +1 -0
- package/dist/{chunk-6LDUDKHS.js → chunk-ODVOQOSO.js} +124 -8
- package/dist/chunk-ODVOQOSO.js.map +1 -0
- package/dist/{chunk-ZU6ZC4SU.js → chunk-T5QQBJ6T.js} +15 -2
- package/dist/chunk-T5QQBJ6T.js.map +1 -0
- package/dist/{chunk-RB57I2IQ.cjs → chunk-T6U5PVAD.cjs} +125 -9
- package/dist/chunk-T6U5PVAD.cjs.map +1 -0
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/grpc/index.cjs +4 -4
- package/dist/grpc/index.cjs.map +1 -1
- package/dist/grpc/index.d.cts +3 -3
- package/dist/grpc/index.d.ts +3 -3
- package/dist/grpc/index.js +3 -3
- package/dist/index.cjs +27 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +25 -14
- package/dist/index.js.map +1 -1
- package/dist/stream-client-2C5KIOWP.js +7 -0
- package/dist/stream-client-GPU37E6F.cjs +7 -0
- package/dist/stream-client-GPU37E6F.cjs.map +1 -0
- package/package.json +6 -1
- package/dist/anticipation-cache-ARYEEKMU.cjs +0 -10
- package/dist/anticipation-cache-ARYEEKMU.cjs.map +0 -1
- package/dist/anticipation-cache-H7HEVWQC.js +0 -10
- package/dist/chunk-3JSE64GW.cjs.map +0 -1
- package/dist/chunk-6LDUDKHS.js.map +0 -1
- package/dist/chunk-RB57I2IQ.cjs.map +0 -1
- package/dist/chunk-ZU6ZC4SU.js.map +0 -1
- package/dist/stream-client-6V4FGKZ3.js +0 -7
- package/dist/stream-client-PRTOH62B.cjs +0 -7
- package/dist/stream-client-PRTOH62B.cjs.map +0 -1
- /package/dist/{anticipation-cache-H7HEVWQC.js.map → anticipation-cache-WLU4NMD5.js.map} +0 -0
- /package/dist/{stream-client-6V4FGKZ3.js.map → stream-client-2C5KIOWP.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AnticipationCacheSnapshot } from './anticipation-cache-
|
|
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-
|
|
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';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
|
|
@@ -1439,8 +1439,15 @@ declare class SynapClient {
|
|
|
1439
1439
|
shutdown(): Promise<void>;
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
/**
|
|
1443
|
-
|
|
1442
|
+
/**
|
|
1443
|
+
* Kept in sync with package.json by the release workflow, in the
|
|
1444
|
+
* "Sync SDK_VERSION to the resolved version" step of publish-npm-js-sdk.yml.
|
|
1445
|
+
*
|
|
1446
|
+
* Until that step existed nothing kept it in sync, so this constant sat at
|
|
1447
|
+
* 1.0.0-beta.0 while the package shipped 0.4.x, and every request's User-Agent
|
|
1448
|
+
* and every telemetry event reported a version that was never released.
|
|
1449
|
+
*/
|
|
1450
|
+
declare const SDK_VERSION = "0.4.7";
|
|
1444
1451
|
|
|
1445
1452
|
/**
|
|
1446
1453
|
* Synap SDK error taxonomy.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as AnticipationCacheSnapshot } from './anticipation-cache-
|
|
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-
|
|
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';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
|
|
@@ -1439,8 +1439,15 @@ declare class SynapClient {
|
|
|
1439
1439
|
shutdown(): Promise<void>;
|
|
1440
1440
|
}
|
|
1441
1441
|
|
|
1442
|
-
/**
|
|
1443
|
-
|
|
1442
|
+
/**
|
|
1443
|
+
* Kept in sync with package.json by the release workflow, in the
|
|
1444
|
+
* "Sync SDK_VERSION to the resolved version" step of publish-npm-js-sdk.yml.
|
|
1445
|
+
*
|
|
1446
|
+
* Until that step existed nothing kept it in sync, so this constant sat at
|
|
1447
|
+
* 1.0.0-beta.0 while the package shipped 0.4.x, and every request's User-Agent
|
|
1448
|
+
* and every telemetry event reported a version that was never released.
|
|
1449
|
+
*/
|
|
1450
|
+
declare const SDK_VERSION = "0.4.7";
|
|
1444
1451
|
|
|
1445
1452
|
/**
|
|
1446
1453
|
* Synap SDK error taxonomy.
|
package/dist/index.js
CHANGED
|
@@ -30,9 +30,10 @@ import {
|
|
|
30
30
|
CONTRACT,
|
|
31
31
|
THRESHOLDS,
|
|
32
32
|
isRecallQuery,
|
|
33
|
+
rungKey,
|
|
33
34
|
stem,
|
|
34
35
|
tokenize
|
|
35
|
-
} from "./chunk-
|
|
36
|
+
} from "./chunk-ODVOQOSO.js";
|
|
36
37
|
import {
|
|
37
38
|
getEnv
|
|
38
39
|
} from "./chunk-QBCVMPGK.js";
|
|
@@ -1205,7 +1206,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
1205
1206
|
onFetched(
|
|
1206
1207
|
response,
|
|
1207
1208
|
id,
|
|
1208
|
-
options.user_id ?? options.userId
|
|
1209
|
+
options.user_id ?? options.userId,
|
|
1210
|
+
options.scope_path ?? options.scopePath
|
|
1209
1211
|
);
|
|
1210
1212
|
return response;
|
|
1211
1213
|
},
|
|
@@ -1400,7 +1402,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1400
1402
|
if (client !== null) {
|
|
1401
1403
|
throw new ListeningAlreadyActiveError("Listening is already active on this instance");
|
|
1402
1404
|
}
|
|
1403
|
-
const { GrpcStreamClient } = await import("./stream-client-
|
|
1405
|
+
const { GrpcStreamClient } = await import("./stream-client-2C5KIOWP.js");
|
|
1404
1406
|
const onContext = options.on_context ?? options.onContext;
|
|
1405
1407
|
const onDisconnect = options.on_disconnect ?? options.onDisconnect;
|
|
1406
1408
|
const onReconnect = options.on_reconnect ?? options.onReconnect;
|
|
@@ -1494,7 +1496,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1494
1496
|
}
|
|
1495
1497
|
|
|
1496
1498
|
// src/version.ts
|
|
1497
|
-
var SDK_VERSION = "
|
|
1499
|
+
var SDK_VERSION = "0.4.7";
|
|
1498
1500
|
|
|
1499
1501
|
// src/registry.ts
|
|
1500
1502
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -1944,16 +1946,16 @@ function mergeUserSummary(response, bundle) {
|
|
|
1944
1946
|
|
|
1945
1947
|
// src/context/anticipated.ts
|
|
1946
1948
|
function scopeLookupParams(scope, params) {
|
|
1947
|
-
const { searchQuery, entityId, customerId, clientId, conversationId } = params;
|
|
1949
|
+
const { searchQuery, entityId, customerId, clientId, conversationId, scopeRung } = params;
|
|
1948
1950
|
switch (scope) {
|
|
1949
1951
|
case "conversation":
|
|
1950
|
-
return { searchQuery, entityId, customerId, clientId, conversationId };
|
|
1952
|
+
return { searchQuery, entityId, customerId, clientId, conversationId, scopeRung };
|
|
1951
1953
|
case "user":
|
|
1952
|
-
return { searchQuery, entityId, customerId, clientId };
|
|
1954
|
+
return { searchQuery, entityId, customerId, clientId, scopeRung };
|
|
1953
1955
|
case "customer":
|
|
1954
|
-
return { searchQuery, entityId: null, customerId, clientId };
|
|
1956
|
+
return { searchQuery, entityId: null, customerId, clientId, scopeRung };
|
|
1955
1957
|
case "client":
|
|
1956
|
-
return { searchQuery, entityId: null, customerId: null, clientId };
|
|
1958
|
+
return { searchQuery, entityId: null, customerId: null, clientId, scopeRung };
|
|
1957
1959
|
}
|
|
1958
1960
|
}
|
|
1959
1961
|
function buildAnticipationResponse(hit) {
|
|
@@ -1988,6 +1990,7 @@ function tryServeFromCache(cache, scope, params, maxItems) {
|
|
|
1988
1990
|
customerId: scoped.customerId ?? null,
|
|
1989
1991
|
clientId: scoped.clientId ?? null,
|
|
1990
1992
|
conversationId: scoped.conversationId ?? null,
|
|
1993
|
+
scopeRung: scoped.scopeRung ?? null,
|
|
1991
1994
|
maxItems
|
|
1992
1995
|
});
|
|
1993
1996
|
if (hit === null) return { response: null, hit: null };
|
|
@@ -2500,7 +2503,15 @@ var SynapClient = class {
|
|
|
2500
2503
|
entityId: o2["user_id"] ?? o2["userId"],
|
|
2501
2504
|
customerId: o2["customer_id"] ?? o2["customerId"],
|
|
2502
2505
|
clientId: this.#transport.currentCredentials().clientId || null,
|
|
2503
|
-
conversationId: o2["conversation_id"] ?? o2["conversationId"]
|
|
2506
|
+
conversationId: o2["conversation_id"] ?? o2["conversationId"],
|
|
2507
|
+
// The rung this read is addressed to, in the same words the server
|
|
2508
|
+
// stamped on the bundles it pushed. Without it the cache matched
|
|
2509
|
+
// on entity and conversation alone, so a bundle prefetched for one
|
|
2510
|
+
// rung answered a caller standing at another, entirely inside this
|
|
2511
|
+
// process and invisible to every server log.
|
|
2512
|
+
scopeRung: rungKey(
|
|
2513
|
+
o2["scope_path"] ?? o2["scopePath"]
|
|
2514
|
+
)
|
|
2504
2515
|
},
|
|
2505
2516
|
Number(o2["max_results"] ?? o2["maxResults"] ?? 10)
|
|
2506
2517
|
);
|
|
@@ -2545,9 +2556,9 @@ var SynapClient = class {
|
|
|
2545
2556
|
({ conversationId, role, content, timestamp }) => {
|
|
2546
2557
|
this.#shortTerm.appendTurn(conversationId, role, content, timestamp);
|
|
2547
2558
|
},
|
|
2548
|
-
(response, conversationId, userId) => {
|
|
2559
|
+
(response, conversationId, userId, scopePath) => {
|
|
2549
2560
|
overlayLocalRecentTurns(response, this.#shortTerm, conversationId, this.#stVerbatimOverlay);
|
|
2550
|
-
this.#injectUserSummary(response, conversationId, userId);
|
|
2561
|
+
this.#injectUserSummary(response, conversationId, userId, rungKey(scopePath));
|
|
2551
2562
|
},
|
|
2552
2563
|
{
|
|
2553
2564
|
prompt: (conversationId, style) => this.#localPrompt(conversationId, style),
|
|
@@ -2912,11 +2923,11 @@ var SynapClient = class {
|
|
|
2912
2923
|
* cannot be scoped, and an unscoped lookup is how user A's summary ends up in
|
|
2913
2924
|
* user B's response.
|
|
2914
2925
|
*/
|
|
2915
|
-
#injectUserSummary(response, conversationId, userId) {
|
|
2926
|
+
#injectUserSummary(response, conversationId, userId, scopeRung) {
|
|
2916
2927
|
this.#turns.increment(conversationId);
|
|
2917
2928
|
if (userId === void 0 || userId === "") return;
|
|
2918
2929
|
if (!this.#turns.shouldInject(conversationId)) return;
|
|
2919
|
-
const summary = this.#anticipationCache.lookupUserSummary(userId);
|
|
2930
|
+
const summary = this.#anticipationCache.lookupUserSummary(userId, scopeRung);
|
|
2920
2931
|
if (summary === null) return;
|
|
2921
2932
|
mergeUserSummary(response, summary);
|
|
2922
2933
|
}
|