@maximem/synap-js-sdk 0.5.17 → 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/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.17";
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.17";
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
@@ -1791,7 +1791,8 @@ function jsonOrText(value) {
1791
1791
  }
1792
1792
  }
1793
1793
  }
1794
- function createInstanceNamespace(credentials, cache, onTurn, agentModel = () => ({}), onToolResult) {
1794
+ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () => ({}), onToolResult, checkCustomerId3 = async () => {
1795
+ }) {
1795
1796
  let client = null;
1796
1797
  const openSessions = /* @__PURE__ */ new Map();
1797
1798
  let dispatchCompaction = null;
@@ -1850,7 +1851,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1850
1851
  onListen?.();
1851
1852
  } catch {
1852
1853
  }
1853
- const { GrpcStreamClient } = await import("./stream-client-ZBCKRU7S.js");
1854
+ const { GrpcStreamClient } = await import("./stream-client-2UMDGCMQ.js");
1854
1855
  const onContext = options.on_context ?? options.onContext;
1855
1856
  const onDisconnect = options.on_disconnect ?? options.onDisconnect;
1856
1857
  const onReconnect = options.on_reconnect ?? options.onReconnect;
@@ -1914,16 +1915,20 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1914
1915
  }
1915
1916
  },
1916
1917
  async send_message(options) {
1918
+ await checkCustomerId3(
1919
+ options.customer_id ?? options.customerId,
1920
+ "instance.send_message"
1921
+ );
1917
1922
  if (client === null) throw new ListeningNotActiveError("Listening is not active");
1918
- if (options.content === void 0) {
1919
- throw new ListeningNotActiveError("content is required");
1920
- }
1921
1923
  const eventType = options.event_type ?? options.eventType ?? "user_message";
1922
1924
  if (!KNOWN_EVENT_TYPES.has(eventType)) {
1923
- throw new SynapError(
1925
+ throw new InvalidInputError(
1924
1926
  `unknown event_type '${eventType}'. Expected one of: ` + [...KNOWN_EVENT_TYPES].sort().join(", ")
1925
1927
  );
1926
1928
  }
1929
+ if (options.content === void 0 || options.content === null) {
1930
+ throw new InvalidInputError("content is required");
1931
+ }
1927
1932
  const conversationId = options.conversation_id ?? options.conversationId ?? "";
1928
1933
  ensureSession(
1929
1934
  conversationId,
@@ -1956,7 +1961,13 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1956
1961
  tool_result_json: toolResultJson(options.tool_result ?? options.toolResult),
1957
1962
  tool_call_id: options.tool_call_id ?? options.toolCallId ?? "",
1958
1963
  search_queries: options.search_queries ?? options.searchQueries ?? [],
1959
- 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
+ })()
1960
1971
  });
1961
1972
  },
1962
1973
  async record_tool_call(options) {
@@ -2029,7 +2040,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
2029
2040
  }
2030
2041
 
2031
2042
  // src/version.ts
2032
- var SDK_VERSION = "0.5.17";
2043
+ var SDK_VERSION = "0.5.18";
2033
2044
 
2034
2045
  // src/registry.ts
2035
2046
  var instances = /* @__PURE__ */ new Map();
@@ -3944,7 +3955,8 @@ var SynapClient = class _SynapClient {
3944
3955
  this.#shortTerm.appendTurn(conversationId, role, content);
3945
3956
  },
3946
3957
  () => this.#agentModel,
3947
- ({ 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)
3948
3960
  );
3949
3961
  this.instance._internal.setOnListen(() => this.#startLocalModel());
3950
3962
  this.instance._internal.setCompactionApplier((bundle) => {