@maximem/synap-js-sdk 0.5.16 → 0.5.18
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-LJ66WCV3.js → chunk-5G3FNDB3.js} +3 -1
- package/dist/chunk-5G3FNDB3.js.map +1 -0
- package/dist/{chunk-QHPVLTQ7.cjs → chunk-CBK3H2LU.cjs} +9 -7
- package/dist/chunk-CBK3H2LU.cjs.map +1 -0
- package/dist/grpc/index.cjs +3 -3
- package/dist/grpc/index.d.cts +2 -0
- package/dist/grpc/index.d.ts +2 -0
- package/dist/grpc/index.js +2 -2
- package/dist/index.cjs +29 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +29 -11
- package/dist/index.js.map +1 -1
- package/dist/{stream-client-ZBCKRU7S.js → stream-client-2UMDGCMQ.js} +2 -2
- package/dist/stream-client-FKKCBVCB.cjs +16 -0
- package/dist/{stream-client-5GYUWETN.cjs.map → stream-client-FKKCBVCB.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/chunk-LJ66WCV3.js.map +0 -1
- package/dist/chunk-QHPVLTQ7.cjs.map +0 -1
- package/dist/stream-client-5GYUWETN.cjs +0 -16
- /package/dist/{stream-client-ZBCKRU7S.js.map → stream-client-2UMDGCMQ.js.map} +0 -0
package/dist/index.d.cts
CHANGED
|
@@ -1309,6 +1309,12 @@ interface SendMessageOptions {
|
|
|
1309
1309
|
searchQueries?: string[];
|
|
1310
1310
|
context_types?: string[];
|
|
1311
1311
|
contextTypes?: string[];
|
|
1312
|
+
/**
|
|
1313
|
+
* The level of your scope ladder this conversation belongs to. Sent as the
|
|
1314
|
+
* event's `scope`; the server keeps the first one it sees. Since 0.5.18.
|
|
1315
|
+
*/
|
|
1316
|
+
scope_path?: Record<string, string>;
|
|
1317
|
+
scopePath?: Record<string, string>;
|
|
1312
1318
|
}
|
|
1313
1319
|
interface RecordThinkingOptions {
|
|
1314
1320
|
content: string;
|
|
@@ -1879,7 +1885,7 @@ declare class SynapClient {
|
|
|
1879
1885
|
* build when the two disagree, which is the only thing that makes a manual
|
|
1880
1886
|
* publish safe.
|
|
1881
1887
|
*/
|
|
1882
|
-
declare const SDK_VERSION = "0.5.
|
|
1888
|
+
declare const SDK_VERSION = "0.5.18";
|
|
1883
1889
|
|
|
1884
1890
|
/**
|
|
1885
1891
|
* `response_shape: "ranked"`: one list in the order the server ranked it.
|
package/dist/index.d.ts
CHANGED
|
@@ -1309,6 +1309,12 @@ interface SendMessageOptions {
|
|
|
1309
1309
|
searchQueries?: string[];
|
|
1310
1310
|
context_types?: string[];
|
|
1311
1311
|
contextTypes?: string[];
|
|
1312
|
+
/**
|
|
1313
|
+
* The level of your scope ladder this conversation belongs to. Sent as the
|
|
1314
|
+
* event's `scope`; the server keeps the first one it sees. Since 0.5.18.
|
|
1315
|
+
*/
|
|
1316
|
+
scope_path?: Record<string, string>;
|
|
1317
|
+
scopePath?: Record<string, string>;
|
|
1312
1318
|
}
|
|
1313
1319
|
interface RecordThinkingOptions {
|
|
1314
1320
|
content: string;
|
|
@@ -1879,7 +1885,7 @@ declare class SynapClient {
|
|
|
1879
1885
|
* build when the two disagree, which is the only thing that makes a manual
|
|
1880
1886
|
* publish safe.
|
|
1881
1887
|
*/
|
|
1882
|
-
declare const SDK_VERSION = "0.5.
|
|
1888
|
+
declare const SDK_VERSION = "0.5.18";
|
|
1883
1889
|
|
|
1884
1890
|
/**
|
|
1885
1891
|
* `response_shape: "ranked"`: one list in the order the server ranked it.
|
package/dist/index.js
CHANGED
|
@@ -1332,6 +1332,9 @@ function buildRecordMessageBody(options) {
|
|
|
1332
1332
|
if (!conversationId) throw new InvalidInputError("conversation_id is required");
|
|
1333
1333
|
validateConversationId(conversationId);
|
|
1334
1334
|
if (!options.role) throw new InvalidInputError("role is required");
|
|
1335
|
+
if (!MESSAGE_ROLES.includes(options.role)) {
|
|
1336
|
+
throw new InvalidInputError(`Invalid role '${options.role}'. Must be 'user' or 'assistant'.`);
|
|
1337
|
+
}
|
|
1335
1338
|
if (options.content === void 0 || options.content === null) {
|
|
1336
1339
|
throw new InvalidInputError("content is required");
|
|
1337
1340
|
}
|
|
@@ -1346,9 +1349,11 @@ function buildRecordMessageBody(options) {
|
|
|
1346
1349
|
metadata: options.metadata ?? {}
|
|
1347
1350
|
};
|
|
1348
1351
|
const sessionId = either2(o2, "session_id", "sessionId");
|
|
1349
|
-
if (sessionId
|
|
1352
|
+
if (sessionId) body["session_id"] = sessionId;
|
|
1350
1353
|
const scopePath = either2(o2, "scope_path", "scopePath");
|
|
1351
|
-
if (scopePath !== void 0)
|
|
1354
|
+
if (scopePath !== void 0 && scopePath !== null && Object.keys(scopePath).length > 0) {
|
|
1355
|
+
body["scope"] = scopePath;
|
|
1356
|
+
}
|
|
1352
1357
|
return body;
|
|
1353
1358
|
}
|
|
1354
1359
|
function buildIngestTranscriptBody(options) {
|
|
@@ -1448,6 +1453,7 @@ function storedBatchRows(bodies, result) {
|
|
|
1448
1453
|
});
|
|
1449
1454
|
return pairs;
|
|
1450
1455
|
}
|
|
1456
|
+
var MESSAGE_ROLES = ["user", "assistant"];
|
|
1451
1457
|
var PROMPT_STYLES = ["structured", "narrative", "bullet_points"];
|
|
1452
1458
|
function createConversationNamespace(transport, subscribers = new CompactionSubscribers(), onWrite = () => {
|
|
1453
1459
|
}, onTurn = () => {
|
|
@@ -1785,7 +1791,8 @@ function jsonOrText(value) {
|
|
|
1785
1791
|
}
|
|
1786
1792
|
}
|
|
1787
1793
|
}
|
|
1788
|
-
function createInstanceNamespace(credentials, cache, onTurn, agentModel = () => ({}), onToolResult) {
|
|
1794
|
+
function createInstanceNamespace(credentials, cache, onTurn, agentModel = () => ({}), onToolResult, checkCustomerId3 = async () => {
|
|
1795
|
+
}) {
|
|
1789
1796
|
let client = null;
|
|
1790
1797
|
const openSessions = /* @__PURE__ */ new Map();
|
|
1791
1798
|
let dispatchCompaction = null;
|
|
@@ -1844,7 +1851,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1844
1851
|
onListen?.();
|
|
1845
1852
|
} catch {
|
|
1846
1853
|
}
|
|
1847
|
-
const { GrpcStreamClient } = await import("./stream-client-
|
|
1854
|
+
const { GrpcStreamClient } = await import("./stream-client-2UMDGCMQ.js");
|
|
1848
1855
|
const onContext = options.on_context ?? options.onContext;
|
|
1849
1856
|
const onDisconnect = options.on_disconnect ?? options.onDisconnect;
|
|
1850
1857
|
const onReconnect = options.on_reconnect ?? options.onReconnect;
|
|
@@ -1908,16 +1915,20 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1908
1915
|
}
|
|
1909
1916
|
},
|
|
1910
1917
|
async send_message(options) {
|
|
1918
|
+
await checkCustomerId3(
|
|
1919
|
+
options.customer_id ?? options.customerId,
|
|
1920
|
+
"instance.send_message"
|
|
1921
|
+
);
|
|
1911
1922
|
if (client === null) throw new ListeningNotActiveError("Listening is not active");
|
|
1912
|
-
if (options.content === void 0) {
|
|
1913
|
-
throw new ListeningNotActiveError("content is required");
|
|
1914
|
-
}
|
|
1915
1923
|
const eventType = options.event_type ?? options.eventType ?? "user_message";
|
|
1916
1924
|
if (!KNOWN_EVENT_TYPES.has(eventType)) {
|
|
1917
|
-
throw new
|
|
1925
|
+
throw new InvalidInputError(
|
|
1918
1926
|
`unknown event_type '${eventType}'. Expected one of: ` + [...KNOWN_EVENT_TYPES].sort().join(", ")
|
|
1919
1927
|
);
|
|
1920
1928
|
}
|
|
1929
|
+
if (options.content === void 0 || options.content === null) {
|
|
1930
|
+
throw new InvalidInputError("content is required");
|
|
1931
|
+
}
|
|
1921
1932
|
const conversationId = options.conversation_id ?? options.conversationId ?? "";
|
|
1922
1933
|
ensureSession(
|
|
1923
1934
|
conversationId,
|
|
@@ -1950,7 +1961,13 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
1950
1961
|
tool_result_json: toolResultJson(options.tool_result ?? options.toolResult),
|
|
1951
1962
|
tool_call_id: options.tool_call_id ?? options.toolCallId ?? "",
|
|
1952
1963
|
search_queries: options.search_queries ?? options.searchQueries ?? [],
|
|
1953
|
-
context_types: options.context_types ?? options.contextTypes ?? []
|
|
1964
|
+
context_types: options.context_types ?? options.contextTypes ?? [],
|
|
1965
|
+
// The proto's `scope`: the conversation's rung, kept from the first
|
|
1966
|
+
// event that names one. Omitted when absent or empty, as in Python.
|
|
1967
|
+
...(() => {
|
|
1968
|
+
const sp = options.scope_path ?? options.scopePath;
|
|
1969
|
+
return sp && Object.keys(sp).length > 0 ? { scope: sp } : {};
|
|
1970
|
+
})()
|
|
1954
1971
|
});
|
|
1955
1972
|
},
|
|
1956
1973
|
async record_tool_call(options) {
|
|
@@ -2023,7 +2040,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
|
|
|
2023
2040
|
}
|
|
2024
2041
|
|
|
2025
2042
|
// src/version.ts
|
|
2026
|
-
var SDK_VERSION = "0.5.
|
|
2043
|
+
var SDK_VERSION = "0.5.18";
|
|
2027
2044
|
|
|
2028
2045
|
// src/registry.ts
|
|
2029
2046
|
var instances = /* @__PURE__ */ new Map();
|
|
@@ -3938,7 +3955,8 @@ var SynapClient = class _SynapClient {
|
|
|
3938
3955
|
this.#shortTerm.appendTurn(conversationId, role, content);
|
|
3939
3956
|
},
|
|
3940
3957
|
() => this.#agentModel,
|
|
3941
|
-
({ conversationId, result, toolName }) => this.archive_tool_result(conversationId, result, { tool_name: toolName })
|
|
3958
|
+
({ conversationId, result, toolName }) => this.archive_tool_result(conversationId, result, { tool_name: toolName }),
|
|
3959
|
+
(customerId, where) => this.#transport.checkCustomerId(customerId, where)
|
|
3942
3960
|
);
|
|
3943
3961
|
this.instance._internal.setOnListen(() => this.#startLocalModel());
|
|
3944
3962
|
this.instance._internal.setCompactionApplier((bundle) => {
|