@maximem/synap-js-sdk 0.7.2 → 0.8.1
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-JDX2VTFE.cjs.map +1 -1
- package/dist/chunk-6GHXJD7L.cjs.map +1 -1
- package/dist/chunk-JPDEKN5M.cjs.map +1 -1
- package/dist/{chunk-RKKTOLXP.js → chunk-MI636P2I.js} +30 -4
- package/dist/chunk-MI636P2I.js.map +1 -0
- package/dist/{chunk-SAKMZI7G.cjs → chunk-ZIMMNSVB.cjs} +41 -15
- package/dist/chunk-ZIMMNSVB.cjs.map +1 -0
- package/dist/chunk-ZKOJDUN4.cjs.map +1 -1
- package/dist/env-55ULHNJZ.cjs.map +1 -1
- package/dist/grpc/index.cjs +3 -3
- package/dist/grpc/index.cjs.map +1 -1
- package/dist/grpc/index.js +2 -2
- package/dist/index.cjs +142 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +103 -7
- package/dist/index.d.ts +103 -7
- package/dist/index.js +108 -7
- package/dist/index.js.map +1 -1
- package/dist/onnx-encoder-4RSL6ID4.cjs.map +1 -1
- package/dist/{stream-client-7A2DQ3H3.js → stream-client-3VPWCEWU.js} +2 -2
- package/dist/stream-client-BGMZW2WP.cjs +22 -0
- package/dist/stream-client-BGMZW2WP.cjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-RKKTOLXP.js.map +0 -1
- package/dist/chunk-SAKMZI7G.cjs.map +0 -1
- package/dist/stream-client-H2ES74FF.cjs +0 -22
- package/dist/stream-client-H2ES74FF.cjs.map +0 -1
- /package/dist/{stream-client-7A2DQ3H3.js.map → stream-client-3VPWCEWU.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -67,6 +67,7 @@ var ENDPOINTS = {
|
|
|
67
67
|
memories_delete: { method: "DELETE", path: "/api/v1/memories/{memory_id}", idempotent: true },
|
|
68
68
|
memories_forget: { method: "POST", path: "/api/v1/memories/forget", idempotent: false },
|
|
69
69
|
data_delete: { method: "POST", path: "/v1/data/delete", idempotent: true },
|
|
70
|
+
data_restore: { method: "POST", path: "/v1/data/restore", idempotent: true },
|
|
70
71
|
data_delete_status: { method: "GET", path: "/v1/data/delete/{deletion_id}", idempotent: true },
|
|
71
72
|
context_fetch_user: { method: "POST", path: "/v1/context/user/fetch", idempotent: true },
|
|
72
73
|
context_fetch_customer: { method: "POST", path: "/v1/context/customer/fetch", idempotent: true },
|
|
@@ -2130,20 +2131,35 @@ function createMemoriesInterface(transport, onForgotten) {
|
|
|
2130
2131
|
body
|
|
2131
2132
|
});
|
|
2132
2133
|
},
|
|
2133
|
-
async delete(memoryId) {
|
|
2134
|
+
async delete(memoryId, options) {
|
|
2135
|
+
const permanent = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _63 => _63.permanent]), () => ( false));
|
|
2136
|
+
if (typeof permanent !== "boolean") throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("permanent must be a boolean");
|
|
2134
2137
|
if (!memoryId) {
|
|
2135
2138
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
|
|
2136
2139
|
"memory_id is required. Deleting by user is no longer supported: the previous implementation tracked ids in process memory, so it silently deleted nothing in any serverless or multi-process deployment while reporting success."
|
|
2137
2140
|
);
|
|
2138
2141
|
}
|
|
2139
|
-
|
|
2142
|
+
const r = await transport.request("memories_delete", {
|
|
2143
|
+
pathParams: { memory_id: memoryId },
|
|
2144
|
+
...permanent ? { query: { permanent: "true" } } : {}
|
|
2145
|
+
});
|
|
2146
|
+
return {
|
|
2147
|
+
memory_id: String(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _64 => _64["memory_id"]]), () => ( memoryId))),
|
|
2148
|
+
deleted_at: String(_nullishCoalesce(_optionalChain([r, 'optionalAccess', _65 => _65["deleted_at"]]), () => ( ""))),
|
|
2149
|
+
fully_removed: _optionalChain([r, 'optionalAccess', _66 => _66["fully_removed"]]) === true,
|
|
2150
|
+
still_present_in: Array.isArray(_optionalChain([r, 'optionalAccess', _67 => _67["still_present_in"]])) ? r["still_present_in"] : [],
|
|
2151
|
+
source_text_kept: _optionalChain([r, 'optionalAccess', _68 => _68["source_text_kept"]]) === true,
|
|
2152
|
+
status: typeof _optionalChain([r, 'optionalAccess', _69 => _69["status"]]) === "string" && r["status"] ? r["status"] : "complete",
|
|
2153
|
+
purge_after: typeof _optionalChain([r, 'optionalAccess', _70 => _70["purge_after"]]) === "string" ? r["purge_after"] : null,
|
|
2154
|
+
permanent: _optionalChain([r, 'optionalAccess', _71 => _71["permanent"]]) === true
|
|
2155
|
+
};
|
|
2140
2156
|
},
|
|
2141
2157
|
async forget(options) {
|
|
2142
2158
|
const o2 = options;
|
|
2143
2159
|
await transport.checkCustomerId(_nullishCoalesce(o2["customer_id"], () => ( o2["customerId"])), "memories.forget");
|
|
2144
2160
|
const body = buildForgetBody(options);
|
|
2145
2161
|
const result = await transport.request("memories_forget", { body });
|
|
2146
|
-
const removed = !!_optionalChain([result, 'optionalAccess',
|
|
2162
|
+
const removed = !!_optionalChain([result, 'optionalAccess', _72 => _72.deleted_ids, 'optionalAccess', _73 => _73.length]) || _optionalChain([result, 'optionalAccess', _74 => _74.status]) === "deleted" || _optionalChain([result, 'optionalAccess', _75 => _75.status]) === "partial";
|
|
2147
2163
|
if (removed && onForgotten) {
|
|
2148
2164
|
try {
|
|
2149
2165
|
onForgotten({
|
|
@@ -2183,14 +2199,14 @@ function sleep2(ms, signal) {
|
|
|
2183
2199
|
if (ms <= 0) return Promise.resolve();
|
|
2184
2200
|
return new Promise((resolve, reject) => {
|
|
2185
2201
|
const timer = setTimeout(() => {
|
|
2186
|
-
_optionalChain([signal, 'optionalAccess',
|
|
2202
|
+
_optionalChain([signal, 'optionalAccess', _76 => _76.removeEventListener, 'call', _77 => _77("abort", onAbort)]);
|
|
2187
2203
|
resolve();
|
|
2188
2204
|
}, ms);
|
|
2189
2205
|
function onAbort() {
|
|
2190
2206
|
clearTimeout(timer);
|
|
2191
|
-
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess',
|
|
2207
|
+
reject(_nullishCoalesce(_optionalChain([signal, 'optionalAccess', _78 => _78.reason]), () => ( new Error("Aborted"))));
|
|
2192
2208
|
}
|
|
2193
|
-
_optionalChain([signal, 'optionalAccess',
|
|
2209
|
+
_optionalChain([signal, 'optionalAccess', _79 => _79.addEventListener, 'call', _80 => _80("abort", onAbort, { once: true })]);
|
|
2194
2210
|
});
|
|
2195
2211
|
}
|
|
2196
2212
|
|
|
@@ -2271,7 +2287,7 @@ function buildRecordMessageBody(options, resolvedContent, field = "content") {
|
|
|
2271
2287
|
content = resolvedContent;
|
|
2272
2288
|
} else {
|
|
2273
2289
|
const n2 = normaliseContent(options.content, field);
|
|
2274
|
-
if (_optionalChain([n2, 'optionalAccess',
|
|
2290
|
+
if (_optionalChain([n2, 'optionalAccess', _81 => _81.kind]) === "parts") {
|
|
2275
2291
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(
|
|
2276
2292
|
"content holds a FilePart, whose bytes have to be read first. Send it with conversation.record_message."
|
|
2277
2293
|
);
|
|
@@ -2385,7 +2401,7 @@ function storedBatchRows(bodies, result) {
|
|
|
2385
2401
|
const r = _nullishCoalesce(result, () => ( {}));
|
|
2386
2402
|
const results = Array.isArray(r["results"]) ? r["results"] : [];
|
|
2387
2403
|
const errors = Array.isArray(r["errors"]) ? r["errors"] : [];
|
|
2388
|
-
const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess',
|
|
2404
|
+
const failed = new Set(errors.map((e) => _optionalChain([e, 'optionalAccess', _82 => _82["index"]])));
|
|
2389
2405
|
const stored = bodies.filter((_, index) => !failed.has(index));
|
|
2390
2406
|
if (stored.length !== results.length) return [];
|
|
2391
2407
|
const pairs = [];
|
|
@@ -2429,7 +2445,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2429
2445
|
};
|
|
2430
2446
|
const fetchImpl = ((url, init) => transport.fetchExternal(url, init));
|
|
2431
2447
|
const validateMessage = (options, field = "content") => {
|
|
2432
|
-
if (_optionalChain([normaliseContent, 'call',
|
|
2448
|
+
if (_optionalChain([normaliseContent, 'call', _83 => _83(options.content, field), 'optionalAccess', _84 => _84.kind]) === "parts") {
|
|
2433
2449
|
buildRecordMessageBody(options, "", field);
|
|
2434
2450
|
} else {
|
|
2435
2451
|
buildRecordMessageBody(options, void 0, field);
|
|
@@ -2437,7 +2453,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2437
2453
|
};
|
|
2438
2454
|
const prepareMessage = async (options, field = "content") => {
|
|
2439
2455
|
const n2 = normaliseContent(options.content, field);
|
|
2440
|
-
if (_optionalChain([n2, 'optionalAccess',
|
|
2456
|
+
if (_optionalChain([n2, 'optionalAccess', _85 => _85.kind]) !== "parts") {
|
|
2441
2457
|
const body = buildRecordMessageBody(options, void 0, field);
|
|
2442
2458
|
return { body, mirror: String(_nullishCoalesce(body["content"], () => ( ""))) };
|
|
2443
2459
|
}
|
|
@@ -2528,7 +2544,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2528
2544
|
const raw = await transport.request("conversations_ingest", { body });
|
|
2529
2545
|
const result = {
|
|
2530
2546
|
...raw,
|
|
2531
|
-
warnings: Array.isArray(_optionalChain([raw, 'optionalAccess',
|
|
2547
|
+
warnings: Array.isArray(_optionalChain([raw, 'optionalAccess', _86 => _86.warnings])) ? raw.warnings.map(String) : []
|
|
2532
2548
|
};
|
|
2533
2549
|
onWrite({
|
|
2534
2550
|
userId: body["user_id"],
|
|
@@ -2572,8 +2588,8 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
|
|
|
2572
2588
|
pathParams: { conversation_id: id },
|
|
2573
2589
|
query: { style }
|
|
2574
2590
|
});
|
|
2575
|
-
const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess',
|
|
2576
|
-
_optionalChain([localShortTerm, 'access',
|
|
2591
|
+
const response = _nullishCoalesce(_nullishCoalesce(_optionalChain([result, 'optionalAccess', _87 => _87["context_for_prompt"]]), () => ( result)), () => ( {}));
|
|
2592
|
+
_optionalChain([localShortTerm, 'access', _88 => _88.reseed, 'optionalCall', _89 => _89(id, response)]);
|
|
2577
2593
|
return withHistory(response);
|
|
2578
2594
|
},
|
|
2579
2595
|
async compact(options) {
|
|
@@ -2633,6 +2649,7 @@ var ID_FIELD = {
|
|
|
2633
2649
|
customer: "customer_id",
|
|
2634
2650
|
conversation: "conversation_id"
|
|
2635
2651
|
};
|
|
2652
|
+
var MAX_RESTORE_IDS = 200;
|
|
2636
2653
|
function either3(o2, snake, camel) {
|
|
2637
2654
|
const a = o2[snake];
|
|
2638
2655
|
if (a !== void 0) return a;
|
|
@@ -2680,15 +2697,39 @@ function buildDeleteBody(options, instanceId) {
|
|
|
2680
2697
|
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)(`confirm must equal the ${field} being deleted`);
|
|
2681
2698
|
}
|
|
2682
2699
|
}
|
|
2683
|
-
|
|
2700
|
+
const instances2 = options.instances === void 0 || options.instances === null ? null : checkInstances(options.instances);
|
|
2701
|
+
const permanent = _nullishCoalesce(options.permanent, () => ( false));
|
|
2702
|
+
if (typeof permanent !== "boolean") throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("permanent must be a boolean");
|
|
2703
|
+
const body = {
|
|
2684
2704
|
scope,
|
|
2685
|
-
|
|
2705
|
+
// Without `instances` the body is byte-identical to earlier versions.
|
|
2706
|
+
instance_id: instances2 === null ? instanceId : null,
|
|
2686
2707
|
user_id: _nullishCoalesce(ids["user_id"], () => ( null)),
|
|
2687
2708
|
customer_id: _nullishCoalesce(ids["customer_id"], () => ( null)),
|
|
2688
2709
|
conversation_id: _nullishCoalesce(ids["conversation_id"], () => ( null)),
|
|
2689
2710
|
dry_run: dryRun,
|
|
2690
2711
|
confirm
|
|
2691
2712
|
};
|
|
2713
|
+
if (instances2 !== null) body["instance_ids"] = instances2;
|
|
2714
|
+
if (permanent) body["permanent"] = true;
|
|
2715
|
+
return body;
|
|
2716
|
+
}
|
|
2717
|
+
function checkInstances(instances2) {
|
|
2718
|
+
if (instances2 === "all") return "all";
|
|
2719
|
+
if (!Array.isArray(instances2)) {
|
|
2720
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)('instances must be "all" or a list of instance ids');
|
|
2721
|
+
}
|
|
2722
|
+
const out = [];
|
|
2723
|
+
for (const i of instances2) {
|
|
2724
|
+
if (typeof i !== "string" || i.trim() === "") {
|
|
2725
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("instances must not contain an empty instance id");
|
|
2726
|
+
}
|
|
2727
|
+
if (!out.includes(i.trim())) out.push(i.trim());
|
|
2728
|
+
}
|
|
2729
|
+
if (out.length === 0) {
|
|
2730
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)('instances is empty: name at least one instance, or "all"');
|
|
2731
|
+
}
|
|
2732
|
+
return out;
|
|
2692
2733
|
}
|
|
2693
2734
|
function normalise(raw) {
|
|
2694
2735
|
return {
|
|
@@ -2704,13 +2745,43 @@ function normalise(raw) {
|
|
|
2704
2745
|
fully_removed: false,
|
|
2705
2746
|
continue: false,
|
|
2706
2747
|
kept: [],
|
|
2748
|
+
not_covered: [],
|
|
2707
2749
|
note: null,
|
|
2708
2750
|
memories_kept: false,
|
|
2709
2751
|
audit: null,
|
|
2710
2752
|
local_cleared: [],
|
|
2753
|
+
instances: [],
|
|
2754
|
+
not_started: [],
|
|
2755
|
+
deletion_ids: [],
|
|
2756
|
+
purge_after: null,
|
|
2711
2757
|
...raw
|
|
2712
2758
|
};
|
|
2713
2759
|
}
|
|
2760
|
+
function buildRestoreBody(memoryIds, instanceId, deletionId = null) {
|
|
2761
|
+
const noIds = memoryIds === null || memoryIds === void 0;
|
|
2762
|
+
const noDeletion = deletionId === null || deletionId === void 0;
|
|
2763
|
+
if (noIds === noDeletion) {
|
|
2764
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("send exactly one of memory_ids or deletion_id");
|
|
2765
|
+
}
|
|
2766
|
+
if (!noDeletion) {
|
|
2767
|
+
if (typeof deletionId !== "string" || deletionId.trim() === "") {
|
|
2768
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("deletion_id must not be empty");
|
|
2769
|
+
}
|
|
2770
|
+
return { deletion_id: deletionId.trim(), instance_id: instanceId };
|
|
2771
|
+
}
|
|
2772
|
+
if (typeof memoryIds === "string" || !Array.isArray(memoryIds)) {
|
|
2773
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("memory_ids must be a list of memory ids");
|
|
2774
|
+
}
|
|
2775
|
+
const ids = memoryIds.map((i) => String(i));
|
|
2776
|
+
if (ids.length === 0) throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("memory_ids must not be empty");
|
|
2777
|
+
if (ids.length > MAX_RESTORE_IDS) {
|
|
2778
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("at most " + String(MAX_RESTORE_IDS) + " memory_ids per call");
|
|
2779
|
+
}
|
|
2780
|
+
if (ids.some((i) => i.trim() === "")) {
|
|
2781
|
+
throw new (0, _chunkJPDEKN5Mcjs.InvalidInputError)("memory_ids must not contain empty ids");
|
|
2782
|
+
}
|
|
2783
|
+
return { memory_ids: ids, instance_id: instanceId };
|
|
2784
|
+
}
|
|
2714
2785
|
function createDataInterface(transport, onDeleted) {
|
|
2715
2786
|
return {
|
|
2716
2787
|
async delete(options) {
|
|
@@ -2730,7 +2801,7 @@ function createDataInterface(transport, onDeleted) {
|
|
|
2730
2801
|
if (dryRun || !result.continue) break;
|
|
2731
2802
|
}
|
|
2732
2803
|
const final = result;
|
|
2733
|
-
if (!dryRun && ["complete", "partial", "in_progress"].includes(final.status) && onDeleted) {
|
|
2804
|
+
if (!dryRun && ["complete", "pending_purge", "partial", "in_progress"].includes(final.status) && onDeleted) {
|
|
2734
2805
|
try {
|
|
2735
2806
|
final.local_cleared = onDeleted({
|
|
2736
2807
|
scope: body["scope"],
|
|
@@ -2753,6 +2824,29 @@ function createDataInterface(transport, onDeleted) {
|
|
|
2753
2824
|
query: { instance_id: transport.currentCredentials().instanceId }
|
|
2754
2825
|
})
|
|
2755
2826
|
);
|
|
2827
|
+
},
|
|
2828
|
+
async restore(target) {
|
|
2829
|
+
const instanceId = transport.currentCredentials().instanceId;
|
|
2830
|
+
let body;
|
|
2831
|
+
if (Array.isArray(target) || typeof target === "string" || target === null || target === void 0) {
|
|
2832
|
+
body = buildRestoreBody(target, instanceId);
|
|
2833
|
+
} else {
|
|
2834
|
+
const o2 = target;
|
|
2835
|
+
body = buildRestoreBody(
|
|
2836
|
+
_nullishCoalesce(either3(o2, "memory_ids", "memoryIds"), () => ( null)),
|
|
2837
|
+
instanceId,
|
|
2838
|
+
_nullishCoalesce(either3(o2, "deletion_id", "deletionId"), () => ( null))
|
|
2839
|
+
);
|
|
2840
|
+
}
|
|
2841
|
+
const raw = await transport.request("data_restore", { body });
|
|
2842
|
+
return {
|
|
2843
|
+
restored_ids: [],
|
|
2844
|
+
not_restorable_ids: [],
|
|
2845
|
+
still_missing_in: [],
|
|
2846
|
+
reindexed_ids: [],
|
|
2847
|
+
fully_restored: false,
|
|
2848
|
+
...raw
|
|
2849
|
+
};
|
|
2756
2850
|
}
|
|
2757
2851
|
};
|
|
2758
2852
|
}
|
|
@@ -2970,8 +3064,8 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2970
3064
|
let onConversationState = null;
|
|
2971
3065
|
const internals = {
|
|
2972
3066
|
onCompactionUpdate(conversationId, bundle) {
|
|
2973
|
-
_optionalChain([applyCompaction, 'optionalCall',
|
|
2974
|
-
_optionalChain([dispatchCompaction, 'optionalCall',
|
|
3067
|
+
_optionalChain([applyCompaction, 'optionalCall', _90 => _90(bundle)]);
|
|
3068
|
+
_optionalChain([dispatchCompaction, 'optionalCall', _91 => _91(conversationId, bundle)]);
|
|
2975
3069
|
},
|
|
2976
3070
|
setCompactionApplier(apply) {
|
|
2977
3071
|
applyCompaction = apply;
|
|
@@ -2986,10 +3080,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
2986
3080
|
onConversationState = handle;
|
|
2987
3081
|
},
|
|
2988
3082
|
sendContextUsed(event) {
|
|
2989
|
-
_optionalChain([client, 'optionalAccess',
|
|
3083
|
+
_optionalChain([client, 'optionalAccess', _92 => _92.sendContextUsed, 'call', _93 => _93(event)]);
|
|
2990
3084
|
},
|
|
2991
3085
|
sendContextAssembled(event) {
|
|
2992
|
-
_optionalChain([client, 'optionalAccess',
|
|
3086
|
+
_optionalChain([client, 'optionalAccess', _94 => _94.sendContextAssembled, 'call', _95 => _95(event)]);
|
|
2993
3087
|
},
|
|
2994
3088
|
setCompactionDispatcher(dispatch) {
|
|
2995
3089
|
dispatchCompaction = dispatch;
|
|
@@ -3030,7 +3124,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3030
3124
|
send(sync);
|
|
3031
3125
|
return Promise.resolve();
|
|
3032
3126
|
}
|
|
3033
|
-
_optionalChain([prepared, 'optionalAccess',
|
|
3127
|
+
_optionalChain([prepared, 'optionalAccess', _96 => _96.catch, 'call', _97 => _97(() => {
|
|
3034
3128
|
})]);
|
|
3035
3129
|
queued += 1;
|
|
3036
3130
|
const run = tail.then(async () => {
|
|
@@ -3049,10 +3143,10 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3049
3143
|
throw new (0, _chunkJPDEKN5Mcjs.ListeningAlreadyActiveError)("Listening is already active on this instance");
|
|
3050
3144
|
}
|
|
3051
3145
|
try {
|
|
3052
|
-
_optionalChain([onListen, 'optionalCall',
|
|
3146
|
+
_optionalChain([onListen, 'optionalCall', _98 => _98()]);
|
|
3053
3147
|
} catch (e17) {
|
|
3054
3148
|
}
|
|
3055
|
-
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-
|
|
3149
|
+
const { GrpcStreamClient } = await Promise.resolve().then(() => _interopRequireWildcard(require("./stream-client-BGMZW2WP.cjs")));
|
|
3056
3150
|
const onContext = _nullishCoalesce(options.on_context, () => ( options.onContext));
|
|
3057
3151
|
const onDisconnect = _nullishCoalesce(options.on_disconnect, () => ( options.onDisconnect));
|
|
3058
3152
|
const onReconnect = _nullishCoalesce(options.on_reconnect, () => ( options.onReconnect));
|
|
@@ -3067,17 +3161,17 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3067
3161
|
internals.onCompactionUpdate(conversationId, bundle);
|
|
3068
3162
|
},
|
|
3069
3163
|
onConversationState: (conversationId, messageCount) => {
|
|
3070
|
-
_optionalChain([onConversationState, 'optionalCall',
|
|
3164
|
+
_optionalChain([onConversationState, 'optionalCall', _99 => _99(conversationId, messageCount)]);
|
|
3071
3165
|
},
|
|
3072
3166
|
onStateChange: (state) => {
|
|
3073
3167
|
if (state !== "connected") openSessions.clear();
|
|
3074
3168
|
if (state === "reconnecting") {
|
|
3075
3169
|
reconnectAttempts += 1;
|
|
3076
|
-
_optionalChain([onReconnect, 'optionalCall',
|
|
3170
|
+
_optionalChain([onReconnect, 'optionalCall', _100 => _100(reconnectAttempts)]);
|
|
3077
3171
|
} else if (state === "disconnected") {
|
|
3078
|
-
const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess',
|
|
3172
|
+
const stopped = _nullishCoalesce(_optionalChain([stream, 'optionalAccess', _101 => _101.lastError]), () => ( null));
|
|
3079
3173
|
const reason = stopped === null ? "stream disconnected" : `credit_stop:${_nullishCoalesce(stopped.reason, () => ( "unknown"))}`;
|
|
3080
|
-
_optionalChain([onDisconnect, 'optionalCall',
|
|
3174
|
+
_optionalChain([onDisconnect, 'optionalCall', _102 => _102(reason)]);
|
|
3081
3175
|
}
|
|
3082
3176
|
}
|
|
3083
3177
|
});
|
|
@@ -3087,7 +3181,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3087
3181
|
} catch (error) {
|
|
3088
3182
|
if (error instanceof _chunkJPDEKN5Mcjs.SynapError) throw error;
|
|
3089
3183
|
throw new (0, _chunkJPDEKN5Mcjs.SynapError)(
|
|
3090
|
-
`Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess',
|
|
3184
|
+
`Could not open the Synap anticipation stream: ${_nullishCoalesce(_optionalChain([error, 'optionalAccess', _103 => _103.message]), () => ( String(error)))}`,
|
|
3091
3185
|
{ cause: error }
|
|
3092
3186
|
);
|
|
3093
3187
|
}
|
|
@@ -3143,7 +3237,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3143
3237
|
_nullishCoalesce(_nullishCoalesce(options.customer_id, () => ( options.customerId)), () => ( ""))
|
|
3144
3238
|
);
|
|
3145
3239
|
if (eventType === "user_message" || eventType === "assistant_message") {
|
|
3146
|
-
_optionalChain([onTurn, 'optionalCall',
|
|
3240
|
+
_optionalChain([onTurn, 'optionalCall', _104 => _104({
|
|
3147
3241
|
conversationId,
|
|
3148
3242
|
role: _nullishCoalesce(options.role, () => ( "user")),
|
|
3149
3243
|
content
|
|
@@ -3175,8 +3269,8 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3175
3269
|
})()
|
|
3176
3270
|
});
|
|
3177
3271
|
};
|
|
3178
|
-
if (_optionalChain([parts, 'optionalAccess',
|
|
3179
|
-
const content = _optionalChain([parts, 'optionalAccess',
|
|
3272
|
+
if (_optionalChain([parts, 'optionalAccess', _105 => _105.kind]) !== "parts") {
|
|
3273
|
+
const content = _optionalChain([parts, 'optionalAccess', _106 => _106.kind]) === "text" ? parts.text : options.content;
|
|
3180
3274
|
return inOrder(null, emit, { content, metadata: _nullishCoalesce(options.metadata, () => ( {})) });
|
|
3181
3275
|
}
|
|
3182
3276
|
const prepared = (async () => {
|
|
@@ -3214,7 +3308,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3214
3308
|
async record_tool_result(options) {
|
|
3215
3309
|
const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
|
|
3216
3310
|
if (conversationId) {
|
|
3217
|
-
_optionalChain([onToolResult, 'optionalCall',
|
|
3311
|
+
_optionalChain([onToolResult, 'optionalCall', _107 => _107({ conversationId, result: options.result, toolName: _nullishCoalesce(_nullishCoalesce(options.tool_name, () => ( options.toolName)), () => ( "")) })]);
|
|
3218
3312
|
}
|
|
3219
3313
|
await namespace.send_message({
|
|
3220
3314
|
content: "",
|
|
@@ -3231,6 +3325,12 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3231
3325
|
});
|
|
3232
3326
|
},
|
|
3233
3327
|
async record_thinking(options) {
|
|
3328
|
+
if (hasCustomerIdCheck) {
|
|
3329
|
+
await checkCustomerId3(
|
|
3330
|
+
_nullishCoalesce(options.customer_id, () => ( options.customerId)),
|
|
3331
|
+
"InstanceInterface.record_thinking"
|
|
3332
|
+
);
|
|
3333
|
+
}
|
|
3234
3334
|
if (client === null) throw new (0, _chunkJPDEKN5Mcjs.ListeningNotActiveError)("Listening is not active");
|
|
3235
3335
|
const conversationId = _nullishCoalesce(_nullishCoalesce(options.conversation_id, () => ( options.conversationId)), () => ( ""));
|
|
3236
3336
|
ensureSession(
|
|
@@ -3269,7 +3369,7 @@ function createInstanceNamespace(credentials, cache, onTurn, fetchOrAgentModel,
|
|
|
3269
3369
|
}
|
|
3270
3370
|
|
|
3271
3371
|
// src/version.ts
|
|
3272
|
-
var SDK_VERSION = "0.
|
|
3372
|
+
var SDK_VERSION = "0.8.1";
|
|
3273
3373
|
|
|
3274
3374
|
// src/registry.ts
|
|
3275
3375
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -3742,7 +3842,7 @@ var TurnStore = (_class3 = class {
|
|
|
3742
3842
|
}
|
|
3743
3843
|
/** Turns the server also holds: archived tool results are local only. Python: `count`. */
|
|
3744
3844
|
count(conversationId) {
|
|
3745
|
-
return (_nullishCoalesce(_optionalChain([this, 'access',
|
|
3845
|
+
return (_nullishCoalesce(_optionalChain([this, 'access', _108 => _108.#conversations, 'access', _109 => _109.get, 'call', _110 => _110(conversationId), 'optionalAccess', _111 => _111.turns]), () => ( []))).filter((t) => t.role !== "tool").length;
|
|
3746
3846
|
}
|
|
3747
3847
|
sizeBytes() {
|
|
3748
3848
|
let n2 = 0;
|
|
@@ -3921,7 +4021,7 @@ function askedKinds(query) {
|
|
|
3921
4021
|
}
|
|
3922
4022
|
function asksHowItStarted(query) {
|
|
3923
4023
|
const spec = _chunk6GHXJD7Lcjs.HISTORY_SEARCH.early_query;
|
|
3924
|
-
if (!_optionalChain([spec, 'optionalAccess',
|
|
4024
|
+
if (!_optionalChain([spec, 'optionalAccess', _112 => _112.pattern])) return false;
|
|
3925
4025
|
return new RegExp(spec.pattern, (_nullishCoalesce(spec.flags, () => ( ""))).includes("i") ? "i" : "").test(_nullishCoalesce(query, () => ( "")));
|
|
3926
4026
|
}
|
|
3927
4027
|
async function searchTurns(turns, query, options = {}) {
|
|
@@ -5184,7 +5284,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5184
5284
|
this.#localEncoder = _nullishCoalesce(_nullishCoalesce(options.history_search_encoder, () => ( options.historySearchEncoder)), () => ( null));
|
|
5185
5285
|
const modelOption = options.history_search_model !== void 0 ? options.history_search_model : options.historySearchModel;
|
|
5186
5286
|
this.#localModelName = modelOption === void 0 ? "auto" : modelOption;
|
|
5187
|
-
if (_optionalChain([this, 'access',
|
|
5287
|
+
if (_optionalChain([this, 'access', _113 => _113.#localEncoder, 'optionalAccess', _114 => _114.model]) === _chunk6GHXJD7Lcjs.SEMANTIC_MATCH.model) this.#anticipationCache.setEncoder(this.#localEncoder);
|
|
5188
5288
|
this.#turns = new TurnCounter();
|
|
5189
5289
|
this.conversation = createConversationNamespace(
|
|
5190
5290
|
this.#transport,
|
|
@@ -5426,7 +5526,7 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5426
5526
|
} catch (error) {
|
|
5427
5527
|
if (this.#localMode) {
|
|
5428
5528
|
throw new (0, _chunkJPDEKN5Mcjs.AuthenticationError)(
|
|
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',
|
|
5529
|
+
`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', _115 => _115.message]), () => ( String(error)))}).`,
|
|
5430
5530
|
{ cause: error }
|
|
5431
5531
|
);
|
|
5432
5532
|
}
|
|
@@ -5766,14 +5866,14 @@ var SynapClient = (_class4 = class _SynapClient {
|
|
|
5766
5866
|
}))
|
|
5767
5867
|
);
|
|
5768
5868
|
const entry = this.#shortTerm.get(conversationId);
|
|
5769
|
-
const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess',
|
|
5869
|
+
const total = Math.max(Number(_nullishCoalesce(r["total_message_count"], () => ( 0))) || 0, Number(_nullishCoalesce(_optionalChain([entry, 'optionalAccess', _116 => _116.serverMessageCount]), () => ( 0))) || 0);
|
|
5770
5870
|
this.#maybeBackfillTurns(conversationId, total);
|
|
5771
5871
|
if (!r["context_block"]) return response;
|
|
5772
5872
|
const turns = store.turns(conversationId);
|
|
5773
5873
|
let q = query;
|
|
5774
5874
|
if (!q) {
|
|
5775
5875
|
const latest = [...recent].reverse().find((m) => m["role"] === "user");
|
|
5776
|
-
q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access',
|
|
5876
|
+
q = latest ? String(_nullishCoalesce(latest["content"], () => ( ""))) : _nullishCoalesce(_optionalChain([[...turns], 'access', _117 => _117.reverse, 'call', _118 => _118(), 'access', _119 => _119.find, 'call', _120 => _120((t) => t.role === "user"), 'optionalAccess', _121 => _121.content]), () => ( ""));
|
|
5777
5877
|
}
|
|
5778
5878
|
if (!q) return response;
|
|
5779
5879
|
const exclude = /* @__PURE__ */ new Set();
|
|
@@ -5919,7 +6019,7 @@ function pick3(o2, snake, camel) {
|
|
|
5919
6019
|
function resolveBaseUrl(options) {
|
|
5920
6020
|
const explicit = _nullishCoalesce(options.baseUrl, () => ( options.api_base_url));
|
|
5921
6021
|
if (explicit !== void 0) return explicit;
|
|
5922
|
-
const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess',
|
|
6022
|
+
const fromEnv = _optionalChain([_chunkZKOJDUN4cjs.getEnv.call(void 0, "SYNAP_BASE_URL"), 'optionalAccess', _122 => _122.trim, 'call', _123 => _123()]);
|
|
5923
6023
|
return fromEnv !== void 0 && fromEnv !== "" ? fromEnv : void 0;
|
|
5924
6024
|
}
|
|
5925
6025
|
function resolveCredentials(options, localMode) {
|
|
@@ -6003,5 +6103,6 @@ function resolveCredentials(options, localMode) {
|
|
|
6003
6103
|
|
|
6004
6104
|
|
|
6005
6105
|
|
|
6006
|
-
|
|
6106
|
+
|
|
6107
|
+
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.MAX_RESTORE_IDS = MAX_RESTORE_IDS; 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;
|
|
6007
6108
|
//# sourceMappingURL=index.cjs.map
|