@maximem/synap-js-sdk 0.7.0 → 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 +162 -99
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -4
- package/dist/index.d.ts +33 -4
- package/dist/index.js +80 -17
- 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');
|
|
@@ -232,7 +233,16 @@ var ScopeAddress = class {
|
|
|
232
233
|
this.customer_id = _nullishCoalesce(init.customer_id, () => ( null));
|
|
233
234
|
this.scope_path = _nullishCoalesce(init.scope_path, () => ( null));
|
|
234
235
|
}
|
|
235
|
-
/**
|
|
236
|
+
/**
|
|
237
|
+
* Options for reads: `fetch`, `send_message`, `record_message`,
|
|
238
|
+
* `user.context.fetch`, `conversation.context.fetch` and
|
|
239
|
+
* `client.context.fetch`. The path is `scope_path`.
|
|
240
|
+
*
|
|
241
|
+
* Not for `customer.context.fetch`: that route refuses a path that names the
|
|
242
|
+
* identity rung (HTTP 400, it reads shared material only) and takes no
|
|
243
|
+
* `user_id`. Call `client.fetch(addr.read_kwargs())`, which sends the
|
|
244
|
+
* customer route the path cut above the identity rung.
|
|
245
|
+
*/
|
|
236
246
|
read_kwargs() {
|
|
237
247
|
const out = {};
|
|
238
248
|
if (this.user_id) out.user_id = this.user_id;
|
|
@@ -253,6 +263,21 @@ var ScopeAddress = class {
|
|
|
253
263
|
return out;
|
|
254
264
|
}
|
|
255
265
|
};
|
|
266
|
+
var RESERVED_IDENTITY_KEY = "user";
|
|
267
|
+
function pathAboveIdentity(scopePath, ladder) {
|
|
268
|
+
if (!scopePath || Object.keys(scopePath).length === 0) return void 0;
|
|
269
|
+
const identity = _optionalChain([ladder, 'optionalAccess', _9 => _9.levels, 'access', _10 => _10.find, 'call', _11 => _11((lv) => lv.role === ROLE_IDENTITY)]);
|
|
270
|
+
const out = {};
|
|
271
|
+
if (!ladder || !identity) {
|
|
272
|
+
for (const [k, v] of Object.entries(scopePath)) if (k !== RESERVED_IDENTITY_KEY) out[k] = v;
|
|
273
|
+
} else {
|
|
274
|
+
const position = new Map(ladder.levels.map((lv) => [lv.key, lv.position]));
|
|
275
|
+
for (const [k, v] of Object.entries(scopePath)) {
|
|
276
|
+
if ((_nullishCoalesce(position.get(k), () => ( -1))) < identity.position) out[k] = v;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
return Object.keys(out).length > 0 ? out : void 0;
|
|
280
|
+
}
|
|
256
281
|
var REFRESH_HINT = "The account's ladder may not be accepted yet, or nested scoping may be off for this instance. If that changed recently, `await sdk.get_scope_ladder({ refresh: true })` re-reads it.";
|
|
257
282
|
var ScopeLadder = class {
|
|
258
283
|
|
|
@@ -473,7 +498,7 @@ var HttpTransport = (_class2 = class {
|
|
|
473
498
|
this.keepAliveOptions = _nullishCoalesce(options.keepAlive, () => ( {}));
|
|
474
499
|
this.heartbeat = new Heartbeat(
|
|
475
500
|
() => this.pingHealth(),
|
|
476
|
-
_nullishCoalesce(_optionalChain([options, 'access',
|
|
501
|
+
_nullishCoalesce(_optionalChain([options, 'access', _12 => _12.keepAlive, 'optionalAccess', _13 => _13.heartbeatIntervalMs]), () => ( HEARTBEAT_INTERVAL_MS))
|
|
477
502
|
);
|
|
478
503
|
}
|
|
479
504
|
/**
|
|
@@ -560,6 +585,10 @@ var HttpTransport = (_class2 = class {
|
|
|
560
585
|
this.#ladderInvalidated = true;
|
|
561
586
|
this.#ladderRetryAt = 0;
|
|
562
587
|
}
|
|
588
|
+
/** The ladder already held, or null when none has been read. Makes no request. */
|
|
589
|
+
cachedScopeLadder() {
|
|
590
|
+
return this.#ladderLoaded ? this.#ladder : null;
|
|
591
|
+
}
|
|
563
592
|
/**
|
|
564
593
|
* The account's ladder, from whoami, cached for 300 s (`null` included).
|
|
565
594
|
* Concurrent callers share one read. A failed re-read after expiry keeps the
|
|
@@ -602,7 +631,7 @@ var HttpTransport = (_class2 = class {
|
|
|
602
631
|
} catch (error) {
|
|
603
632
|
if (keepOnFailure) {
|
|
604
633
|
warn(
|
|
605
|
-
`Could not re-read the scope ladder (${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
634
|
+
`Could not re-read the scope ladder (${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _14 => _14.message]), () => ( String(error)))}); keeping the last known one and retrying in ${LADDER_RETRY_BACKOFF_MS / 1e3}s.`
|
|
606
635
|
);
|
|
607
636
|
this.#ladderRetryAt = now + LADDER_RETRY_BACKOFF_MS;
|
|
608
637
|
return cached2;
|
|
@@ -723,7 +752,7 @@ var HttpTransport = (_class2 = class {
|
|
|
723
752
|
await sleep(decision.delaySeconds * 1e3, options.signal);
|
|
724
753
|
}
|
|
725
754
|
}
|
|
726
|
-
throw _nullishCoalesce(_optionalChain([last, 'optionalAccess',
|
|
755
|
+
throw _nullishCoalesce(_optionalChain([last, 'optionalAccess', _15 => _15.error]), () => ( new (0, _chunkJPDEKN5Mcjs.SynapError)("Request failed with no recorded error")));
|
|
727
756
|
}
|
|
728
757
|
async attempt(name, options, correlationId) {
|
|
729
758
|
const spec = ENDPOINTS[name];
|
|
@@ -751,11 +780,11 @@ var HttpTransport = (_class2 = class {
|
|
|
751
780
|
const error = await toHttpError(response, correlationId);
|
|
752
781
|
if (response.status === 400 && error instanceof _chunkJPDEKN5Mcjs.InvalidInputError) {
|
|
753
782
|
try {
|
|
754
|
-
_optionalChain([this, 'access',
|
|
783
|
+
_optionalChain([this, 'access', _16 => _16.onInvalidInput, 'optionalCall', _17 => _17(error, carriesScopePath(options.body))]);
|
|
755
784
|
} catch (e3) {
|
|
756
785
|
}
|
|
757
786
|
}
|
|
758
|
-
throw _nullishCoalesce(_optionalChain([options, 'access',
|
|
787
|
+
throw _nullishCoalesce(_optionalChain([options, 'access', _18 => _18.mapError, 'optionalCall', _19 => _19(response.status, error)]), () => ( error));
|
|
759
788
|
}
|
|
760
789
|
if (response.status === 204) return void 0;
|
|
761
790
|
const text = await response.text();
|
|
@@ -827,18 +856,18 @@ function isConnectionRefusal(error) {
|
|
|
827
856
|
}
|
|
828
857
|
function toTransportError(error, correlationId) {
|
|
829
858
|
if (error instanceof _chunkJPDEKN5Mcjs.SynapError) return error;
|
|
830
|
-
const name = _optionalChain([error, 'optionalAccess',
|
|
859
|
+
const name = _optionalChain([error, 'optionalAccess', _20 => _20.name]);
|
|
831
860
|
if (name === "AbortError" || name === "TimeoutError") {
|
|
832
861
|
return new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)("Request timed out", { correlationId, cause: error });
|
|
833
862
|
}
|
|
834
863
|
if (isConnectionRefusal(error)) {
|
|
835
864
|
return new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)(
|
|
836
|
-
`Connection failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
865
|
+
`Connection failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _21 => _21.message]), () => ( String(error)))}`,
|
|
837
866
|
{ correlationId, cause: error }
|
|
838
867
|
);
|
|
839
868
|
}
|
|
840
869
|
return new (0, _chunkJPDEKN5Mcjs.ServiceUnavailableError)(
|
|
841
|
-
`Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
870
|
+
`Network request failed: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _22 => _22.message]), () => ( String(error)))}`,
|
|
842
871
|
{ correlationId, cause: error }
|
|
843
872
|
);
|
|
844
873
|
}
|
|
@@ -923,8 +952,8 @@ async function toHttpError(response, correlationId) {
|
|
|
923
952
|
});
|
|
924
953
|
}
|
|
925
954
|
case 409:
|
|
926
|
-
if (parsed["error"] === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess',
|
|
927
|
-
const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess',
|
|
955
|
+
if (parsed["error"] === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _23 => _23["code"]]) === "instance_build_failed" || _optionalChain([detailObject, 'optionalAccess', _24 => _24["error"]]) === "instance_build_failed") {
|
|
956
|
+
const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _25 => _25[key]])));
|
|
928
957
|
const msg = pick4("message");
|
|
929
958
|
const attempts = Number(pick4("attempts"));
|
|
930
959
|
return new (0, _chunkJPDEKN5Mcjs.InstanceBuildFailedError)(
|
|
@@ -937,8 +966,8 @@ async function toHttpError(response, correlationId) {
|
|
|
937
966
|
}
|
|
938
967
|
);
|
|
939
968
|
}
|
|
940
|
-
if (parsed["error"] === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess',
|
|
941
|
-
const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess',
|
|
969
|
+
if (parsed["error"] === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _26 => _26["code"]]) === "instance_not_ready" || _optionalChain([detailObject, 'optionalAccess', _27 => _27["error"]]) === "instance_not_ready") {
|
|
970
|
+
const pick4 = (key) => _nullishCoalesce(parsed[key], () => ( _optionalChain([detailObject, 'optionalAccess', _28 => _28[key]])));
|
|
942
971
|
const rawWait = _nullishCoalesce(pick4("retry_after_seconds"), () => ( response.headers.get("retry-after")));
|
|
943
972
|
const wait = rawWait !== null && rawWait !== void 0 && String(rawWait).trim() !== "" ? Number(rawWait) : NaN;
|
|
944
973
|
const msg = pick4("message");
|
|
@@ -986,11 +1015,11 @@ function stringOrNull(v) {
|
|
|
986
1015
|
}
|
|
987
1016
|
function withTimeout(ms, external) {
|
|
988
1017
|
const controller = new AbortController();
|
|
989
|
-
const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess',
|
|
1018
|
+
const onExternalAbort = () => controller.abort(_optionalChain([external, 'optionalAccess', _29 => _29.reason]));
|
|
990
1019
|
const timer = setTimeout(() => {
|
|
991
1020
|
controller.abort(new (0, _chunkJPDEKN5Mcjs.NetworkTimeoutError)(`Timed out after ${ms}ms`));
|
|
992
1021
|
}, ms);
|
|
993
|
-
_optionalChain([timer, 'access',
|
|
1022
|
+
_optionalChain([timer, 'access', _30 => _30.unref, 'optionalCall', _31 => _31()]);
|
|
994
1023
|
if (external) {
|
|
995
1024
|
if (external.aborted) onExternalAbort();
|
|
996
1025
|
else external.addEventListener("abort", onExternalAbort, { once: true });
|
|
@@ -999,7 +1028,7 @@ function withTimeout(ms, external) {
|
|
|
999
1028
|
signal: controller.signal,
|
|
1000
1029
|
dispose() {
|
|
1001
1030
|
clearTimeout(timer);
|
|
1002
|
-
_optionalChain([external, 'optionalAccess',
|
|
1031
|
+
_optionalChain([external, 'optionalAccess', _32 => _32.removeEventListener, 'call', _33 => _33("abort", onExternalAbort)]);
|
|
1003
1032
|
}
|
|
1004
1033
|
};
|
|
1005
1034
|
}
|
|
@@ -1007,14 +1036,14 @@ function sleep(ms, signal) {
|
|
|
1007
1036
|
if (ms <= 0) return Promise.resolve();
|
|
1008
1037
|
return new Promise((resolve, reject) => {
|
|
1009
1038
|
const timer = setTimeout(() => {
|
|
1010
|
-
_optionalChain([signal, 'optionalAccess',
|
|
1039
|
+
_optionalChain([signal, 'optionalAccess', _34 => _34.removeEventListener, 'call', _35 => _35("abort", onAbort)]);
|
|
1011
1040
|
resolve();
|
|
1012
1041
|
}, ms);
|
|
1013
1042
|
function onAbort() {
|
|
1014
1043
|
clearTimeout(timer);
|
|
1015
|
-
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess',
|
|
1044
|
+
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _36 => _36.reason]), () => ( new Error("Aborted"))));
|
|
1016
1045
|
}
|
|
1017
|
-
_optionalChain([signal, 'optionalAccess',
|
|
1046
|
+
_optionalChain([signal, 'optionalAccess', _37 => _37.addEventListener, 'call', _38 => _38("abort", onAbort, { once: true })]);
|
|
1018
1047
|
});
|
|
1019
1048
|
}
|
|
1020
1049
|
|
|
@@ -1268,7 +1297,7 @@ function validateSearchQuery(searchQuery) {
|
|
|
1268
1297
|
}
|
|
1269
1298
|
async function fetchContext(transport, scope, options = {}, hooks = {}) {
|
|
1270
1299
|
const startedAt = Date.now();
|
|
1271
|
-
await _optionalChain([transport, 'access',
|
|
1300
|
+
await _optionalChain([transport, 'access', _39 => _39.ready, 'optionalCall', _40 => _40()]);
|
|
1272
1301
|
await transport.checkCustomerId(
|
|
1273
1302
|
opt(options, "customer_id", "customerId"),
|
|
1274
1303
|
`${scope}.context.fetch`
|
|
@@ -1284,20 +1313,20 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
|
|
|
1284
1313
|
if (answer !== null) return applyResponseShape(answer, responseShape);
|
|
1285
1314
|
}
|
|
1286
1315
|
const finish = (response2) => {
|
|
1287
|
-
_optionalChain([hooks, 'access',
|
|
1316
|
+
_optionalChain([hooks, 'access', _41 => _41.onResponse, 'optionalCall', _42 => _42(scope, options, response2)]);
|
|
1288
1317
|
return response2;
|
|
1289
1318
|
};
|
|
1290
1319
|
const conversationId = opt(options, "conversation_id", "conversationId");
|
|
1291
|
-
const skipServerSt = conversationId ? _optionalChain([hooks, 'access',
|
|
1320
|
+
const skipServerSt = conversationId ? _optionalChain([hooks, 'access', _43 => _43.skipServerShortTerm, 'optionalCall', _44 => _44(conversationId)]) === true : false;
|
|
1292
1321
|
const network = async () => {
|
|
1293
1322
|
const { endpoint, body } = buildFetchRequest(
|
|
1294
1323
|
scope,
|
|
1295
1324
|
skipServerSt ? { ...options, include_conversation_context: false } : options
|
|
1296
1325
|
);
|
|
1297
1326
|
const result = await transport.request(endpoint, { body });
|
|
1298
|
-
return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
1327
|
+
return applyResponseShape(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _45 => _45["context"]]), () => ( {})), responseShape);
|
|
1299
1328
|
};
|
|
1300
|
-
const anticipated = summaryMode ? null : await _asyncNullishCoalesce(await _optionalChain([hooks, 'access',
|
|
1329
|
+
const anticipated = summaryMode ? null : await _asyncNullishCoalesce(await _optionalChain([hooks, 'access', _46 => _46.beforeFetch, 'optionalCall', _47 => _47(scope, options)]), async () => ( null));
|
|
1301
1330
|
if (anticipated !== null && anticipated.borderline) {
|
|
1302
1331
|
const pending = network();
|
|
1303
1332
|
pending.catch(() => void 0);
|
|
@@ -1308,17 +1337,17 @@ async function fetchContext(transport, scope, options = {}, hooks = {}) {
|
|
|
1308
1337
|
const won = await Promise.race([pending.then((r) => r, () => null), late]);
|
|
1309
1338
|
if (timer !== void 0) clearTimeout(timer);
|
|
1310
1339
|
if (won !== null) {
|
|
1311
|
-
_optionalChain([hooks, 'access',
|
|
1340
|
+
_optionalChain([hooks, 'access', _48 => _48.onAssembled, 'optionalCall', _49 => _49(scope, options, won, startedAt)]);
|
|
1312
1341
|
return finish(won);
|
|
1313
1342
|
}
|
|
1314
1343
|
}
|
|
1315
1344
|
if (anticipated !== null) {
|
|
1316
|
-
_optionalChain([hooks, 'access',
|
|
1317
|
-
_optionalChain([hooks, 'access',
|
|
1345
|
+
_optionalChain([hooks, 'access', _50 => _50.onServedFromCache, 'optionalCall', _51 => _51(scope, options, anticipated)]);
|
|
1346
|
+
_optionalChain([hooks, 'access', _52 => _52.onAssembled, 'optionalCall', _53 => _53(scope, options, anticipated.response, startedAt)]);
|
|
1318
1347
|
return finish(applyResponseShape(anticipated.response, responseShape));
|
|
1319
1348
|
}
|
|
1320
1349
|
const response = await network();
|
|
1321
|
-
_optionalChain([hooks, 'access',
|
|
1350
|
+
_optionalChain([hooks, 'access', _54 => _54.onAssembled, 'optionalCall', _55 => _55(scope, options, response, startedAt)]);
|
|
1322
1351
|
return finish(response);
|
|
1323
1352
|
}
|
|
1324
1353
|
|
|
@@ -1620,7 +1649,7 @@ function defaultFilename(p, source) {
|
|
|
1620
1649
|
}
|
|
1621
1650
|
return lastSegment(pathname) || "file";
|
|
1622
1651
|
}
|
|
1623
|
-
const named = _optionalChain([p, 'access',
|
|
1652
|
+
const named = _optionalChain([p, 'access', _56 => _56.data, 'optionalAccess', _57 => _57.name]);
|
|
1624
1653
|
return typeof named === "string" && named ? named : "file";
|
|
1625
1654
|
}
|
|
1626
1655
|
var MEDIA_TYPES = {
|
|
@@ -1657,7 +1686,7 @@ function guessMediaType(filename) {
|
|
|
1657
1686
|
function defaultMediaType(filename, data) {
|
|
1658
1687
|
const guessed = guessMediaType(filename);
|
|
1659
1688
|
if (guessed !== null) return guessed;
|
|
1660
|
-
const blobType = _optionalChain([data, 'optionalAccess',
|
|
1689
|
+
const blobType = _optionalChain([data, 'optionalAccess', _58 => _58.type]);
|
|
1661
1690
|
return typeof blobType === "string" && blobType ? blobType : DEFAULT_MEDIA_TYPE;
|
|
1662
1691
|
}
|
|
1663
1692
|
function normaliseContent(value, field) {
|
|
@@ -1683,7 +1712,7 @@ function typeName(value) {
|
|
|
1683
1712
|
if (value === null) return "null";
|
|
1684
1713
|
if (Array.isArray(value)) return "array";
|
|
1685
1714
|
if (typeof value === "object") {
|
|
1686
|
-
return _nullishCoalesce(_optionalChain([value, 'access',
|
|
1715
|
+
return _nullishCoalesce(_optionalChain([value, 'access', _59 => _59.constructor, 'optionalAccess', _60 => _60.name]), () => ( "object"));
|
|
1687
1716
|
}
|
|
1688
1717
|
return typeof value;
|
|
1689
1718
|
}
|
|
@@ -1700,7 +1729,7 @@ async function resolveFile(part, fetchImpl) {
|
|
|
1700
1729
|
bytes = new Uint8Array(await readFile(part.path));
|
|
1701
1730
|
} catch (error) {
|
|
1702
1731
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
|
|
1703
|
-
`Could not read FilePart path '${part.path}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
1732
|
+
`Could not read FilePart path '${part.path}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _61 => _61.message]), () => ( String(error)))}`,
|
|
1704
1733
|
{ cause: error }
|
|
1705
1734
|
);
|
|
1706
1735
|
}
|
|
@@ -1770,7 +1799,7 @@ async function fetchUrl(url, fetchImpl) {
|
|
|
1770
1799
|
);
|
|
1771
1800
|
}
|
|
1772
1801
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
|
|
1773
|
-
`Could not fetch FilePart url '${url}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
1802
|
+
`Could not fetch FilePart url '${url}': ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _62 => _62.message]), () => ( String(error)))}`,
|
|
1774
1803
|
{ cause: error }
|
|
1775
1804
|
);
|
|
1776
1805
|
} finally {
|
|
@@ -2114,7 +2143,7 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
2114
2143
|
await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
|
|
2115
2144
|
const body = buildForgetBody(options);
|
|
2116
2145
|
const result = await transport.request("memories_forget", { body });
|
|
2117
|
-
const removed = !!_optionalChain([result, 'optionalAccess',
|
|
2146
|
+
const removed = !!_optionalChain([result, 'optionalAccess', _63 => _63.deleted_ids, 'optionalAccess', _64 => _64.length]) || _optionalChain([result, 'optionalAccess', _65 => _65.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _66 => _66.status]) === "partial";
|
|
2118
2147
|
if (removed && onForgotten) {
|
|
2119
2148
|
try {
|
|
2120
2149
|
onForgotten({
|
|
@@ -2154,14 +2183,14 @@ function sleep2(ms, signal) {
|
|
|
2154
2183
|
if (ms <= 0) return Promise.resolve();
|
|
2155
2184
|
return new Promise((resolve, reject) => {
|
|
2156
2185
|
const timer = setTimeout(() => {
|
|
2157
|
-
_optionalChain([signal, 'optionalAccess',
|
|
2186
|
+
_optionalChain([signal, 'optionalAccess', _67 => _67.removeEventListener, 'call', _68 => _68("abort", onAbort)]);
|
|
2158
2187
|
resolve();
|
|
2159
2188
|
}, ms);
|
|
2160
2189
|
function onAbort() {
|
|
2161
2190
|
clearTimeout(timer);
|
|
2162
|
-
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess',
|
|
2191
|
+
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _69 => _69.reason]), () => ( new Error("Aborted"))));
|
|
2163
2192
|
}
|
|
2164
|
-
_optionalChain([signal, 'optionalAccess',
|
|
2193
|
+
_optionalChain([signal, 'optionalAccess', _70 => _70.addEventListener, 'call', _71 => _71("abort", onAbort, { once: true })]);
|
|
2165
2194
|
});
|
|
2166
2195
|
}
|
|
2167
2196
|
|
|
@@ -2242,7 +2271,7 @@ function buildRecordMessageBody(options, resolvedContent, field = "content") {
|
|
|
2242
2271
|
content = resolvedContent;
|
|
2243
2272
|
} else {
|
|
2244
2273
|
const n2 = normaliseContent(options.content, field);
|
|
2245
|
-
if (_optionalChain([n2, 'optionalAccess',
|
|
2274
|
+
if (_optionalChain([n2, 'optionalAccess', _72 => _72.kind]) === "parts") {
|
|
2246
2275
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
|
|
2247
2276
|
"content holds a FilePart, whose bytes have to be read first. Send it with conversation.record_message."
|
|
2248
2277
|
);
|
|
@@ -2311,6 +2340,7 @@ function buildCompactBody(options) {
|
|
|
2311
2340
|
var CompactionSubscribers = class {
|
|
2312
2341
|
#byConversation = /* @__PURE__ */ new Map();
|
|
2313
2342
|
add(conversationId, callback) {
|
|
2343
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2314
2344
|
const list = this.#byConversation.get(conversationId);
|
|
2315
2345
|
if (list === void 0) this.#byConversation.set(conversationId, [callback]);
|
|
2316
2346
|
else list.push(callback);
|
|
@@ -2326,6 +2356,7 @@ var CompactionSubscribers = class {
|
|
|
2326
2356
|
};
|
|
2327
2357
|
}
|
|
2328
2358
|
removeAll(conversationId) {
|
|
2359
|
+
if (conversationId !== void 0) conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2329
2360
|
if (conversationId === void 0) {
|
|
2330
2361
|
let count = 0;
|
|
2331
2362
|
for (const list2 of this.#byConversation.values()) count += list2.length;
|
|
@@ -2339,6 +2370,7 @@ var CompactionSubscribers = class {
|
|
|
2339
2370
|
}
|
|
2340
2371
|
/** Fires subscribers in registration order. A throwing listener must not break the stream reader. */
|
|
2341
2372
|
dispatch(conversationId, bundle, onError) {
|
|
2373
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
2342
2374
|
for (const callback of [..._nullishCoalesce(this.#byConversation.get(conversationId), () => ( []))]) {
|
|
2343
2375
|
try {
|
|
2344
2376
|
const result = callback(bundle);
|
|
@@ -2353,7 +2385,7 @@ function storedBatchRows(bodies, result) {
|
|
|
2353
2385
|
const r = _nullishCoalesce(result, () => ( {}));
|
|
2354
2386
|
const results = Array.isArray(r["results"]) ? r["results"] : [];
|
|
2355
2387
|
const errors = Array.isArray(r["errors"]) ? r["errors"] : [];
|
|
2356
|
-
const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess',
|
|
2388
|
+
const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _73 => _73["index"]])));
|
|
2357
2389
|
const stored = bodies.filter((_, index) => !failed.has(index));
|
|
2358
2390
|
if (stored.length !== results.length) return [];
|
|
2359
2391
|
const pairs = [];
|
|
@@ -2397,7 +2429,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2397
2429
|
};
|
|
2398
2430
|
const fetchImpl = ((url, init) => transport.fetchExternal(url, init));
|
|
2399
2431
|
const validateMessage = (options, field = "content") => {
|
|
2400
|
-
if (_optionalChain([normaliseContent, 'call',
|
|
2432
|
+
if (_optionalChain([normaliseContent, 'call', _74 => _74(options.content, field), 'optionalAccess', _75 => _75.kind]) === "parts") {
|
|
2401
2433
|
buildRecordMessageBody(options, "", field);
|
|
2402
2434
|
} else {
|
|
2403
2435
|
buildRecordMessageBody(options, void 0, field);
|
|
@@ -2405,7 +2437,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2405
2437
|
};
|
|
2406
2438
|
const prepareMessage = async (options, field = "content") => {
|
|
2407
2439
|
const n2 = normaliseContent(options.content, field);
|
|
2408
|
-
if (_optionalChain([n2, 'optionalAccess',
|
|
2440
|
+
if (_optionalChain([n2, 'optionalAccess', _76 => _76.kind]) !== "parts") {
|
|
2409
2441
|
const body = buildRecordMessageBody(options, void 0, field);
|
|
2410
2442
|
return { body, mirror: String(_nullishCoalesce(body["content"], () => ( ""))) };
|
|
2411
2443
|
}
|
|
@@ -2496,7 +2528,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2496
2528
|
const raw = await transport.request("conversations_ingest", { body });
|
|
2497
2529
|
const result = {
|
|
2498
2530
|
...raw,
|
|
2499
|
-
warnings: Array.isArray(_optionalChain([raw, 'optionalAccess',
|
|
2531
|
+
warnings: Array.isArray(_optionalChain([raw, 'optionalAccess', _77 => _77.warnings])) ? raw.warnings.map(String) : []
|
|
2500
2532
|
};
|
|
2501
2533
|
onWrite({
|
|
2502
2534
|
userId: body["user_id"],
|
|
@@ -2540,8 +2572,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2540
2572
|
pathParams: { conversation_id: id },
|
|
2541
2573
|
query: { style }
|
|
2542
2574
|
});
|
|
2543
|
-
const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
2544
|
-
_optionalChain([localShortTerm, 'access',
|
|
2575
|
+
const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _78 => _78["context_for_prompt"]]), () => ( result)), () => ( {}));
|
|
2576
|
+
_optionalChain([localShortTerm, 'access', _79 => _79.reseed, 'optionalCall', _80 => _80(id, response)]);
|
|
2545
2577
|
return withHistory(response);
|
|
2546
2578
|
},
|
|
2547
2579
|
async compact(options) {
|
|
@@ -2938,8 +2970,8 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2938
2970
|
let onConversationState = null;
|
|
2939
2971
|
const internals = {
|
|
2940
2972
|
onCompactionUpdate(conversationId, bundle) {
|
|
2941
|
-
_optionalChain([applyCompaction, 'optionalCall',
|
|
2942
|
-
_optionalChain([dispatchCompaction, 'optionalCall',
|
|
2973
|
+
_optionalChain([applyCompaction, 'optionalCall', _81 => _81(bundle)]);
|
|
2974
|
+
_optionalChain([dispatchCompaction, 'optionalCall', _82 => _82(conversationId, bundle)]);
|
|
2943
2975
|
},
|
|
2944
2976
|
setCompactionApplier(apply) {
|
|
2945
2977
|
applyCompaction = apply;
|
|
@@ -2954,10 +2986,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2954
2986
|
onConversationState = handle;
|
|
2955
2987
|
},
|
|
2956
2988
|
sendContextUsed(event) {
|
|
2957
|
-
_optionalChain([client, 'optionalAccess',
|
|
2989
|
+
_optionalChain([client, 'optionalAccess', _83 => _83.sendContextUsed, 'call', _84 => _84(event)]);
|
|
2958
2990
|
},
|
|
2959
2991
|
sendContextAssembled(event) {
|
|
2960
|
-
_optionalChain([client, 'optionalAccess',
|
|
2992
|
+
_optionalChain([client, 'optionalAccess', _85 => _85.sendContextAssembled, 'call', _86 => _86(event)]);
|
|
2961
2993
|
},
|
|
2962
2994
|
setCompactionDispatcher(dispatch) {
|
|
2963
2995
|
dispatchCompaction = dispatch;
|
|
@@ -2966,9 +2998,18 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2966
2998
|
return client !== null && client.isConnected;
|
|
2967
2999
|
}
|
|
2968
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
|
+
}
|
|
2969
3010
|
function ensureSession(conversationId, userId, customerId) {
|
|
2970
3011
|
if (!conversationId || !userId || client === null) return;
|
|
2971
|
-
if (
|
|
3012
|
+
if (openSessionKey(conversationId) !== void 0) return;
|
|
2972
3013
|
const sessionId = _chunkJPDEKN5Mcjs.newCorrelationId.call(void 0, );
|
|
2973
3014
|
try {
|
|
2974
3015
|
client.sendSessionControl({
|
|
@@ -2989,7 +3030,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2989
3030
|
send(sync);
|
|
2990
3031
|
return Promise.resolve();
|
|
2991
3032
|
}
|
|
2992
|
-
_optionalChain([prepared, 'optionalAccess',
|
|
3033
|
+
_optionalChain([prepared, 'optionalAccess', _87 => _87.catch, 'call', _88 => _88(() => {
|
|
2993
3034
|
})]);
|
|
2994
3035
|
queued += 1;
|
|
2995
3036
|
const run = tail.then(async () => {
|
|
@@ -3008,7 +3049,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3008
3049
|
throw new (0, _chunkJPDEKN5Mcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
|
|
3009
3050
|
}
|
|
3010
3051
|
try {
|
|
3011
|
-
_optionalChain([onListen, 'optionalCall',
|
|
3052
|
+
_optionalChain([onListen, 'optionalCall', _89 => _89()]);
|
|
3012
3053
|
} catch (e17) {
|
|
3013
3054
|
}
|
|
3014
3055
|
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-H2ES74FF.cjs")));
|
|
@@ -3026,17 +3067,17 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3026
3067
|
internals.onCompactionUpdate(conversationId, bundle);
|
|
3027
3068
|
},
|
|
3028
3069
|
onConversationState: (conversationId, messageCount) => {
|
|
3029
|
-
_optionalChain([onConversationState, 'optionalCall',
|
|
3070
|
+
_optionalChain([onConversationState, 'optionalCall', _90 => _90(conversationId, messageCount)]);
|
|
3030
3071
|
},
|
|
3031
3072
|
onStateChange: (state) => {
|
|
3032
3073
|
if (state !== "connected") openSessions.clear();
|
|
3033
3074
|
if (state === "reconnecting") {
|
|
3034
3075
|
reconnectAttempts += 1;
|
|
3035
|
-
_optionalChain([onReconnect, 'optionalCall',
|
|
3076
|
+
_optionalChain([onReconnect, 'optionalCall', _91 => _91(reconnectAttempts)]);
|
|
3036
3077
|
} else if (state === "disconnected") {
|
|
3037
|
-
const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess',
|
|
3078
|
+
const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _92 => _92.lastError]), () => ( null));
|
|
3038
3079
|
const reason = stopped === null ? "stream disconnected" : `credit_stop:${_nullishCoalesce(stopped.reason, () => ( "unknown"))}`;
|
|
3039
|
-
_optionalChain([onDisconnect, 'optionalCall',
|
|
3080
|
+
_optionalChain([onDisconnect, 'optionalCall', _93 => _93(reason)]);
|
|
3040
3081
|
}
|
|
3041
3082
|
}
|
|
3042
3083
|
});
|
|
@@ -3046,7 +3087,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3046
3087
|
} catch (error) {
|
|
3047
3088
|
if (error instanceof _chunkJPDEKN5Mcjs.SynapError) throw error;
|
|
3048
3089
|
throw new (0, _chunkJPDEKN5Mcjs.SynapError)(
|
|
3049
|
-
`Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
3090
|
+
`Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _94 => _94.message]), () => ( String(error)))}`,
|
|
3050
3091
|
{ cause: error }
|
|
3051
3092
|
);
|
|
3052
3093
|
}
|
|
@@ -3062,9 +3103,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3062
3103
|
await active.disconnect();
|
|
3063
3104
|
},
|
|
3064
3105
|
async end_session(conversationId) {
|
|
3065
|
-
const
|
|
3066
|
-
|
|
3067
|
-
|
|
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);
|
|
3068
3110
|
try {
|
|
3069
3111
|
client.sendSessionControl({
|
|
3070
3112
|
action: "end",
|
|
@@ -3101,7 +3143,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3101
3143
|
_nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( ""))
|
|
3102
3144
|
);
|
|
3103
3145
|
if (eventType === "user_message" || eventType === "assistant_message") {
|
|
3104
|
-
_optionalChain([onTurn, 'optionalCall',
|
|
3146
|
+
_optionalChain([onTurn, 'optionalCall', _95 => _95({
|
|
3105
3147
|
conversationId,
|
|
3106
3148
|
role: _nullishCoalesce(options.role, () => ( "user")),
|
|
3107
3149
|
content
|
|
@@ -3114,7 +3156,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3114
3156
|
conversation_id: _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( "")),
|
|
3115
3157
|
user_id: _nullishCoalesce(_nullishCoalesce(options.user_id, () => ( options.userId)), () => ( "")),
|
|
3116
3158
|
customer_id: _nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( "")),
|
|
3117
|
-
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), () => ( ""))))), () => ( "")),
|
|
3118
3160
|
metadata: _nullishCoalesce(withAgentModel(metadata, agentModelOf(options), agentModel(), true), () => ( {})),
|
|
3119
3161
|
timestamp_ms: Date.now(),
|
|
3120
3162
|
tool_name: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")),
|
|
@@ -3133,8 +3175,8 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3133
3175
|
})()
|
|
3134
3176
|
});
|
|
3135
3177
|
};
|
|
3136
|
-
if (_optionalChain([parts, 'optionalAccess',
|
|
3137
|
-
const content = _optionalChain([parts, 'optionalAccess',
|
|
3178
|
+
if (_optionalChain([parts, 'optionalAccess', _96 => _96.kind]) !== "parts") {
|
|
3179
|
+
const content = _optionalChain([parts, 'optionalAccess', _97 => _97.kind]) === "text" ? parts.text : options.content;
|
|
3138
3180
|
return inOrder(null, emit, { content, metadata: _nullishCoalesce(options.metadata, () => ( {})) });
|
|
3139
3181
|
}
|
|
3140
3182
|
const prepared = (async () => {
|
|
@@ -3172,7 +3214,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3172
3214
|
async record_tool_result(options) {
|
|
3173
3215
|
const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
|
|
3174
3216
|
if (conversationId) {
|
|
3175
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
3217
|
+
_optionalChain([onToolResult, 'optionalCall', _98 => _98({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
|
|
3176
3218
|
}
|
|
3177
3219
|
await namespace.send_message({
|
|
3178
3220
|
content: "",
|
|
@@ -3227,7 +3269,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3227
3269
|
}
|
|
3228
3270
|
|
|
3229
3271
|
// src/version.ts
|
|
3230
|
-
var SDK_VERSION = "0.7.
|
|
3272
|
+
var SDK_VERSION = "0.7.2";
|
|
3231
3273
|
|
|
3232
3274
|
// src/registry.ts
|
|
3233
3275
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -3335,6 +3377,7 @@ var ShortTermStore = class {
|
|
|
3335
3377
|
/** The entry, or null. Age-evicts on read, as Python does. */
|
|
3336
3378
|
get(conversationId) {
|
|
3337
3379
|
if (!conversationId) return null;
|
|
3380
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3338
3381
|
const entry = this.#entries.get(conversationId);
|
|
3339
3382
|
if (entry === void 0) return null;
|
|
3340
3383
|
if (this.#now() - entry.lastActivityAt > this.#maxAgeMs) {
|
|
@@ -3363,6 +3406,7 @@ var ShortTermStore = class {
|
|
|
3363
3406
|
*/
|
|
3364
3407
|
appendTurn(conversationId, role, content, timestamp, confirmation = {}) {
|
|
3365
3408
|
if (!conversationId) return;
|
|
3409
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3366
3410
|
const stamp = _nullishCoalesce(timestamp, () => ( new Date(this.#now()).toISOString()));
|
|
3367
3411
|
if (this.#archive !== null) {
|
|
3368
3412
|
try {
|
|
@@ -3396,6 +3440,7 @@ var ShortTermStore = class {
|
|
|
3396
3440
|
*/
|
|
3397
3441
|
noteServerCount(conversationId, count) {
|
|
3398
3442
|
if (!conversationId) return;
|
|
3443
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3399
3444
|
const entry = this.#entries.get(conversationId);
|
|
3400
3445
|
if (entry !== void 0) this.#noteCount(entry, Number(count), 0);
|
|
3401
3446
|
}
|
|
@@ -3443,10 +3488,11 @@ var ShortTermStore = class {
|
|
|
3443
3488
|
applyCompaction(bundle) {
|
|
3444
3489
|
if (typeof bundle !== "object" || bundle === null) return;
|
|
3445
3490
|
const cc = _nullishCoalesce(bundle["conversation_context"], () => ( {}));
|
|
3446
|
-
const
|
|
3491
|
+
const rawConversationId = String(
|
|
3447
3492
|
_nullishCoalesce(_nullishCoalesce(_nullishCoalesce(cc["conversation_id"], () => ( bundle["anticipation_conversation_id"])), () => ( bundle["conversation_id"])), () => ( ""))
|
|
3448
3493
|
);
|
|
3449
|
-
if (!
|
|
3494
|
+
if (!rawConversationId) return;
|
|
3495
|
+
const conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, rawConversationId);
|
|
3450
3496
|
const endTs = parseIso(_nullishCoalesce(cc["end_timestamp"], () => ( cc["compacted_at"])));
|
|
3451
3497
|
const compactedAt = parseIso(cc["compacted_at"]);
|
|
3452
3498
|
const compactedCount = Number(_nullishCoalesce(cc["compacted_message_count"], () => ( 0))) || 0;
|
|
@@ -3511,6 +3557,7 @@ var ShortTermStore = class {
|
|
|
3511
3557
|
*/
|
|
3512
3558
|
reseed(conversationId, state) {
|
|
3513
3559
|
if (!conversationId) return;
|
|
3560
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
3514
3561
|
const entry = this.#entries.get(conversationId);
|
|
3515
3562
|
if (entry === void 0 || entry.shared) return;
|
|
3516
3563
|
entry.serverMessageCount = Math.max(
|
|
@@ -3527,7 +3574,7 @@ var ShortTermStore = class {
|
|
|
3527
3574
|
entry.synced = true;
|
|
3528
3575
|
}
|
|
3529
3576
|
invalidate(conversationId) {
|
|
3530
|
-
this.#entries.delete(conversationId);
|
|
3577
|
+
this.#entries.delete(_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId));
|
|
3531
3578
|
}
|
|
3532
3579
|
clear() {
|
|
3533
3580
|
this.#entries.clear();
|
|
@@ -3581,7 +3628,7 @@ var TurnStore = (_class3 = class {
|
|
|
3581
3628
|
#conversations = /* @__PURE__ */ new Map();
|
|
3582
3629
|
#vectors = /* @__PURE__ */ new Map();
|
|
3583
3630
|
constructor(options = {}) {;_class3.prototype.__init7.call(this);
|
|
3584
|
-
this.limits = _nullishCoalesce(options.limits, () => ( { ...
|
|
3631
|
+
this.limits = _nullishCoalesce(options.limits, () => ( { ..._chunk6GHXJD7Lcjs.HISTORY_SEARCH.store_limits }));
|
|
3585
3632
|
this.#now = _nullishCoalesce(options.now, () => ( (() => Date.now() / 1e3)));
|
|
3586
3633
|
}
|
|
3587
3634
|
add(conversationId, role, content, timestamp, options = {}) {
|
|
@@ -3695,7 +3742,7 @@ var TurnStore = (_class3 = class {
|
|
|
3695
3742
|
}
|
|
3696
3743
|
/** Turns the server also holds: archived tool results are local only. Python: `count`. */
|
|
3697
3744
|
count(conversationId) {
|
|
3698
|
-
return (_nullishCoalesce(_optionalChain([this, 'access',
|
|
3745
|
+
return (_nullishCoalesce(_optionalChain([this, 'access', _99 => _99.#conversations, 'access', _100 => _100.get, 'call', _101 => _101(conversationId), 'optionalAccess', _102 => _102.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
|
|
3699
3746
|
}
|
|
3700
3747
|
sizeBytes() {
|
|
3701
3748
|
let n2 = 0;
|
|
@@ -3725,11 +3772,11 @@ var TurnStore = (_class3 = class {
|
|
|
3725
3772
|
|
|
3726
3773
|
// src/cache/history-search.ts
|
|
3727
3774
|
var WORD_RE = /[\p{L}\p{N}\p{M}]+/gu;
|
|
3728
|
-
var FORMS = _nullishCoalesce(
|
|
3775
|
+
var FORMS = _nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.irregular_forms, () => ( {}));
|
|
3729
3776
|
function tokenize2(text) {
|
|
3730
3777
|
const out = [];
|
|
3731
3778
|
for (const word of _nullishCoalesce((text || "").toLowerCase().match(WORD_RE), () => ( []))) {
|
|
3732
|
-
if (/^[\x00-\x7f]+$/.test(word)) out.push(...
|
|
3779
|
+
if (/^[\x00-\x7f]+$/.test(word)) out.push(..._chunk6GHXJD7Lcjs.tokenize.call(void 0, _nullishCoalesce(FORMS[word], () => ( word))));
|
|
3733
3780
|
else out.push(word);
|
|
3734
3781
|
}
|
|
3735
3782
|
return out;
|
|
@@ -3866,19 +3913,19 @@ function windowsOf(pieces, maxWords) {
|
|
|
3866
3913
|
}
|
|
3867
3914
|
function askedKinds(query) {
|
|
3868
3915
|
const out = [];
|
|
3869
|
-
for (const [name, spec] of Object.entries(_nullishCoalesce(
|
|
3916
|
+
for (const [name, spec] of Object.entries(_nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.asked_kinds, () => ( {})))) {
|
|
3870
3917
|
if (name.startsWith("$") || typeof spec !== "object") continue;
|
|
3871
3918
|
if (new RegExp(spec.query, "i").test(_nullishCoalesce(query, () => ( "")))) out.push(new RegExp(spec.value));
|
|
3872
3919
|
}
|
|
3873
3920
|
return out;
|
|
3874
3921
|
}
|
|
3875
3922
|
function asksHowItStarted(query) {
|
|
3876
|
-
const spec =
|
|
3877
|
-
if (!_optionalChain([spec, 'optionalAccess',
|
|
3923
|
+
const spec = _chunk6GHXJD7Lcjs.HISTORY_SEARCH.early_query;
|
|
3924
|
+
if (!_optionalChain([spec, 'optionalAccess', _103 => _103.pattern])) return false;
|
|
3878
3925
|
return new RegExp(spec.pattern, (_nullishCoalesce(spec.flags, () => ( ""))).includes("i") ? "i" : "").test(_nullishCoalesce(query, () => ( "")));
|
|
3879
3926
|
}
|
|
3880
3927
|
async function searchTurns(turns, query, options = {}) {
|
|
3881
|
-
const params =
|
|
3928
|
+
const params = _chunk6GHXJD7Lcjs.HISTORY_SEARCH;
|
|
3882
3929
|
const k = params.max_excerpts;
|
|
3883
3930
|
const skip = new Set(_nullishCoalesce(options.exclude, () => ( [])));
|
|
3884
3931
|
const pool = turns.filter((t) => t.content && !skip.has(t.content) && !skip.has(_nullishCoalesce(t.message_id, () => ( ""))));
|
|
@@ -3905,7 +3952,7 @@ async function searchTurns(turns, query, options = {}) {
|
|
|
3905
3952
|
});
|
|
3906
3953
|
});
|
|
3907
3954
|
const docs = units.map((u) => tokenize2(u.content));
|
|
3908
|
-
const bm = new (0,
|
|
3955
|
+
const bm = new (0, _chunk6GHXJD7Lcjs.BM25)(docs);
|
|
3909
3956
|
const termList = [...terms];
|
|
3910
3957
|
const rows = units.map((turn, i) => {
|
|
3911
3958
|
const held = new Set(docs[i]);
|
|
@@ -4043,13 +4090,13 @@ async function embeddingRanks(pool, query, encoder, store, minCosine) {
|
|
|
4043
4090
|
}
|
|
4044
4091
|
function toolResultText(result, toolName) {
|
|
4045
4092
|
let text = typeof result === "string" ? result : _nullishCoalesce(JSON.stringify(result), () => ( String(result)));
|
|
4046
|
-
const limit = _nullishCoalesce(
|
|
4093
|
+
const limit = _nullishCoalesce(_chunk6GHXJD7Lcjs.HISTORY_SEARCH.tool_result_max_chars, () => ( 16e3));
|
|
4047
4094
|
if (text.length > limit) text = text.slice(0, limit) + " ...[cut]";
|
|
4048
4095
|
return `[tool result: ${toolName || "tool"}] ${text}`;
|
|
4049
4096
|
}
|
|
4050
4097
|
function renderExcerpts(excerpts, latest = "") {
|
|
4051
4098
|
if (excerpts.length === 0) return "";
|
|
4052
|
-
const lines = [
|
|
4099
|
+
const lines = [_chunk6GHXJD7Lcjs.HISTORY_SEARCH.heading];
|
|
4053
4100
|
for (const e of excerpts) {
|
|
4054
4101
|
let where = e.position ? `turn ${e.position}, ${e.role}` : `${e.role}, earlier`;
|
|
4055
4102
|
if (e.timestamp) {
|
|
@@ -4328,7 +4375,7 @@ var TurnCounter = class {
|
|
|
4328
4375
|
#counts = /* @__PURE__ */ new Map();
|
|
4329
4376
|
/** Increment and return the new count. Python buckets a missing id under `_global`. */
|
|
4330
4377
|
increment(conversationId) {
|
|
4331
|
-
const key = conversationId !== void 0 && conversationId !== "" ? conversationId : "_global";
|
|
4378
|
+
const key = conversationId !== void 0 && conversationId !== "" ? _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId) : "_global";
|
|
4332
4379
|
const next = (_nullishCoalesce(this.#counts.get(key), () => ( 0))) + 1;
|
|
4333
4380
|
this.#counts.set(key, next);
|
|
4334
4381
|
return next;
|
|
@@ -4341,7 +4388,7 @@ var TurnCounter = class {
|
|
|
4341
4388
|
* triggered a fresh retrieval anyway.
|
|
4342
4389
|
*/
|
|
4343
4390
|
shouldInject(conversationId) {
|
|
4344
|
-
const key = conversationId !== void 0 && conversationId !== "" ? conversationId : "_global";
|
|
4391
|
+
const key = conversationId !== void 0 && conversationId !== "" ? _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId) : "_global";
|
|
4345
4392
|
const count = _nullishCoalesce(this.#counts.get(key), () => ( 0));
|
|
4346
4393
|
return count > 0 && count % USER_SUMMARY_INTERVAL === 0;
|
|
4347
4394
|
}
|
|
@@ -5031,7 +5078,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5031
5078
|
this.#transport.onInvalidInput = (_error, carriedScopePath) => {
|
|
5032
5079
|
if (carriedScopePath) this.#transport.invalidateScopeLadder();
|
|
5033
5080
|
};
|
|
5034
|
-
this.#anticipationCache = new (0,
|
|
5081
|
+
this.#anticipationCache = new (0, _chunk6GHXJD7Lcjs.AnticipationCache)();
|
|
5035
5082
|
this.#fetchHooks = {
|
|
5036
5083
|
beforeFetch: async (scope, options2) => {
|
|
5037
5084
|
const o2 = options2;
|
|
@@ -5050,7 +5097,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5050
5097
|
// on entity and conversation alone, so a bundle prefetched for one
|
|
5051
5098
|
// rung answered a caller standing at another, entirely inside this
|
|
5052
5099
|
// process and invisible to every server log.
|
|
5053
|
-
scopeRung:
|
|
5100
|
+
scopeRung: _chunk6GHXJD7Lcjs.rungKey.call(void 0,
|
|
5054
5101
|
_nullishCoalesce(o2["scope_path"], () => ( o2["scopePath"]))
|
|
5055
5102
|
),
|
|
5056
5103
|
maxResultsPerQuery: _nullishCoalesce(_nullishCoalesce(o2["max_results_per_query"], () => ( o2["maxResultsPerQuery"])), () => ( null))
|
|
@@ -5063,7 +5110,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5063
5110
|
servedItemIds: servedItemIds(attempt.hit),
|
|
5064
5111
|
bundleId: _nullishCoalesce(attempt.hit.bundleIds[0], () => ( "")),
|
|
5065
5112
|
borderline: attempt.hit.band === "borderline",
|
|
5066
|
-
raceDeadlineMs:
|
|
5113
|
+
raceDeadlineMs: _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.race_deadline_ms
|
|
5067
5114
|
};
|
|
5068
5115
|
},
|
|
5069
5116
|
onAssembled: (scope, options2, response, startedAt) => {
|
|
@@ -5116,7 +5163,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5116
5163
|
response,
|
|
5117
5164
|
_nullishCoalesce(o2["conversation_id"], () => ( o2["conversationId"])),
|
|
5118
5165
|
owner,
|
|
5119
|
-
|
|
5166
|
+
_chunk6GHXJD7Lcjs.rungKey.call(void 0, _nullishCoalesce(o2["scope_path"], () => ( o2["scopePath"])))
|
|
5120
5167
|
);
|
|
5121
5168
|
}
|
|
5122
5169
|
};
|
|
@@ -5137,7 +5184,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5137
5184
|
this.#localEncoder = _nullishCoalesce(_nullishCoalesce(options.history_search_encoder, () => ( options.historySearchEncoder)), () => ( null));
|
|
5138
5185
|
const modelOption = options.history_search_model !== void 0 ? options.history_search_model : options.historySearchModel;
|
|
5139
5186
|
this.#localModelName = modelOption === void 0 ? "auto" : modelOption;
|
|
5140
|
-
if (_optionalChain([this, 'access',
|
|
5187
|
+
if (_optionalChain([this, 'access', _104 => _104.#localEncoder, 'optionalAccess', _105 => _105.model]) === _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
|
|
5141
5188
|
this.#turns = new TurnCounter();
|
|
5142
5189
|
this.conversation = createConversationNamespace(
|
|
5143
5190
|
this.#transport,
|
|
@@ -5163,7 +5210,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5163
5210
|
},
|
|
5164
5211
|
(response, conversationId, userId, scopePath) => {
|
|
5165
5212
|
overlayLocalRecentTurns(response, this.#shortTerm, conversationId, this.#stVerbatimOverlay);
|
|
5166
|
-
this.#injectUserSummary(response, conversationId, userId,
|
|
5213
|
+
this.#injectUserSummary(response, conversationId, userId, _chunk6GHXJD7Lcjs.rungKey.call(void 0, scopePath));
|
|
5167
5214
|
},
|
|
5168
5215
|
{
|
|
5169
5216
|
prompt: (conversationId, style) => this.#localPrompt(conversationId, style),
|
|
@@ -5188,7 +5235,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5188
5235
|
if (scope === "conversation") {
|
|
5189
5236
|
if (conversationId) {
|
|
5190
5237
|
this.#shortTerm.invalidate(conversationId);
|
|
5191
|
-
this.#turnStore.drop(conversationId);
|
|
5238
|
+
this.#turnStore.drop(_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId));
|
|
5192
5239
|
cleared.push("short_term_context", "turns");
|
|
5193
5240
|
}
|
|
5194
5241
|
} else {
|
|
@@ -5379,7 +5426,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5379
5426
|
} catch (error) {
|
|
5380
5427
|
if (this.#localMode) {
|
|
5381
5428
|
throw new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(
|
|
5382
|
-
`Could not reach the Synap server at ${this.#transport.baseUrl}, or it did not identify itself: GET /api/v1/auth/whoami failed (${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
5429
|
+
`Could not reach the Synap server at ${this.#transport.baseUrl}, or it did not identify itself: GET /api/v1/auth/whoami failed (${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _106 => _106.message]), () => ( String(error)))}).`,
|
|
5383
5430
|
{ cause: error }
|
|
5384
5431
|
);
|
|
5385
5432
|
}
|
|
@@ -5499,6 +5546,19 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5499
5546
|
// one hands every scope fetch exactly the options it always got.
|
|
5500
5547
|
...scopePath !== void 0 && scopePath !== null && Object.keys(scopePath).length > 0 ? { scope_path: scopePath } : {}
|
|
5501
5548
|
};
|
|
5549
|
+
const { scope_path: _fullPath, ...sharedNoPath } = shared;
|
|
5550
|
+
void _fullPath;
|
|
5551
|
+
let customerPath;
|
|
5552
|
+
if (scopePath && Object.keys(scopePath).length > 0 && customerId !== void 0 && customerId !== null && customerId !== "" && wants("customer")) {
|
|
5553
|
+
let ladder = null;
|
|
5554
|
+
try {
|
|
5555
|
+
ladder = await this.get_scope_ladder();
|
|
5556
|
+
} catch (e) {
|
|
5557
|
+
this.#warn(`Could not read the scope ladder (${e instanceof Error ? e.message : String(e)}); cutting the customer scope's path at the reserved key 'user'.`);
|
|
5558
|
+
}
|
|
5559
|
+
customerPath = pathAboveIdentity(scopePath, ladder);
|
|
5560
|
+
}
|
|
5561
|
+
const customerShared = customerPath ? { ...sharedNoPath, scope_path: customerPath } : sharedNoPath;
|
|
5502
5562
|
const labels = [];
|
|
5503
5563
|
const tasks = [];
|
|
5504
5564
|
const present = (v) => v !== void 0 && v !== null && v !== "";
|
|
@@ -5530,14 +5590,14 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5530
5590
|
tasks.push(this.customer.context.fetch({
|
|
5531
5591
|
customer_id: customerId,
|
|
5532
5592
|
conversation_id: conversationId,
|
|
5533
|
-
...
|
|
5593
|
+
...customerShared
|
|
5534
5594
|
}));
|
|
5535
5595
|
}
|
|
5536
5596
|
if (scopes !== void 0 && scopes.includes("client")) {
|
|
5537
5597
|
labels.push("client");
|
|
5538
5598
|
tasks.push(this.client.context.fetch({
|
|
5539
5599
|
conversation_id: conversationId,
|
|
5540
|
-
...
|
|
5600
|
+
...sharedNoPath
|
|
5541
5601
|
}));
|
|
5542
5602
|
}
|
|
5543
5603
|
if (tasks.length === 0 && !(conversationState && includeConversationContext)) {
|
|
@@ -5694,6 +5754,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5694
5754
|
async #withHistoryExcerpts(conversationId, response, query) {
|
|
5695
5755
|
const r = _nullishCoalesce(response, () => ( {}));
|
|
5696
5756
|
const store = this.#turnStore;
|
|
5757
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5697
5758
|
const recent = Array.isArray(r["recent_messages"]) ? r["recent_messages"] : [];
|
|
5698
5759
|
store.addMany(
|
|
5699
5760
|
conversationId,
|
|
@@ -5705,14 +5766,14 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5705
5766
|
}))
|
|
5706
5767
|
);
|
|
5707
5768
|
const entry = this.#shortTerm.get(conversationId);
|
|
5708
|
-
const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
5769
|
+
const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _107 => _107.serverMessageCount]), () => ( 0))) || 0);
|
|
5709
5770
|
this.#maybeBackfillTurns(conversationId, total);
|
|
5710
5771
|
if (!r["context_block"]) return response;
|
|
5711
5772
|
const turns = store.turns(conversationId);
|
|
5712
5773
|
let q = query;
|
|
5713
5774
|
if (!q) {
|
|
5714
5775
|
const latest = [...recent].reverse().find((m) => m["role"] === "user");
|
|
5715
|
-
q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access',
|
|
5776
|
+
q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _108 => _108.reverse, 'call', _109 => _109(), 'access', _110 => _110.find, 'call', _111 => _111((t) => t.role === "user"), 'optionalAccess', _112 => _112.content]), () => ( ""));
|
|
5716
5777
|
}
|
|
5717
5778
|
if (!q) return response;
|
|
5718
5779
|
const exclude = /* @__PURE__ */ new Set();
|
|
@@ -5741,7 +5802,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5741
5802
|
if (!conversationId || result === null || result === void 0) return;
|
|
5742
5803
|
try {
|
|
5743
5804
|
this.#turnStore.add(
|
|
5744
|
-
conversationId,
|
|
5805
|
+
_chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId),
|
|
5745
5806
|
"tool",
|
|
5746
5807
|
toolResultText(result, _nullishCoalesce(options.tool_name, () => ( options.toolName))),
|
|
5747
5808
|
_nullishCoalesce(options.timestamp, () => ( (/* @__PURE__ */ new Date()).toISOString()))
|
|
@@ -5760,17 +5821,18 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5760
5821
|
if (this.#localModelStarted) return;
|
|
5761
5822
|
this.#localModelStarted = true;
|
|
5762
5823
|
if (localModelOff()) return;
|
|
5763
|
-
const name = this.#localModelName === "auto" ?
|
|
5824
|
+
const name = this.#localModelName === "auto" ? _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model : this.#localModelName;
|
|
5764
5825
|
if (!name) return;
|
|
5765
5826
|
const callerEncoder = this.#localEncoder;
|
|
5766
5827
|
void Promise.resolve().then(() => _interopRequireWildcard(require("./onnx-encoder-4RSL6ID4.cjs"))).then(({ canRunLocalModel, loadOnnxEncoder }) => canRunLocalModel() ? loadOnnxEncoder(name) : null).then((encoder) => {
|
|
5767
5828
|
if (encoder === null) return;
|
|
5768
5829
|
if (callerEncoder === null) this.#localEncoder = encoder;
|
|
5769
|
-
if (encoder.model ===
|
|
5830
|
+
if (encoder.model === _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(encoder);
|
|
5770
5831
|
}).catch(() => {
|
|
5771
5832
|
});
|
|
5772
5833
|
}
|
|
5773
5834
|
#maybeBackfillTurns(conversationId, total) {
|
|
5835
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5774
5836
|
if (total <= this.#turnStore.count(conversationId)) return;
|
|
5775
5837
|
const now = Date.now();
|
|
5776
5838
|
if (now < (_nullishCoalesce(this.#backfillAfter.get(conversationId), () => ( 0)))) return;
|
|
@@ -5778,6 +5840,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5778
5840
|
void this.#backfillTurns(conversationId, total);
|
|
5779
5841
|
}
|
|
5780
5842
|
async #backfillTurns(conversationId, total) {
|
|
5843
|
+
conversationId = _chunk6GHXJD7Lcjs.normalizeConversationId.call(void 0, conversationId);
|
|
5781
5844
|
try {
|
|
5782
5845
|
let start = 1;
|
|
5783
5846
|
while (start <= total) {
|
|
@@ -5856,7 +5919,7 @@ function pick3(o2, snake, camel) {
|
|
|
5856
5919
|
function resolveBaseUrl(options) {
|
|
5857
5920
|
const explicit = _nullishCoalesce(options.baseUrl, () => ( options.api_base_url));
|
|
5858
5921
|
if (explicit !== void 0) return explicit;
|
|
5859
|
-
const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess',
|
|
5922
|
+
const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _113 => _113.trim, 'call', _114 => _114()]);
|
|
5860
5923
|
return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
|
|
5861
5924
|
}
|
|
5862
5925
|
function resolveCredentials(options, localMode) {
|
|
@@ -5940,5 +6003,5 @@ function resolveCredentials(options, localMode) {
|
|
|
5940
6003
|
|
|
5941
6004
|
|
|
5942
6005
|
|
|
5943
|
-
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;
|
|
5944
6007
|
//# sourceMappingURL=index.cjs.map
|