@maximem/synap-js-sdk 0.5.1 → 0.5.4
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/{chunk-ASM2OIIG.js → chunk-DJPYUPSV.js} +240 -2
- package/dist/chunk-DJPYUPSV.js.map +1 -0
- package/dist/{chunk-IA2N5NUY.cjs → chunk-WWTGJZA7.cjs} +254 -16
- package/dist/chunk-WWTGJZA7.cjs.map +1 -0
- package/dist/grpc/index.cjs +3 -3
- package/dist/grpc/index.d.cts +6 -0
- package/dist/grpc/index.d.ts +6 -0
- package/dist/grpc/index.js +2 -2
- package/dist/index.cjs +37 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +28 -5
- package/dist/index.js.map +1 -1
- package/dist/{stream-client-6OWRYOA4.js → stream-client-5CGJNTH4.js} +2 -2
- package/dist/stream-client-GJM4YSXW.cjs +16 -0
- package/dist/{stream-client-Y5JGSF2R.cjs.map → stream-client-GJM4YSXW.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-ASM2OIIG.js.map +0 -1
- package/dist/chunk-IA2N5NUY.cjs.map +0 -1
- package/dist/stream-client-Y5JGSF2R.cjs +0 -16
- /package/dist/{stream-client-6OWRYOA4.js.map → stream-client-5CGJNTH4.js.map} +0 -0
package/dist/grpc/index.d.cts
CHANGED
|
@@ -36,6 +36,12 @@ interface StreamClientOptions {
|
|
|
36
36
|
onContext?: (bundle: Record<string, unknown>) => void;
|
|
37
37
|
/** Fires only for `compaction_update` bundles. Backs the compaction subscriptions. */
|
|
38
38
|
onCompactionUpdate?: (conversationId: string, bundle: Record<string, unknown>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Where the outbox journal lives, so buffered events survive a restart.
|
|
41
|
+
* Defaults to `~/.synap`, the same root Python uses. `''` turns it off, and
|
|
42
|
+
* it is off anyway wherever there is no filesystem.
|
|
43
|
+
*/
|
|
44
|
+
outboxPath?: string;
|
|
39
45
|
}
|
|
40
46
|
interface ConversationEventInput {
|
|
41
47
|
event_type: string;
|
package/dist/grpc/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface StreamClientOptions {
|
|
|
36
36
|
onContext?: (bundle: Record<string, unknown>) => void;
|
|
37
37
|
/** Fires only for `compaction_update` bundles. Backs the compaction subscriptions. */
|
|
38
38
|
onCompactionUpdate?: (conversationId: string, bundle: Record<string, unknown>) => void;
|
|
39
|
+
/**
|
|
40
|
+
* Where the outbox journal lives, so buffered events survive a restart.
|
|
41
|
+
* Defaults to `~/.synap`, the same root Python uses. `''` turns it off, and
|
|
42
|
+
* it is off anyway wherever there is no filesystem.
|
|
43
|
+
*/
|
|
44
|
+
outboxPath?: string;
|
|
39
45
|
}
|
|
40
46
|
interface ConversationEventInput {
|
|
41
47
|
event_type: string;
|
package/dist/grpc/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
GrpcStreamClient,
|
|
3
3
|
PROTO_SHA
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-DJPYUPSV.js";
|
|
5
5
|
import {
|
|
6
6
|
ListeningNotActiveError
|
|
7
7
|
} from "../chunk-BWMPKLFG.js";
|
|
@@ -39,7 +39,7 @@ async function listen(options) {
|
|
|
39
39
|
throw new ListeningNotActiveError(availability.detail);
|
|
40
40
|
}
|
|
41
41
|
const [{ GrpcStreamClient: StreamClient }, { AnticipationCache }, { getEnv }] = await Promise.all([
|
|
42
|
-
import("../stream-client-
|
|
42
|
+
import("../stream-client-5CGJNTH4.js"),
|
|
43
43
|
import("../anticipation-cache-WLU4NMD5.js"),
|
|
44
44
|
import("../env-QCUKKW36.js")
|
|
45
45
|
]);
|
package/dist/index.cjs
CHANGED
|
@@ -536,6 +536,7 @@ function buildFetchRequest(scope, options) {
|
|
|
536
536
|
const searchQuery = opt(options, "search_query", "searchQuery");
|
|
537
537
|
const maxResults = _nullishCoalesce(opt(options, "max_results", "maxResults"), () => ( 10));
|
|
538
538
|
const precisionLevel = _nullishCoalesce(opt(options, "precision_level", "precisionLevel"), () => ( "high"));
|
|
539
|
+
const queryDate = opt(options, "query_date", "queryDate");
|
|
539
540
|
const mode = _nullishCoalesce(options.mode, () => ( "fast"));
|
|
540
541
|
if (searchQuery !== void 0 && !Array.isArray(searchQuery)) {
|
|
541
542
|
throw new (0, _chunkT372OL3Qcjs.InvalidInputError)("search_query must be an array when provided");
|
|
@@ -551,6 +552,7 @@ function buildFetchRequest(scope, options) {
|
|
|
551
552
|
mode
|
|
552
553
|
};
|
|
553
554
|
if (precisionLevel !== "high") body["precision_level"] = precisionLevel;
|
|
555
|
+
if (queryDate) body["query_date"] = queryDate;
|
|
554
556
|
if (options.include_conversation_context === false) {
|
|
555
557
|
body["include_conversation_context"] = false;
|
|
556
558
|
}
|
|
@@ -1391,7 +1393,22 @@ var KNOWN_EVENT_TYPES = /* @__PURE__ */ new Set([
|
|
|
1391
1393
|
]);
|
|
1392
1394
|
function toolResultJson(result) {
|
|
1393
1395
|
if (result === void 0 || result === null) return "";
|
|
1394
|
-
return typeof result === "string" ? result :
|
|
1396
|
+
return typeof result === "string" ? result : jsonOrText(result);
|
|
1397
|
+
}
|
|
1398
|
+
function jsonOrText(value) {
|
|
1399
|
+
try {
|
|
1400
|
+
const out = JSON.stringify(
|
|
1401
|
+
value,
|
|
1402
|
+
(_k, v) => typeof v === "bigint" ? String(v) : v
|
|
1403
|
+
);
|
|
1404
|
+
return out === void 0 ? String(value) : out;
|
|
1405
|
+
} catch (e5) {
|
|
1406
|
+
try {
|
|
1407
|
+
return String(value);
|
|
1408
|
+
} catch (e6) {
|
|
1409
|
+
return "";
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1395
1412
|
}
|
|
1396
1413
|
function createInstanceNamespace(credentials, cache, onTurn) {
|
|
1397
1414
|
let client = null;
|
|
@@ -1432,7 +1449,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1432
1449
|
...customerId ? { customer_id: customerId } : {}
|
|
1433
1450
|
});
|
|
1434
1451
|
openSessions.set(conversationId, sessionId);
|
|
1435
|
-
} catch (
|
|
1452
|
+
} catch (e7) {
|
|
1436
1453
|
}
|
|
1437
1454
|
}
|
|
1438
1455
|
const namespace = {
|
|
@@ -1440,7 +1457,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1440
1457
|
if (client !== null) {
|
|
1441
1458
|
throw new (0, _chunkT372OL3Qcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
|
|
1442
1459
|
}
|
|
1443
|
-
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-
|
|
1460
|
+
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-GJM4YSXW.cjs")));
|
|
1444
1461
|
const onContext = _nullishCoalesce(options.on_context, () => ( options.onContext));
|
|
1445
1462
|
const onDisconnect = _nullishCoalesce(options.on_disconnect, () => ( options.onDisconnect));
|
|
1446
1463
|
const onReconnect = _nullishCoalesce(options.on_reconnect, () => ( options.onReconnect));
|
|
@@ -1497,7 +1514,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1497
1514
|
session_id: sessionId,
|
|
1498
1515
|
conversation_id: conversationId
|
|
1499
1516
|
});
|
|
1500
|
-
} catch (
|
|
1517
|
+
} catch (e8) {
|
|
1501
1518
|
}
|
|
1502
1519
|
},
|
|
1503
1520
|
async send_message(options) {
|
|
@@ -1538,7 +1555,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1538
1555
|
// Python serialises tool_args with json.dumps into tool_args_json.
|
|
1539
1556
|
tool_args_json: (() => {
|
|
1540
1557
|
const a = _nullishCoalesce(options.tool_args, () => ( options.toolArgs));
|
|
1541
|
-
return a === void 0 ? "" :
|
|
1558
|
+
return a === void 0 ? "" : jsonOrText(a);
|
|
1542
1559
|
})(),
|
|
1543
1560
|
tool_result_json: toolResultJson(_nullishCoalesce(options.tool_result, () => ( options.toolResult))),
|
|
1544
1561
|
tool_call_id: _nullishCoalesce(_nullishCoalesce(options.tool_call_id, () => ( options.toolCallId)), () => ( "")),
|
|
@@ -1612,7 +1629,7 @@ function createInstanceNamespace(credentials, cache, onTurn) {
|
|
|
1612
1629
|
}
|
|
1613
1630
|
|
|
1614
1631
|
// src/version.ts
|
|
1615
|
-
var SDK_VERSION = "0.5.
|
|
1632
|
+
var SDK_VERSION = "0.5.4";
|
|
1616
1633
|
|
|
1617
1634
|
// src/registry.ts
|
|
1618
1635
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -1824,7 +1841,7 @@ function overlayLocalRecentTurns(response, store, conversationId, configured) {
|
|
|
1824
1841
|
compacted_at: orLocal("compacted_at", entry.compactedAt),
|
|
1825
1842
|
conversation_id: conversationId
|
|
1826
1843
|
};
|
|
1827
|
-
} catch (
|
|
1844
|
+
} catch (e9) {
|
|
1828
1845
|
}
|
|
1829
1846
|
}
|
|
1830
1847
|
|
|
@@ -1837,7 +1854,7 @@ function stringify(value) {
|
|
|
1837
1854
|
if (t === "string" || t === "number" || t === "boolean") return String(value);
|
|
1838
1855
|
try {
|
|
1839
1856
|
return _nullishCoalesce(JSON.stringify(value), () => ( ""));
|
|
1840
|
-
} catch (
|
|
1857
|
+
} catch (e10) {
|
|
1841
1858
|
return String(value);
|
|
1842
1859
|
}
|
|
1843
1860
|
}
|
|
@@ -2111,7 +2128,7 @@ function tryServeFromCache(cache, scope, params, maxItems) {
|
|
|
2111
2128
|
});
|
|
2112
2129
|
if (hit === null) return { response: null, hit: null };
|
|
2113
2130
|
return { response: buildAnticipationResponse(hit), hit };
|
|
2114
|
-
} catch (
|
|
2131
|
+
} catch (e11) {
|
|
2115
2132
|
return { response: null, hit: null };
|
|
2116
2133
|
}
|
|
2117
2134
|
}
|
|
@@ -2611,6 +2628,7 @@ var SynapClient = class {
|
|
|
2611
2628
|
this.#fetchHooks = {
|
|
2612
2629
|
beforeFetch: (scope, options2) => {
|
|
2613
2630
|
const o2 = options2;
|
|
2631
|
+
if (_nullishCoalesce(o2["query_date"], () => ( o2["queryDate"]))) return null;
|
|
2614
2632
|
const attempt = tryServeFromCache(
|
|
2615
2633
|
this.#anticipationCache,
|
|
2616
2634
|
scope,
|
|
@@ -2811,7 +2829,7 @@ var SynapClient = class {
|
|
|
2811
2829
|
this.#registryKeys.push(resolvedInstanceId);
|
|
2812
2830
|
}
|
|
2813
2831
|
}
|
|
2814
|
-
} catch (
|
|
2832
|
+
} catch (e12) {
|
|
2815
2833
|
}
|
|
2816
2834
|
}
|
|
2817
2835
|
/**
|
|
@@ -2879,6 +2897,7 @@ var SynapClient = class {
|
|
|
2879
2897
|
types,
|
|
2880
2898
|
mode = "fast",
|
|
2881
2899
|
precision_level: precisionLevel = "high",
|
|
2900
|
+
query_date: queryDate,
|
|
2882
2901
|
include_conversation_context: includeConversationContext = true,
|
|
2883
2902
|
scopes,
|
|
2884
2903
|
include_scope_labels: includeScopeLabels = false,
|
|
@@ -2893,7 +2912,11 @@ var SynapClient = class {
|
|
|
2893
2912
|
max_results: maxResults,
|
|
2894
2913
|
types,
|
|
2895
2914
|
mode,
|
|
2896
|
-
precision_level: precisionLevel
|
|
2915
|
+
precision_level: precisionLevel,
|
|
2916
|
+
// In `shared` so it reaches all four branches at once. The Python edit
|
|
2917
|
+
// threaded three call sites by hand and missed the client branch, which
|
|
2918
|
+
// sits one indent deeper; spreading removes that whole class of miss.
|
|
2919
|
+
query_date: queryDate
|
|
2897
2920
|
};
|
|
2898
2921
|
const labels = [];
|
|
2899
2922
|
const tasks = [];
|
|
@@ -2958,7 +2981,7 @@ var SynapClient = class {
|
|
|
2958
2981
|
merged.conversation_context = await this.conversation.context.get_context_for_prompt({
|
|
2959
2982
|
conversation_id: conversationId
|
|
2960
2983
|
});
|
|
2961
|
-
} catch (
|
|
2984
|
+
} catch (e13) {
|
|
2962
2985
|
}
|
|
2963
2986
|
}
|
|
2964
2987
|
merged.formatted_context = formatForPrompt(merged, {
|
|
@@ -3005,7 +3028,7 @@ var SynapClient = class {
|
|
|
3005
3028
|
source_bundle_ids: served.bundleId ? [served.bundleId] : [],
|
|
3006
3029
|
timestamp_ms: Date.now()
|
|
3007
3030
|
});
|
|
3008
|
-
} catch (
|
|
3031
|
+
} catch (e14) {
|
|
3009
3032
|
}
|
|
3010
3033
|
}
|
|
3011
3034
|
/**
|
|
@@ -3030,7 +3053,7 @@ var SynapClient = class {
|
|
|
3030
3053
|
}),
|
|
3031
3054
|
scope
|
|
3032
3055
|
});
|
|
3033
|
-
} catch (
|
|
3056
|
+
} catch (e15) {
|
|
3034
3057
|
}
|
|
3035
3058
|
}
|
|
3036
3059
|
/**
|