@maximem/synap-js-sdk 0.5.10 → 0.5.11

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
@@ -1,5 +1,5 @@
1
- import { E as Encoder, a as AnticipationCacheSnapshot } from './errors-Bdayqlzy.cjs';
2
- export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, i as ExitReason, I as InsufficientCreditsError, j as InvalidConversationIdError, k as InvalidInputError, l as InvalidInstanceIdError, L as ListeningAlreadyActiveError, m as ListeningNotActiveError, n as LookupParams, o as LookupResult, p as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, q as SDKError, r as ServiceUnavailableError, s as SessionExpiredError, t as SnapshotBundle, u as SnapshotItemPreview, v as SnapshotItemRecord, S as SynapError, w as SynapErrorCode, x as SynapErrorOptions, y as SynapPermanentError, z as SynapTransientError, T as TranscriptConflictError, D as TransientError, F as isSynapError } from './errors-Bdayqlzy.cjs';
1
+ import { E as Encoder, a as AnticipationCacheSnapshot } from './errors-BvUA5EW8.cjs';
2
+ export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, i as CustomerIdNotAcceptedError, j as ExitReason, I as InsufficientCreditsError, k as InvalidConversationIdError, l as InvalidInputError, m as InvalidInstanceIdError, L as ListeningAlreadyActiveError, n as ListeningNotActiveError, o as LookupParams, p as LookupResult, q as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, r as SDKError, s as ServiceUnavailableError, t as SessionExpiredError, u as SnapshotBundle, v as SnapshotItemPreview, w as SnapshotItemRecord, S as SynapError, x as SynapErrorCode, y as SynapErrorOptions, z as SynapPermanentError, D as SynapTransientError, T as TranscriptConflictError, F as TransientError, G as isSynapError } from './errors-BvUA5EW8.cjs';
3
3
 
4
4
  /**
5
5
  * AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
@@ -335,8 +335,12 @@ declare class HttpTransport {
335
335
  identityResolver: (() => Promise<void>) | undefined;
336
336
  /** Resolve identity once, before the first request. Never throws. */
337
337
  ready(): Promise<void>;
338
- /** Refuse a customer_id on a B2C instance, at the call site. */
339
- checkCustomerId(customerId: unknown, where: string): void;
338
+ /**
339
+ * Refuse a customer_id on a B2C instance, at the call site. Resolves identity
340
+ * first: the isolation comes from whoami, so on the first call of a client
341
+ * that skipped initialize() the check would otherwise see nothing and pass.
342
+ */
343
+ checkCustomerId(customerId: unknown, where: string): Promise<void>;
340
344
  setTimeouts(timeouts: Partial<TimeoutConfig>): void;
341
345
  /**
342
346
  * `null` DISABLES retries, matching Python.
@@ -1869,7 +1873,7 @@ declare class SynapClient {
1869
1873
  * build when the two disagree, which is the only thing that makes a manual
1870
1874
  * publish safe.
1871
1875
  */
1872
- declare const SDK_VERSION = "0.5.10";
1876
+ declare const SDK_VERSION = "0.5.11";
1873
1877
 
1874
1878
  /**
1875
1879
  * `response_shape: "ranked"`: one list in the order the server ranked it.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { E as Encoder, a as AnticipationCacheSnapshot } from './errors-Bdayqlzy.js';
2
- export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, i as ExitReason, I as InsufficientCreditsError, j as InvalidConversationIdError, k as InvalidInputError, l as InvalidInstanceIdError, L as ListeningAlreadyActiveError, m as ListeningNotActiveError, n as LookupParams, o as LookupResult, p as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, q as SDKError, r as ServiceUnavailableError, s as SessionExpiredError, t as SnapshotBundle, u as SnapshotItemPreview, v as SnapshotItemRecord, S as SynapError, w as SynapErrorCode, x as SynapErrorOptions, y as SynapPermanentError, z as SynapTransientError, T as TranscriptConflictError, D as TransientError, F as isSynapError } from './errors-Bdayqlzy.js';
1
+ import { E as Encoder, a as AnticipationCacheSnapshot } from './errors-BvUA5EW8.js';
2
+ export { b as ANY_SCOPE, c as AgentUnavailableError, A as AnticipationCache, d as AnticipationCacheOptions, e as AuthenticationError, B as BundleItem, C as ConflictError, f as ConnectionError, g as ContextBundle, h as ContextNotFoundError, i as CustomerIdNotAcceptedError, j as ExitReason, I as InsufficientCreditsError, k as InvalidConversationIdError, l as InvalidInputError, m as InvalidInstanceIdError, L as ListeningAlreadyActiveError, n as ListeningNotActiveError, o as LookupParams, p as LookupResult, q as LookupTelemetry, N as NetworkTimeoutError, P as PermanentError, R as RateLimitError, r as SDKError, s as ServiceUnavailableError, t as SessionExpiredError, u as SnapshotBundle, v as SnapshotItemPreview, w as SnapshotItemRecord, S as SynapError, x as SynapErrorCode, y as SynapErrorOptions, z as SynapPermanentError, D as SynapTransientError, T as TranscriptConflictError, F as TransientError, G as isSynapError } from './errors-BvUA5EW8.js';
3
3
 
4
4
  /**
5
5
  * AUTOGENERATED FROM synap/sdk/CONTRACT/endpoints.yaml -- DO NOT EDIT.
@@ -335,8 +335,12 @@ declare class HttpTransport {
335
335
  identityResolver: (() => Promise<void>) | undefined;
336
336
  /** Resolve identity once, before the first request. Never throws. */
