@maximem/synap-js-sdk 0.7.1 → 0.7.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.
- package/dist/{anticipation-cache-VL5WHTJB.js → anticipation-cache-B5OY43LX.js} +2 -2
- package/dist/anticipation-cache-JDX2VTFE.cjs +26 -0
- package/dist/anticipation-cache-JDX2VTFE.cjs.map +1 -0
- package/dist/{chunk-BYUGILQI.cjs → chunk-6GHXJD7L.cjs} +92 -3
- package/dist/chunk-6GHXJD7L.cjs.map +1 -0
- package/dist/chunk-JPDEKN5M.cjs.map +1 -1
- package/dist/chunk-SAKMZI7G.cjs.map +1 -1
- package/dist/{chunk-CSG3N5E3.js → chunk-W6AH4CPC.js} +91 -2
- package/dist/chunk-W6AH4CPC.js.map +1 -0
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/grpc/index.cjs +1 -1
- package/dist/grpc/index.cjs.map +1 -1
- package/dist/grpc/index.js +1 -1
- package/dist/index.cjs +54 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +36 -14
- package/dist/index.js.map +1 -1
- package/dist/onnx-encoder-4RSL6ID4.cjs.map +1 -1
- package/dist/stream-client-H2ES74FF.cjs.map +1 -1
- package/package.json +1 -1
- package/dist/anticipation-cache-Q7IYC3ID.cjs +0 -26
- package/dist/anticipation-cache-Q7IYC3ID.cjs.map +0 -1
- package/dist/chunk-BYUGILQI.cjs.map +0 -1
- package/dist/chunk-CSG3N5E3.js.map +0 -1
- /package/dist/{anticipation-cache-VL5WHTJB.js.map → anticipation-cache-B5OY43LX.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
|
|
13
|
+
var _chunk6GHXJD7Lcjs = require('./chunk-6GHXJD7L.cjs');
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
var _chunkZKOJDUN4cjs = require('./chunk-ZKOJDUN4.cjs');
|
|
@@ -2339,6 +2340,7 @@ function buildCompactBody(options) {
|
|
|
2339
2340
|
var CompactionSubscribers = class {
|
|
2340
2341
|
#byConversation = /* @__PURE__ */ new Map();
|
|
2341
2342
|
add(conversationId, callback) {
|
|
2343
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2342
2344
|
const list = this.#byConversation.get(conversationId);
|
|
2343
2345
|
if (list === void 0) this.#byConversation.set(conversationId, [callback]);
|
|
2344
2346
|
else list.push(callback);
|
|
@@ -2354,6 +2356,7 @@ var CompactionSubscribers = class {
|
|
|
2354
2356
|
};
|
|
2355
2357
|
}
|
|
2356
2358
|
removeAll(conversationId) {
|
|
2359
|
+
if (conversationId !== void 0) conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2357
2360
|
if (conversationId === void 0) {
|
|
2358
2361
|
let count = 0;
|
|
2359
2362
|
for (const list2 of this.#byConversation.values()) count += list2.length;
|
|
@@ -2367,6 +2370,7 @@ var CompactionSubscribers = class {
|
|
|
2367
2370
|
}
|
|
2368
2371
|
/** Fires subscribers in registration order. A throwing listener must not break the stream reader. */
|
|
2369
2372
|
dispatch(conversationId, bundle, onError) {
|
|
2373
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2370
2374
|
for (const callback of [..._nullishCoalesce(this.#byConversation.get(conversationId), () => ( []))]) {
|
|
2371
2375
|
try {
|
|
2372
2376
|
const result = callback(bundle);
|
|
@@ -2994,9 +2998,18 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2994
2998
|
return client !== null && client.isConnected;
|
|
2995
2999
|
}
|
|
2996
3000
|
};
|
|
3001
|
+
function openSessionKey(conversationId) {
|
|
3002
|
+
if (!conversationId) return void 0;
|
|
3003
|
+
if (openSessions.has(conversationId)) return conversationId;
|
|
3004
|
+
const wanted = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3005
|
+
for (const key of openSessions.keys()) {
|
|
3006
|
+
if (_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, key) === wanted) return key;
|
|
3007
|
+
}
|
|
3008
|
+
return void 0;
|
|
3009
|
+
}
|
|
2997
3010
|
function ensureSession(conversationId, userId, customerId) {
|
|
2998
3011
|
if (!conversationId || !userId || client === null) return;
|
|
2999
|
-
if (
|
|
3012
|
+
if (openSessionKey(conversationId) !== void 0) return;
|
|
3000
3013
|
const sessionId = _chunkJPDEKN5Mcjs.newCorrelationId.call(void 0, );
|
|
3001
3014
|
try {
|
|
3002
3015
|
client.sendSessionControl({
|
|
@@ -3090,9 +3103,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3090
3103
|
await active.disconnect();
|
|
3091
3104
|
},
|
|
3092
3105
|
async end_session(conversationId) {
|
|
3093
|
-
const
|
|
3094
|
-
|
|
3095
|
-
|
|
3106
|
+
const openedAs = openSessionKey(conversationId);
|
|
3107
|
+
const sessionId = openedAs === void 0 ? void 0 : openSessions.get(openedAs);
|
|
3108
|
+
if (openedAs === void 0 || sessionId === void 0 || client === null) return;
|
|
3109
|
+
openSessions.delete(openedAs);
|
|
3096
3110
|
try {
|
|
3097
3111
|
client.sendSessionControl({
|
|
3098
3112
|
action: "end",
|
|
@@ -3142,7 +3156,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3142
3156
|
conversation_id: _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( "")),
|
|
3143
3157
|
user_id: _nullishCoalesce(_nullishCoalesce(options.user_id, () => ( options.userId)), () => ( "")),
|
|
3144
3158
|
customer_id: _nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( "")),
|
|
3145
|
-
session_id: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(options.session_id, () => ( options.sessionId)), () => ( openSessions.get(conversationId))), () => ( "")),
|
|
3159
|
+
session_id: _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(options.session_id, () => ( options.sessionId)), () => ( openSessions.get(_nullishCoalesce(openSessionKey(conversationId), () => ( ""))))), () => ( "")),
|
|
3146
3160
|
metadata: _nullishCoalesce(withAgentModel(metadata, agentModelOf(options), agentModel(), true), () => ( {})),
|
|
3147
3161
|
timestamp_ms: Date.now(),
|
|
3148
3162
|
tool_name: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")),
|
|
@@ -3255,7 +3269,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3255
3269
|
}
|
|
3256
3270
|
|
|
3257
3271
|
// src/version.ts
|
|
3258
|
-
var SDK_VERSION = "0.7.
|
|
3272
|
+
var SDK_VERSION = "0.7.2";
|
|
3259
3273
|
|
|
3260
3274
|
// src/registry.ts
|
|
3261
3275
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -3363,6 +3377,7 @@ var ShortTermStore = class {
|
|
|
3363
3377
|
/** The entry, or null. Age-evicts on read, as Python does. */
|
|
3364
3378
|
get(conversationId) {
|
|
3365
3379
|
if (!conversationId) return null;
|
|
3380
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3366
3381
|
const entry = this.#entries.get(conversationId);
|
|
3367
3382
|
if (entry === void 0) return null;
|
|
3368
3383
|
if (this.#now() - entry.lastActivityAt > this.#maxAgeMs) {
|
|
@@ -3391,6 +3406,7 @@ var ShortTermStore = class {
|
|
|
3391
3406
|
*/
|
|
3392
3407
|
appendTurn(conversationId, role, content, timestamp, confirmation = {}) {
|
|
3393
3408
|
if (!conversationId) return;
|
|
3409
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3394
3410
|
const stamp = _nullishCoalesce(timestamp, () => ( new Date(this.#now()).toISOString()));
|
|
3395
3411
|
if (this.#archive !== null) {
|
|
3396
3412
|
try {
|
|
@@ -3424,6 +3440,7 @@ var ShortTermStore = class {
|
|
|
3424
3440
|
*/
|
|
3425
3441
|
noteServerCount(conversationId, count) {
|
|
3426
3442
|
if (!conversationId) return;
|
|
3443
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3427
3444
|
const entry = this.#entries.get(conversationId);
|
|
3428
3445
|
if (entry !== void 0) this.#noteCount(entry, Number(count), 0);
|
|
3429
3446
|
}
|
|
@@ -3471,10 +3488,11 @@ var ShortTermStore = class {
|
|
|
3471
3488
|
applyCompaction(bundle) {
|
|
3472
3489
|
if (typeof bundle !== "object" || bundle === null) return;
|
|
3473
3490
|
const cc = _nullishCoalesce(bundle["conversation_context"], () => ( {}));
|
|
3474
|
-
const
|
|
3491
|
+
const rawConversationId = String(
|
|
3475
3492
|
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(cc["conversation_id"], () => ( bundle["anticipation_conversation_id"])), () => ( bundle["conversation_id"])), () => ( ""))
|
|
3476
3493
|
);
|
|
3477
|
-
if (!
|
|
3494
|
+
if (!rawConversationId) return;
|
|
3495
|
+
const conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, rawConversationId);
|
|
3478
3496
|
const endTs = parseIso(_nullishCoalesce(cc["end_timestamp"], () => ( cc["compacted_at"])));
|
|
3479
3497
|
const compactedAt = parseIso(cc["compacted_at"]);
|
|
3480
3498
|
const compactedCount = Number(_nullishCoalesce(cc["compacted_message_count"], () => ( 0))) || 0;
|
|
@@ -3539,6 +3557,7 @@ var ShortTermStore = class {
|
|
|
3539
3557
|
*/
|
|
3540
3558
|
reseed(conversationId, state) {
|
|
3541
3559
|
if (!conversationId) return;
|
|
3560
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3542
3561
|
const entry = this.#entries.get(conversationId);
|
|
3543
3562
|
if (entry === void 0 || entry.shared) return;
|
|
3544
3563
|
entry.serverMessageCount = Math.max(
|
|
@@ -3555,7 +3574,7 @@ var ShortTermStore = class {
|
|
|
3555
3574
|
entry.synced = true;
|
|
3556
3575
|
}
|
|
3557
3576
|
invalidate(conversationId) {
|
|
3558
|
-
this.#entries.delete(conversationId);
|
|
3577
|
+
this.#entries.delete(_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId));
|
|
3559
3578
|
}
|
|
3560
3579
|
clear() {
|
|
3561
3580
|
this.#entries.clear();
|
|
@@ -3609,7 +3628,7 @@ var TurnStore = (_class3 = class {
|
|
|
3609
3628
|
#conversations = /* @__PURE__ */ new Map();
|
|
3610
3629
|
#vectors = /* @__PURE__ */ new Map();
|
|
3611
3630
|
constructor(options = {}) {;_class3.prototype.__init7.call(this);
|
|
3612
|
-
this.limits = _nullishCoalesce(options.limits, () => ( { ...
|
|
3631
|
+
this.limits = _nullishCoalesce(options.limits, () => ( { ..._chunk6GHXJD7Lcjs.HISTORY_SEARCH.store_limits }));
|
|
3613
3632
|
this.#now = _nullishCoalesce(options.now, () => ( (() => Date.now() / 1e3)));
|
|
3614
3633
|
}
|
|
3615
3634
|
add(conversationId, role, content, timestamp, options = {}) {
|
|
@@ -3753,11 +3772,11 @@ var TurnStore = (_class3 = class {
|
|
|
3753
3772
|
|
|
3754
3773
|
// src/cache/history-search.ts
|
|
3755
3774
|
var WORD_RE = /[\p{L}\p{N}\p{M}]+/gu;
|
|
3756
|
-
var FORMS = _nullishCoalesce(
|
|
3775
|
+
var FORMS = _nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.irregular_forms, () => ( {}));
|
|
3757
3776
|
function tokenize2(text) {
|
|
3758
3777
|
const out = [];
|
|
3759
3778
|
for (const word of _nullishCoalesce((text || "").toLowerCase().match(WORD_RE), () => ( []))) {
|
|
3760
|
-
if (/^[\x00-\x7f]+$/.test(word)) out.push(...
|
|
3779
|
+
if (/^[\x00-\x7f]+$/.test(word)) out.push(..._chunk6GHXJD7Lcjs.tokenize.call(void 0, _nullishCoalesce(FORMS[word], () => ( word))));
|
|
3761
3780
|
else out.push(word);
|
|
3762
3781
|
}
|
|
3763
3782
|
return out;
|
|
@@ -3894,19 +3913,19 @@ function windowsOf(pieces, maxWords) {
|
|
|
3894
3913
|
}
|
|
3895
3914
|
function askedKinds(query) {
|
|
3896
3915
|
const out = [];
|
|
3897
|
-
for (const [name, spec] of Object.entries(_nullishCoalesce(
|
|
3916
|
+
for (const [name, spec] of Object.entries(_nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.asked_kinds, () => ( {})))) {
|
|
3898
3917
|
if (name.startsWith("$") || typeof spec !== "object") continue;
|
|
3899
3918
|
if (new RegExp(spec.query, "i").test(_nullishCoalesce(query, () => ( "")))) out.push(new RegExp(spec.value));
|
|
3900
3919
|
}
|
|
3901
3920
|
return out;
|
|
3902
3921
|
}
|
|
3903
3922
|
function asksHowItStarted(query) {
|
|
3904
|
-
const spec =
|
|
3923
|
+
const spec = _chunk6GHXJD7Lcjs.HISTORY_SEARCH.early_query;
|
|
3905
3924
|
if (!_optionalChain([spec, 'optionalAccess', _103 => _103.pattern])) return false;
|
|
3906
3925
|
return new RegExp(spec.pattern, (_nullishCoalesce(spec.flags, () => ( ""))).includes("i") ? "i" : "").test(_nullishCoalesce(query, () => ( "")));
|
|
3907
3926
|
}
|
|
3908
3927
|
async function searchTurns(turns, query, options = {}) {
|
|
3909
|
-
const params =
|
|
3928
|
+
const params = _chunk6GHXJD7Lcjs.HISTORY_SEARCH;
|
|
3910
3929
|
const k = params.max_excerpts;
|
|
3911
3930
|
const skip = new Set(_nullishCoalesce(options.exclude, () => ( [])));
|
|
3912
3931
|
const pool = turns.filter((t) => t.content && !skip.has(t.content) && !skip.has(_nullishCoalesce(t.message_id, () => ( ""))));
|
|
@@ -3933,7 +3952,7 @@ async function searchTurns(turns, query, options = {}) {
|
|
|
3933
3952
|
});
|
|
3934
3953
|
});
|
|
3935
3954
|
const docs = units.map((u) => tokenize2(u.content));
|
|
3936
|
-
const bm = new (0,
|
|
3955
|
+
const bm = new (0, _chunk6GHXJD7Lcjs.BM25)(docs);
|
|
3937
3956
|
const termList = [...terms];
|
|
3938
3957
|
const rows = units.map((turn, i) => {
|
|
3939
3958
|
const held = new Set(docs[i]);
|
|
@@ -4071,13 +4090,13 @@ async function embeddingRanks(pool, query, encoder, store, minCosine) {
|
|
|
4071
4090
|
}
|
|
4072
4091
|
function toolResultText(result, toolName) {
|
|
4073
4092
|
let text = typeof result === "string" ? result : _nullishCoalesce(JSON.stringify(result), () => ( String(result)));
|
|
4074
|
-
const limit = _nullishCoalesce(
|
|
4093
|
+
const limit = _nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.tool_result_max_chars, () => ( 16e3));
|
|
4075
4094
|
if (text.length > limit) text = text.slice(0, limit) + " ...[cut]";
|
|
4076
4095
|
return `[tool result: ${toolName || "tool"}] ${text}`;
|
|
4077
4096
|
}
|
|
4078
4097
|
function renderExcerpts(excerpts, latest = "") {
|
|
4079
4098
|
if (excerpts.length === 0) return "";
|
|
4080
|
-
const lines = [
|
|
4099
|
+
const lines = [_chunk6GHXJD7Lcjs.HISTORY_SEARCH.heading];
|
|
4081
4100
|
for (const e of excerpts) {
|
|
4082
4101
|
let where = e.position ? `turn ${e.position}, ${e.role}` : `${e.role}, earlier`;
|
|
4083
4102
|
if (e.timestamp) {
|
|
@@ -4356,7 +4375,7 @@ var TurnCounter = class {
|
|
|
4356
4375
|
#counts = /* @__PURE__ */ new Map();
|
|
4357
4376
|
/** Increment and return the new count. Python buckets a missing id under `_global`. */
|
|
4358
4377
|
increment(conversationId) {
|
|
4359
|
-
const key = conversationId !== void 0 && conversationId !== "" ? conversationId : "_global";
|
|
4378
|
+
const key = conversationId !== void 0 && conversationId !== "" ? _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId) : "_global";
|
|
4360
4379
|
const next = (_nullishCoalesce(this.#counts.get(key), () => ( 0))) + 1;
|
|
4361
4380
|
this.#counts.set(key, next);
|
|
4362
4381
|
return next;
|
|
@@ -4369,7 +4388,7 @@ var TurnCounter = class {
|
|
|
4369
4388
|
* triggered a fresh retrieval anyway.
|
|
4370
4389
|
*/
|
|
4371
4390
|
shouldInject(conversationId) {
|
|
4372
|
-
const key = conversationId !== void 0 && conversationId !== "" ? conversationId : "_global";
|
|
4391
|
+
const key = conversationId !== void 0 && conversationId !== "" ? _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId) : "_global";
|
|
4373
4392
|
const count = _nullishCoalesce(this.#counts.get(key), () => ( 0));
|
|
4374
4393
|
return count > 0 && count % USER_SUMMARY_INTERVAL === 0;
|
|
4375
4394
|
}
|
|
@@ -5059,7 +5078,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5059
5078
|
this.#transport.onInvalidInput = (_error, carriedScopePath) => {
|
|
5060
5079
|
if (carriedScopePath) this.#transport.invalidateScopeLadder();
|
|
5061
5080
|
};
|
|
5062
|
-
this.#anticipationCache = new (0,
|
|
5081
|
+
this.#anticipationCache = new (0, _chunk6GHXJD7Lcjs.AnticipationCache)();
|
|
5063
5082
|
this.#fetchHooks = {
|
|
5064
5083
|
beforeFetch: async (scope, options2) => {
|
|
5065
5084
|
const o2 = options2;
|
|
@@ -5078,7 +5097,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5078
5097
|
// on entity and conversation alone, so a bundle prefetched for one
|
|
5079
5098
|
// rung answered a caller standing at another, entirely inside this
|
|
5080
5099
|
// process and invisible to every server log.
|
|
5081
|
-
scopeRung:
|
|
5100
|
+
scopeRung: _chunk6GHXJD7Lcjs.rungKey.call(void 0,
|
|
5082
5101
|
_nullishCoalesce(o2["scope_path"], () => ( o2["scopePath"]))
|
|
5083
5102
|
),
|
|
5084
5103
|
maxResultsPerQuery: _nullishCoalesce(_nullishCoalesce(o2["max_results_per_query"], () => ( o2["maxResultsPerQuery"])), () => ( null))
|
|
@@ -5091,7 +5110,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5091
5110
|
servedItemIds: servedItemIds(attempt.hit),
|
|
5092
5111
|
bundleId: _nullishCoalesce(attempt.hit.bundleIds[0], () => ( "")),
|
|
5093
5112
|
borderline: attempt.hit.band === "borderline",
|
|
5094
|
-
raceDeadlineMs:
|
|
5113
|
+
raceDeadlineMs: _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.race_deadline_ms
|
|
5095
5114
|
};
|
|
5096
5115
|
},
|
|
5097
5116
|
onAssembled: (scope, options2, response, startedAt) => {
|
|
@@ -5144,7 +5163,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5144
5163
|
response,
|
|
5145
5164
|
_nullishCoalesce(o2["conversation_id"], () => ( o2["conversationId"])),
|
|
5146
5165
|
owner,
|
|
5147
|
-
|
|
5166
|
+
_chunk6GHXJD7Lcjs.rungKey.call(void 0, _nullishCoalesce(o2["scope_path"], () => ( o2["scopePath"])))
|
|
5148
5167
|
);
|
|
5149
5168
|
}
|
|
5150
5169
|
};
|
|
@@ -5165,7 +5184,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5165
5184
|
this.#localEncoder = _nullishCoalesce(_nullishCoalesce(options.history_search_encoder, () => ( options.historySearchEncoder)), () => ( null));
|
|
5166
5185
|
const modelOption = options.history_search_model !== void 0 ? options.history_search_model : options.historySearchModel;
|
|
5167
5186
|
this.#localModelName = modelOption === void 0 ? "auto" : modelOption;
|
|
5168
|
-
if (_optionalChain([this, 'access', _104 => _104.#localEncoder, 'optionalAccess', _105 => _105.model]) ===
|
|
5187
|
+
if (_optionalChain([this, 'access', _104 => _104.#localEncoder, 'optionalAccess', _105 => _105.model]) === _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
|
|
5169
5188
|
this.#turns = new TurnCounter();
|
|
5170
5189
|
this.conversation = createConversationNamespace(
|
|
5171
5190
|
this.#transport,
|
|
@@ -5191,7 +5210,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5191
5210
|
},
|
|
5192
5211
|
(response, conversationId, userId, scopePath) => {
|
|
5193
5212
|
overlayLocalRecentTurns(response, this.#shortTerm, conversationId, this.#stVerbatimOverlay);
|
|
5194
|
-
this.#injectUserSummary(response, conversationId, userId,
|
|
5213
|
+
this.#injectUserSummary(response, conversationId, userId, _chunk6GHXJD7Lcjs.rungKey.call(void 0, scopePath));
|
|
5195
5214
|
},
|
|
5196
5215
|
{
|
|
5197
5216
|
prompt: (conversationId, style) => this.#localPrompt(conversationId, style),
|
|
@@ -5216,7 +5235,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5216
5235
|
if (scope === "conversation") {
|
|
5217
5236
|
if (conversationId) {
|
|
5218
5237
|
this.#shortTerm.invalidate(conversationId);
|
|
5219
|
-
this.#turnStore.drop(conversationId);
|
|
5238
|
+
this.#turnStore.drop(_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId));
|
|
5220
5239
|
cleared.push("short_term_context", "turns");
|
|
5221
5240
|
}
|
|
5222
5241
|
} else {
|
|
@@ -5735,6 +5754,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5735
5754
|
async #withHistoryExcerpts(conversationId, response, query) {
|
|
5736
5755
|
const r = _nullishCoalesce(response, () => ( {}));
|
|
5737
5756
|
const store = this.#turnStore;
|
|
5757
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5738
5758
|
const recent = Array.isArray(r["recent_messages"]) ? r["recent_messages"] : [];
|
|
5739
5759
|
store.addMany(
|
|
5740
5760
|
conversationId,
|
|
@@ -5782,7 +5802,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5782
5802
|
if (!conversationId || result === null || result === void 0) return;
|
|
5783
5803
|
try {
|
|
5784
5804
|
this.#turnStore.add(
|
|
5785
|
-
conversationId,
|
|
5805
|
+
_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId),
|
|
5786
5806
|
"tool",
|
|
5787
5807
|
toolResultText(result, _nullishCoalesce(options.tool_name, () => ( options.toolName))),
|
|
5788
5808
|
_nullishCoalesce(options.timestamp, () => ( (/* @__PURE__ */ new Date()).toISOString()))
|
|
@@ -5801,17 +5821,18 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5801
5821
|
if (this.#localModelStarted) return;
|
|
5802
5822
|
this.#localModelStarted = true;
|
|
5803
5823
|
if (localModelOff()) return;
|
|
5804
|
-
const name = this.#localModelName === "auto" ?
|
|
5824
|
+
const name = this.#localModelName === "auto" ? _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model : this.#localModelName;
|
|
5805
5825
|
if (!name) return;
|
|
5806
5826
|
const callerEncoder = this.#localEncoder;
|
|
5807
5827
|
void Promise.resolve().then(() => _interopRequireWildcard(require("./onnx-encoder-4RSL6ID4.cjs"))).then(({ canRunLocalModel, loadOnnxEncoder }) => canRunLocalModel() ? loadOnnxEncoder(name) : null).then((encoder) => {
|
|
5808
5828
|
if (encoder === null) return;
|
|
5809
5829
|
if (callerEncoder === null) this.#localEncoder = encoder;
|
|
5810
|
-
if (encoder.model ===
|
|
5830
|
+
if (encoder.model === _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(encoder);
|
|
5811
5831
|
}).catch(() => {
|
|
5812
5832
|
});
|
|
5813
5833
|
}
|
|
5814
5834
|
#maybeBackfillTurns(conversationId, total) {
|
|
5835
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5815
5836
|
if (total <= this.#turnStore.count(conversationId)) return;
|
|
5816
5837
|
const now = Date.now();
|
|
5817
5838
|
if (now < (_nullishCoalesce(this.#backfillAfter.get(conversationId), () => ( 0)))) return;
|
|
@@ -5819,6 +5840,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5819
5840
|
void this.#backfillTurns(conversationId, total);
|
|
5820
5841
|
}
|
|
5821
5842
|
async #backfillTurns(conversationId, total) {
|
|
5843
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5822
5844
|
try {
|
|
5823
5845
|
let start = 1;
|
|
5824
5846
|
while (start <= total) {
|
|
@@ -5981,5 +6003,5 @@ function resolveCredentials(options, localMode) {
|
|
|
5981
6003
|
|
|
5982
6004
|
|
|
5983
6005
|
|
|
5984
|
-
exports.ANY_SCOPE =
|
|
6006
|
+
exports.ANY_SCOPE = _chunk6GHXJD7Lcjs.ANY_SCOPE; exports.AgentUnavailableError = _chunkJPDEKN5Mcjs.AgentUnavailableError; exports.AnticipationCache = _chunk6GHXJD7Lcjs.AnticipationCache; exports.AuthenticationError = _chunkJPDEKN5Mcjs.AuthenticationError; exports.BM25 = _chunk6GHXJD7Lcjs.BM25; exports.COMPACTION_LEVELS = COMPACTION_LEVELS; exports.CONTRACT = _chunk6GHXJD7Lcjs.CONTRACT; exports.ConflictError = _chunkJPDEKN5Mcjs.ConflictError; exports.ConnectionError = _chunkJPDEKN5Mcjs.ConnectionError; exports.ContextNotFoundError = _chunkJPDEKN5Mcjs.ContextNotFoundError; exports.CustomerIdNotAcceptedError = _chunkJPDEKN5Mcjs.CustomerIdNotAcceptedError; exports.DATA_SCOPES = DATA_SCOPES; exports.DEFAULT_BASE_URL = DEFAULT_BASE_URL; exports.DEFAULT_DOCUMENT_TYPE = DEFAULT_DOCUMENT_TYPE; exports.DEFAULT_INGEST_MODE = DEFAULT_INGEST_MODE; exports.DEFAULT_RETRY_POLICY = DEFAULT_RETRY_POLICY; exports.DEFAULT_TIMEOUTS = DEFAULT_TIMEOUTS; exports.DOCUMENT_TYPES = DOCUMENT_TYPES; exports.ENDPOINTS = ENDPOINTS; exports.EXCERPT_CATEGORY = EXCERPT_CATEGORY; exports.FORGET_MODES = FORGET_MODES; exports.HttpTransport = HttpTransport; exports.INGEST_MODES = INGEST_MODES; exports.ITEM_COLLECTIONS = ITEM_COLLECTIONS; exports.InstanceBuildFailedError = _chunkJPDEKN5Mcjs.InstanceBuildFailedError; exports.InstanceNotReadyError = _chunkJPDEKN5Mcjs.InstanceNotReadyError; exports.InsufficientCreditsError = _chunkJPDEKN5Mcjs.InsufficientCreditsError; exports.InvalidConversationIdError = _chunkJPDEKN5Mcjs.InvalidConversationIdError; exports.InvalidInputError = _chunkJPDEKN5Mcjs.InvalidInputError; exports.InvalidInstanceIdError = _chunkJPDEKN5Mcjs.InvalidInstanceIdError; exports.ListeningAlreadyActiveError = _chunkJPDEKN5Mcjs.ListeningAlreadyActiveError; exports.ListeningNotActiveError = _chunkJPDEKN5Mcjs.ListeningNotActiveError; exports.MEMORY_TYPES = MEMORY_TYPES; exports.NetworkTimeoutError = _chunkJPDEKN5Mcjs.NetworkTimeoutError; exports.OBJECTIVES = OBJECTIVES; exports.PermanentError = _chunkJPDEKN5Mcjs.PermanentError; exports.RESPONSE_SHAPES = RESPONSE_SHAPES; exports.RateLimitError = _chunkJPDEKN5Mcjs.RateLimitError; exports.SDKError = _chunkJPDEKN5Mcjs.SDKError; exports.SDK_VERSION = SDK_VERSION; exports.ScopeAddress = ScopeAddress; exports.ScopeLadder = ScopeLadder; exports.ScopeLadderError = _chunkJPDEKN5Mcjs.ScopeLadderError; exports.ServiceUnavailableError = _chunkJPDEKN5Mcjs.ServiceUnavailableError; exports.SessionExpiredError = _chunkJPDEKN5Mcjs.SessionExpiredError; exports.SynapClient = SynapClient; exports.SynapError = _chunkJPDEKN5Mcjs.SynapError; exports.SynapPermanentError = _chunkJPDEKN5Mcjs.SynapPermanentError; exports.SynapTransientError = _chunkJPDEKN5Mcjs.SynapTransientError; exports.THRESHOLDS = _chunk6GHXJD7Lcjs.THRESHOLDS; exports.TranscriptConflictError = _chunkJPDEKN5Mcjs.TranscriptConflictError; exports.TransientError = _chunkJPDEKN5Mcjs.TransientError; exports.applyResponseShape = applyResponseShape; exports.filePart = filePart; exports.flattenContextItems = flattenContextItems; exports.formatForPrompt = formatForPrompt; exports.isOutcomeUnknown = isOutcomeUnknown; exports.isSynapError = _chunkJPDEKN5Mcjs.isSynapError; exports.mergeScopeResults = mergeScopeResults; exports.rankItems = rankItems; exports.resolvePath = resolvePath; exports.shouldRetry = shouldRetry; exports.stem = _chunk6GHXJD7Lcjs.stem; exports.textPart = textPart; exports.tokenize = _chunk6GHXJD7Lcjs.tokenize; exports.wireRankScore = wireRankScore;
|
|
5985
6007
|
//# sourceMappingURL=index.cjs.map
|