337
337
  ready(): Promise<void>;
338
- /** Refuse a customer_id on a B2C instance, at the call site. */
339
- checkCustomerId(customerId: unknown, where: string): void;
338
+ /**
339
+ * Refuse a customer_id on a B2C instance, at the call site. Resolves identity
340
+ * first: the isolation comes from whoami, so on the first call of a client
341
+ * that skipped initialize() the check would otherwise see nothing and pass.
342
+ */
343
+ checkCustomerId(customerId: unknown, where: string): Promise<void>;
340
344
  setTimeouts(timeouts: Partial<TimeoutConfig>): void;
341
345
  /**
342
346
  * `null` DISABLES retries, matching Python.
@@ -1869,7 +1873,7 @@ declare class SynapClient {
1869
1873
  * build when the two disagree, which is the only thing that makes a manual
1870
1874
  * publish safe.
1871
1875
  */
1872
- declare const SDK_VERSION = "0.5.10";
1876
+ declare const SDK_VERSION = "0.5.11";
1873
1877
 
1874
1878
  /**
1875
1879
  * `response_shape: "ranked"`: one list in the order the server ranked it.
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ import {
20
20
  ConflictError,
21
21
  ConnectionError,
22
22
  ContextNotFoundError,
23
+ CustomerIdNotAcceptedError,
23
24
  InsufficientCreditsError,
24
25
  InvalidConversationIdError,
25
26
  InvalidInputError,
@@ -39,7 +40,7 @@ import {
39
40
  TransientError,
40
41
  isSynapError,
41
42
  newCorrelationId
42
- } from "./chunk-BWMPKLFG.js";
43
+ } from "./chunk-4GE7SORD.js";
43
44
 
44
45
  // src/transport/endpoints.ts
45
46
  var ENDPOINTS = {
@@ -194,9 +195,7 @@ var B2C_ISOLATION = "equals_customer";
194
195
  function checkCustomerId(isolation, customerId, where, instanceId) {
195
196
  if (customerId === void 0 || customerId === null || customerId === "") return;
196
197
  if (isolation !== B2C_ISOLATION) return;
197
- throw new InvalidInputError(
198
- `${where}: customer_id is not accepted on this instance${instanceId ? ` (${instanceId})` : ""}, which is B2C (user_context_isolation='${B2C_ISOLATION}'). Send user_id only; it is the whole identity, and the server files and reads your data under it. Received customer_id=${JSON.stringify(customerId)}.`
199
- );
198
+ throw new CustomerIdNotAcceptedError(where, String(customerId), instanceId);
200
199
  }
201
200
 
202
201
  // src/transport/http.ts
@@ -278,8 +277,13 @@ var HttpTransport = class {
278
277
  async ready() {
279
278
  if (this.identityResolver !== void 0) await this.identityResolver();
280
279
  }
281
- /** Refuse a customer_id on a B2C instance, at the call site. */
282
- checkCustomerId(customerId, where) {
280
+ /**
281
+ * Refuse a customer_id on a B2C instance, at the call site. Resolves identity
282
+ * first: the isolation comes from whoami, so on the first call of a client
283
+ * that skipped initialize() the check would otherwise see nothing and pass.
284
+ */
285
+ async checkCustomerId(customerId, where) {
286
+ await this.ready();
283
287
  checkCustomerId(
284
288
  this.userContextIsolation,
285
289
  customerId,
@@ -730,7 +734,7 @@ function retrievalOptionsOf(options) {
730
734
  async function fetchContext(transport, scope, options = {}, hooks = {}) {
731
735
  const startedAt = Date.now();
732
736
  await transport.ready?.();
733
- transport.checkCustomerId(
737
+ await transport.checkCustomerId(
734
738
  opt(options, "customer_id", "customerId"),
735
739
  `${scope}.context.fetch`
736
740
  );
@@ -1078,7 +1082,7 @@ function createMemoriesInterface(transport, onForgotten) {
1078
1082
  return {
1079
1083
  async create(options) {
1080
1084
  const o2 = options;
1081
- transport.checkCustomerId(o2["customer_id"] ?? o2["customerId"], "memories.create");
1085
+ await transport.checkCustomerId(o2["customer_id"] ?? o2["customerId"], "memories.create");
1082
1086
  return transport.request("memories_create", { body: buildCreateBody(options) });
1083
1087
  },
1084
1088
  async batch_create(options) {
@@ -1095,7 +1099,7 @@ function createMemoriesInterface(transport, onForgotten) {
1095
1099
  const userId = options.user_id ?? options.userId;
1096
1100
  const customerId = options.customer_id ?? options.customerId;
1097
1101
  if (!userId) throw new InvalidInputError("user_id is required");
1098
- transport.checkCustomerId(customerId, "memories.create_from_file");
1102
+ await transport.checkCustomerId(customerId, "memories.create_from_file");
1099
1103
  const filePath = options.file_path ?? options.filePath;
1100
1104
  const sources = [filePath, options.file, options.text].filter((v) => v !== void 0);
1101
1105
  if (sources.length === 0) {
@@ -1162,7 +1166,7 @@ function createMemoriesInterface(transport, onForgotten) {
1162
1166
  },
1163
1167
  async forget(options) {
1164
1168
  const o2 = options;
1165
- transport.checkCustomerId(o2["customer_id"] ?? o2["customerId"], "memories.forget");
1169
+ await transport.checkCustomerId(o2["customer_id"] ?? o2["customerId"], "memories.forget");
1166
1170
  const body = buildForgetBody(options);
1167
1171
  const result = await transport.request("memories_forget", { body });
1168
1172
  const removed = !!result?.deleted_ids?.length || result?.status === "deleted" || result?.status === "partial";
@@ -1433,7 +1437,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1433
1437
  };
1434
1438
  return {
1435
1439
  async record_message(options) {
1436
- transport.checkCustomerId(
1440
+ await transport.checkCustomerId(
1437
1441
  options["customer_id"] ?? options["customerId"],
1438
1442
  "conversation.record_message"
1439
1443
  );
@@ -1465,7 +1469,7 @@ function createConversationNamespace(transport, subscribers = new CompactionSubs
1465
1469
  }
1466
1470
  for (const m of messages) {
1467
1471
  const mo = m;
1468
- transport.checkCustomerId(
1472
+ await transport.checkCustomerId(
1469
1473
  mo["customer_id"] ?? mo["customerId"],
1470
1474
  "conversation.record_messages_batch"
1471
1475
  );
@@ -1775,7 +1779,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1775
1779
  onListen?.();
1776
1780
  } catch {
1777
1781
  }
1778
- const { GrpcStreamClient } = await import("./stream-client-3WHXGW4U.js");
1782
+ const { GrpcStreamClient } = await import("./stream-client-ZBCKRU7S.js");
1779
1783
  const onContext = options.on_context ?? options.onContext;
1780
1784
  const onDisconnect = options.on_disconnect ?? options.onDisconnect;
1781
1785
  const onReconnect = options.on_reconnect ?? options.onReconnect;
@@ -1954,7 +1958,7 @@ function createInstanceNamespace(credentials, cache, onTurn, agentModel = () =>
1954
1958
  }
1955
1959
 
1956
1960
  // src/version.ts
1957
- var SDK_VERSION = "0.5.10";
1961
+ var SDK_VERSION = "0.5.11";
1958
1962
 
1959
1963
  // src/registry.ts
1960
1964
  var instances = /* @__PURE__ */ new Map();
@@ -4064,6 +4068,7 @@ var SynapClient = class _SynapClient {
4064
4068
  last_n_conversations: lastNConversations = 1,
4065
4069
  response_shape: responseShape = "by_type"
4066
4070
  } = options;
4071
+ await this.#transport.checkCustomerId(customerId, "sdk.fetch");
4067
4072
  validateConversationId(conversationId);
4068
4073
  responseShapeOf({ response_shape: responseShape });
4069
4074
  const wants = (scope) => scopes === void 0 || scopes.includes(scope);
@@ -4459,6 +4464,7 @@ export {
4459
4464
  ConflictError,
4460
4465
  ConnectionError,
4461
4466
  ContextNotFoundError,
4467
+ CustomerIdNotAcceptedError,
4462
4468
  DEFAULT_BASE_URL,
4463
4469
  DEFAULT_DOCUMENT_TYPE,
4464
4470
  DEFAULT_INGEST_MODE,