@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.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/anish/maximemai/maximem_synap-js-parity/synap/sdk/js/dist/chunk-UXNVTP4D.cjs","../src/errors.ts","../src/util/correlation.ts"],"names":[],"mappings":"AAAA;AC8CA,IAAM,MAAA,kBAAQ,MAAA,CAAO,GAAA,CAAI,kCAAkC,CAAA;AAOpD,IAAM,WAAA,YAAN,MAAA,QAAyB,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAYpC,4BAAgB,UAAA,EAA4B,cAAA;AAAA;AAAA,EAE5C,6BAAgB,YAAA,EAAuB,MAAA;AAAA;AAAA,EAG9B;AAAA,EACA;AAAA,EACA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,QAAA,EAA6B,CAAC,CAAA,EAAG;AAC5D,IAAA,KAAA,CAAM,OAAA,EAAS,OAAA,CAAQ,MAAA,IAAU,KAAA,EAAA,EAAY,EAAE,KAAA,EAAO,OAAA,CAAQ,MAAM,EAAA,EAAI,KAAA,CAAS,CAAA;AACjF,IAAA,MAAM,KAAA,EAAO,GAAA,CAAA,MAAA;AACb,IAAA,IAAA,CAAK,KAAA,EAAO,GAAA,CAAA,MAAA,CAAW,IAAA;AACvB,IAAA,IAAA,CAAK,KAAA,EAAO,IAAA,CAAK,SAAA;AACjB,IAAA,IAAA,CAAK,UAAA,EAAY,IAAA,CAAK,WAAA;AACtB,IAAA,IAAA,CAAK,cAAA,mBAAgB,OAAA,CAAQ,aAAA,UAAiB,MAAA;AAC9C,IAAA,MAAA,CAAO,cAAA,CAAe,IAAA,EAAM,KAAA,EAAO,EAAE,KAAA,EAAO,IAAA,EAAM,UAAA,EAAY,MAAM,CAAC,CAAA;AAGrE,IAAA,MAAA,CAAO,cAAA,CAAe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AAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACA,EAAA;AACF;AAEA;AACM,EAAA;AACJ,EAAA;AACA,EAAA;AACE,IAAA;AACA,IAAA;AACA,IAAA;AACF,EAAA;AACA,EAAA;AACF;AAMa;AACA;AACA;AACA;ADjJN;AACA;AE9KA;AACL,EAAA;AACI,EAAA;AAEA,EAAA;AACF,IAAA;AAGG,IAAA;AACA,IAAA;AACH,IAAA;AACA,IAAA;AACF,EAAA;AAIA,EAAA;AACE,IAAA;AACA,IAAA;AACD,EAAA;AACH;AF0KO;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/anish/maximemai/maximem_synap-js-parity/synap/sdk/js/dist/chunk-UXNVTP4D.cjs","sourcesContent":[null,"/**\n * Synap SDK error taxonomy.\n *\n * Mirrors `maximem_synap/models/errors.py` 1:1, including the four\n * backward-compatibility aliases at the bottom. If you add an error to one\n * SDK, add it to the other in the same change.\n *\n * ## Why every error carries a `.code`\n *\n * This package ships dual ESM + CJS. A consumer whose dependency graph pulls\n * in both formats gets *two* copies of every class in this file, and then:\n *\n * try { ... } catch (e) { if (e instanceof SynapError) { ... } }\n *\n * silently evaluates to `false` against the copy from the other format. Error\n * handling stops working and nothing throws to tell you. `.code` is a plain\n * string, so it is immune. Prefer it at package boundaries:\n *\n * if (isSynapError(e) && e.code === 'rate_limit') { ... }\n *\n * `Symbol.hasInstance` is also wired up on the base class, so `instanceof`\n * works across realms too -- but `.code` is the documented contract.\n */\n\n/** Stable, format-independent discriminators. Never renumber or reuse. */\nexport type SynapErrorCode =\n | 'synap_error'\n | 'transient'\n | 'permanent'\n | 'network_timeout'\n | 'rate_limit'\n | 'insufficient_credits'\n | 'service_unavailable'\n | 'invalid_input'\n | 'invalid_instance_id'\n | 'invalid_conversation_id'\n | 'customer_id_not_accepted'\n | 'authentication'\n | 'context_not_found'\n | 'conflict'\n | 'transcript_conflict'\n | 'session_expired'\n | 'listening_already_active'\n | 'listening_not_active'\n | 'agent_unavailable';\n\nconst BRAND = Symbol.for('@maximem/synap-js-sdk.SynapError');\n\nexport interface SynapErrorOptions {\n correlationId?: string | null;\n cause?: unknown;\n}\n\nexport class SynapError extends Error {\n /**\n * The single declaration site for each subclass's code.\n *\n * It is `static` rather than a class field on purpose. Under\n * `useDefineForClassFields` (the default at our ES2022 target) a class field\n * is an *instance* property, so it is invisible from the constructor object.\n * `Symbol.hasInstance` below only has the constructor to work with, so a\n * field would leave it unable to tell `AuthenticationError` from\n * `RateLimitError` -- it would report every Synap error as an instance of\n * every other one.\n */\n static readonly errorCode: SynapErrorCode = 'synap_error';\n /** True for errors where a retry may succeed. Static for the same reason. */\n static readonly isTransient: boolean = false;\n\n /** Own, enumerable, so logs and JSON.stringify include it. */\n readonly code: SynapErrorCode;\n readonly correlationId: string | null;\n readonly transient: boolean;\n\n constructor(message: string, options: SynapErrorOptions = {}) {\n super(message, options.cause !== undefined ? { cause: options.cause } : undefined);\n const ctor = new.target as typeof SynapError;\n this.name = new.target.name;\n this.code = ctor.errorCode;\n this.transient = ctor.isTransient;\n this.correlationId = options.correlationId ?? null;\n Object.defineProperty(this, BRAND, { value: true, enumerable: false });\n // Without this, subclassing a built-in under a downlevel target breaks the\n // prototype chain and `instanceof` fails even within a single copy.\n Object.setPrototypeOf(this, new.target.prototype);\n }\n\n static override [Symbol.hasInstance](instance: unknown): boolean {\n if (instance === null || typeof instance !== 'object') return false;\n // Cross-realm / dual-format tolerant: identify by brand, then narrow by the\n // subclass's own code so `e instanceof RateLimitError` stays meaningful.\n if (!(BRAND in instance)) return false;\n const expected = (this as unknown as { errorCode?: SynapErrorCode }).errorCode;\n // Called on something that is not one of our classes: fall back to the brand.\n if (expected === undefined) return true;\n // Everything branded descends from the root.\n if (expected === 'synap_error') return true;\n const actual = (instance as { code?: string }).code;\n return actual === expected || descendsFrom(actual, expected);\n }\n}\n\n/** Type guard that works across ESM/CJS copies and realms. */\nexport function isSynapError(e: unknown): e is SynapError {\n return typeof e === 'object' && e !== null && BRAND in e;\n}\n\nexport class SynapTransientError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'transient';\n static override readonly isTransient: boolean = true;\n}\n\nexport class SynapPermanentError extends SynapError {\n static override readonly errorCode: SynapErrorCode = 'permanent';\n static override readonly isTransient: boolean = false;\n}\n\n// ─── Transient ────────────────────────────────────────────────────────────────\n\nexport class NetworkTimeoutError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'network_timeout';\n}\n\n/**\n * Rate limit exceeded (HTTP 429, gRPC RESOURCE_EXHAUSTED).\n *\n * Also carries the two credit stops the server reports as 429, because both\n * recover with time or a plan change rather than with a retry of this request:\n * `reason: 'trial_limit_reached'` (the Trial cap is spent, see `upgradeUrl`)\n * and `reason: 'subscription_inactive'` (a paid plan whose subscription is past\n * due, unpaid or cancelled, see `manageUrl`). `reason` is null for an ordinary\n * rate limit and against a server too old to send one.\n */\nexport class RateLimitError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'rate_limit';\n readonly retryAfterSeconds: number | null;\n /** Machine-readable cause, when the stop was a credit stop. */\n readonly reason: string | null;\n /** Where a Trial customer upgrades. Python calls this `upgrade_url`. */\n readonly upgradeUrl: string | null;\n /** Where billing is managed. Python calls this `manage_url`. */\n readonly manageUrl: string | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & {\n retryAfterSeconds?: number | null;\n reason?: string | null;\n upgradeUrl?: string | null;\n manageUrl?: string | null;\n } = {},\n ) {\n super(message, options);\n this.retryAfterSeconds = options.retryAfterSeconds ?? null;\n this.reason = options.reason ?? null;\n this.upgradeUrl = options.upgradeUrl ?? null;\n this.manageUrl = options.manageUrl ?? null;\n }\n}\n\nexport class ServiceUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'service_unavailable';\n}\n\nexport class AgentUnavailableError extends SynapTransientError {\n static override readonly errorCode: SynapErrorCode = 'agent_unavailable';\n constructor(message = 'Agent unavailable', options: SynapErrorOptions = {}) {\n super(message, options);\n }\n}\n\n// ─── Permanent ────────────────────────────────────────────────────────────────\n\n/**\n * The caller's credit wallet cannot cover this request.\n *\n * HTTP 402, and gRPC RESOURCE_EXHAUSTED with credit-related trailing metadata.\n * Permanent by design: retrying without topping up burns quota and never\n * succeeds. This is the error behind \"the agent forgot\" reports where retrieval\n * silently returns nothing.\n */\nexport class InsufficientCreditsError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'insufficient_credits';\n readonly balanceCredits: number | null;\n readonly requiredCredits: number | null;\n /** Where the balance can be viewed. Python calls this `recovery_url`. */\n readonly recoveryUrl: string | null;\n /** Where a redeem code can be entered. Python calls this `redeem_url`. */\n readonly redeemUrl: string | null;\n /**\n * Machine-readable cause. `'overages_disabled'` means the plan is paid and\n * the balance is spent, but the account has not allowed usage past zero, so\n * the work stops until someone allows overages or adds credits. Null when an\n * older server did not send one.\n */\n readonly reason: string | null;\n /** Where that setting and billing are managed. Python calls this `manage_url`. */\n readonly manageUrl: string | null;\n\n constructor(\n message: string,\n options: SynapErrorOptions & {\n balanceCredits?: number | null;\n requiredCredits?: number | null;\n recoveryUrl?: string | null;\n redeemUrl?: string | null;\n reason?: string | null;\n manageUrl?: string | null;\n } = {},\n ) {\n super(message, options);\n this.balanceCredits = options.balanceCredits ?? null;\n this.requiredCredits = options.requiredCredits ?? null;\n this.recoveryUrl = options.recoveryUrl ?? null;\n this.redeemUrl = options.redeemUrl ?? null;\n this.reason = options.reason ?? null;\n this.manageUrl = options.manageUrl ?? null;\n }\n}\n\nexport class InvalidInputError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'invalid_input';\n}\n\n/**\n * Raised by `validateInstanceId` before any network call, matching Python's\n * `utils/validators.py`. The message text is identical in both SDKs.\n */\nexport class InvalidInstanceIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_instance_id';\n}\n\n/** See the note on InvalidInstanceIdError. Raised by `validateConversationId`. */\nexport class InvalidConversationIdError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'invalid_conversation_id';\n}\n\n/**\n * A customer_id passed on a B2C instance, refused before any request.\n * Python raises the same class (`maximem_synap.CustomerIdNotAcceptedError`),\n * also a subclass of InvalidInputError, with the same three fields.\n */\nexport class CustomerIdNotAcceptedError extends InvalidInputError {\n static override readonly errorCode: SynapErrorCode = 'customer_id_not_accepted';\n readonly where: string;\n readonly customerId: string;\n readonly instanceId: string | null;\n\n constructor(where: string, customerId: string, instanceId?: string | null) {\n super(\n `${where}: customer_id is not accepted on this instance` +\n `${instanceId ? ` (${instanceId})` : ''}, which is B2C ` +\n `(user_context_isolation='equals_customer'). Send user_id only; it is the ` +\n `whole identity, and the server files and reads your data under it. ` +\n `Received customer_id=${JSON.stringify(customerId)}.`,\n );\n this.where = where;\n this.customerId = customerId;\n this.instanceId = instanceId ?? null;\n }\n}\n\nexport class AuthenticationError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'authentication';\n}\n\nexport class ContextNotFoundError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'context_not_found';\n}\n\nexport class ConflictError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'conflict';\n}\n\nexport class TranscriptConflictError extends ConflictError {\n static override readonly errorCode: SynapErrorCode = 'transcript_conflict';\n}\n\nexport class SessionExpiredError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'session_expired';\n}\n\nexport class ListeningAlreadyActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_already_active';\n}\n\nexport class ListeningNotActiveError extends SynapPermanentError {\n static override readonly errorCode: SynapErrorCode = 'listening_not_active';\n}\n\n// ─── Hierarchy metadata (drives the cross-copy instanceof above) ──────────────\n\nconst PARENT: Partial<Record<SynapErrorCode, SynapErrorCode>> = {\n transient: 'synap_error',\n permanent: 'synap_error',\n network_timeout: 'transient',\n rate_limit: 'transient',\n service_unavailable: 'transient',\n agent_unavailable: 'transient',\n insufficient_credits: 'permanent',\n invalid_input: 'permanent',\n invalid_instance_id: 'invalid_input',\n invalid_conversation_id: 'invalid_input',\n customer_id_not_accepted: 'invalid_input',\n authentication: 'permanent',\n context_not_found: 'permanent',\n conflict: 'permanent',\n transcript_conflict: 'conflict',\n session_expired: 'permanent',\n listening_already_active: 'permanent',\n listening_not_active: 'permanent',\n};\n\nfunction descendsFrom(actual: string | undefined, expected: string): boolean {\n let cur = actual as SynapErrorCode | undefined;\n const seen = new Set<string>();\n while (cur && !seen.has(cur)) {\n seen.add(cur);\n if (cur === expected) return true;\n cur = PARENT[cur];\n }\n return false;\n}\n\n// ─── Backward-compatibility aliases (mirrors the tail of errors.py) ──────────\n// `ConnectionError` deliberately shadows the global in a module scope. Python\n// does the same thing; keeping the name means ported code reads identically.\n\nexport const SDKError = SynapError;\nexport const TransientError = SynapTransientError;\nexport const PermanentError = SynapPermanentError;\nexport const ConnectionError = NetworkTimeoutError;\n","/**\n * Correlation ID generation.\n *\n * `globalThis.crypto` is unflagged from Node 19 onward and this package\n * declares `engines.node >= 20`, so `randomUUID` is normally present. It is\n * still feature-detected rather than assumed, because `engines` is advisory:\n * npm warns and installs anyway, and the SDK also runs on Workers, Edge and\n * Bun, where the available crypto surface varies.\n *\n * Deliberately does NOT import `node:crypto`. That import is what breaks Edge\n * and Workers builds at bundle time, and a correlation ID is not a security\n * value, so there is nothing to gain from it.\n */\nexport function newCorrelationId(): string {\n const c = globalThis.crypto;\n if (typeof c?.randomUUID === 'function') return c.randomUUID();\n\n if (typeof c?.getRandomValues === 'function') {\n const b = c.getRandomValues(new Uint8Array(16));\n // RFC 4122 version (4) and variant bits. The `?? 0` guards satisfy\n // `noUncheckedIndexedAccess`; a 16-byte array always has these slots.\n b[6] = ((b[6] ?? 0) & 0x0f) | 0x40;\n b[8] = ((b[8] ?? 0) & 0x3f) | 0x80;\n const h = Array.from(b, (x) => x.toString(16).padStart(2, '0')).join('');\n return `${h.slice(0, 8)}-${h.slice(8, 12)}-${h.slice(12, 16)}-${h.slice(16, 20)}-${h.slice(20)}`;\n }\n\n // Last resort. Correlation IDs are for tracing only, never for security, so\n // Math.random is acceptable here and only here.\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (ch) => {\n const r = (Math.random() * 16) | 0;\n return (ch === 'x' ? r : (r & 0x3) | 0x8).toString(16);\n });\n}\n"]}
@@ -318,7 +318,7 @@ declare class AnticipationCache {
318
318
  * works across realms too -- but `.code` is the documented contract.
319
319
  */
320
320
  /** Stable, format-independent discriminators. Never renumber or reuse. */
321
- type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
321
+ type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'customer_id_not_accepted' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
322
322
  interface SynapErrorOptions {
323
323
  correlationId?: string | null;
324
324
  cause?: unknown;
@@ -439,6 +439,18 @@ declare class InvalidInstanceIdError extends InvalidInputError {
439
439
  declare class InvalidConversationIdError extends InvalidInputError {
440
440
  static readonly errorCode: SynapErrorCode;
441
441
  }
442
+ /**
443
+ * A customer_id passed on a B2C instance, refused before any request.
444
+ * Python raises the same class (`maximem_synap.CustomerIdNotAcceptedError`),
445
+ * also a subclass of InvalidInputError, with the same three fields.
446
+ */
447
+ declare class CustomerIdNotAcceptedError extends InvalidInputError {
448
+ static readonly errorCode: SynapErrorCode;
449
+ readonly where: string;
450
+ readonly customerId: string;
451
+ readonly instanceId: string | null;
452
+ constructor(where: string, customerId: string, instanceId?: string | null);
453
+ }
442
454
  declare class AuthenticationError extends SynapPermanentError {
443
455
  static readonly errorCode: SynapErrorCode;
444
456
  }
@@ -465,4 +477,4 @@ declare const TransientError: typeof SynapTransientError;
465
477
  declare const PermanentError: typeof SynapPermanentError;
466
478
  declare const ConnectionError: typeof NetworkTimeoutError;
467
479
 
468
- export { AnticipationCache as A, type BundleItem as B, ConflictError as C, TransientError as D, type Encoder as E, isSynapError as F, InsufficientCreditsError as I, ListeningAlreadyActiveError as L, NetworkTimeoutError as N, PermanentError as P, RateLimitError as R, SynapError as S, TranscriptConflictError as T, type AnticipationCacheSnapshot as a, ANY_SCOPE as b, AgentUnavailableError as c, type AnticipationCacheOptions as d, AuthenticationError as e, ConnectionError as f, type ContextBundle as g, ContextNotFoundError as h, type ExitReason as i, InvalidConversationIdError as j, InvalidInputError as k, InvalidInstanceIdError as l, ListeningNotActiveError as m, type LookupParams as n, type LookupResult as o, type LookupTelemetry as p, SDKError as q, ServiceUnavailableError as r, SessionExpiredError as s, type SnapshotBundle as t, type SnapshotItemPreview as u, type SnapshotItemRecord as v, type SynapErrorCode as w, type SynapErrorOptions as x, SynapPermanentError as y, SynapTransientError as z };
480
+ export { AnticipationCache as A, type BundleItem as B, ConflictError as C, SynapTransientError as D, type Encoder as E, TransientError as F, isSynapError as G, InsufficientCreditsError as I, ListeningAlreadyActiveError as L, NetworkTimeoutError as N, PermanentError as P, RateLimitError as R, SynapError as S, TranscriptConflictError as T, type AnticipationCacheSnapshot as a, ANY_SCOPE as b, AgentUnavailableError as c, type AnticipationCacheOptions as d, AuthenticationError as e, ConnectionError as f, type ContextBundle as g, ContextNotFoundError as h, CustomerIdNotAcceptedError as i, type ExitReason as j, InvalidConversationIdError as k, InvalidInputError as l, InvalidInstanceIdError as m, ListeningNotActiveError as n, type LookupParams as o, type LookupResult as p, type LookupTelemetry as q, SDKError as r, ServiceUnavailableError as s, SessionExpiredError as t, type SnapshotBundle as u, type SnapshotItemPreview as v, type SnapshotItemRecord as w, type SynapErrorCode as x, type SynapErrorOptions as y, SynapPermanentError as z };
@@ -318,7 +318,7 @@ declare class AnticipationCache {
318
318
  * works across realms too -- but `.code` is the documented contract.
319
319
  */
320
320
  /** Stable, format-independent discriminators. Never renumber or reuse. */
321
- type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
321
+ type SynapErrorCode = 'synap_error' | 'transient' | 'permanent' | 'network_timeout' | 'rate_limit' | 'insufficient_credits' | 'service_unavailable' | 'invalid_input' | 'invalid_instance_id' | 'invalid_conversation_id' | 'customer_id_not_accepted' | 'authentication' | 'context_not_found' | 'conflict' | 'transcript_conflict' | 'session_expired' | 'listening_already_active' | 'listening_not_active' | 'agent_unavailable';
322
322
  interface SynapErrorOptions {
323
323
  correlationId?: string | null;
324
324
  cause?: unknown;
@@ -439,6 +439,18 @@ declare class InvalidInstanceIdError extends InvalidInputError {
439
439
  declare class InvalidConversationIdError extends InvalidInputError {
440
440
  static readonly errorCode: SynapErrorCode;
441
441
  }
442
+ /**
443
+ * A customer_id passed on a B2C instance, refused before any request.
444
+ * Python raises the same class (`maximem_synap.CustomerIdNotAcceptedError`),
445
+ * also a subclass of InvalidInputError, with the same three fields.
446
+ */
447
+ declare class CustomerIdNotAcceptedError extends InvalidInputError {
448
+ static readonly errorCode: SynapErrorCode;
449
+ readonly where: string;
450
+ readonly customerId: string;
451
+ readonly instanceId: string | null;
452
+ constructor(where: string, customerId: string, instanceId?: string | null);
453
+ }
442
454
  declare class AuthenticationError extends SynapPermanentError {
443
455
  static readonly errorCode: SynapErrorCode;
444
456
  }
@@ -465,4 +477,4 @@ declare const TransientError: typeof SynapTransientError;
465
477
  declare const PermanentError: typeof SynapPermanentError;
466
478
  declare const ConnectionError: typeof NetworkTimeoutError;
467
479
 
468
- export { AnticipationCache as A, type BundleItem as B, ConflictError as C, TransientError as D, type Encoder as E, isSynapError as F, InsufficientCreditsError as I, ListeningAlreadyActiveError as L, NetworkTimeoutError as N, PermanentError as P, RateLimitError as R, SynapError as S, TranscriptConflictError as T, type AnticipationCacheSnapshot as a, ANY_SCOPE as b, AgentUnavailableError as c, type AnticipationCacheOptions as d, AuthenticationError as e, ConnectionError as f, type ContextBundle as g, ContextNotFoundError as h, type ExitReason as i, InvalidConversationIdError as j, InvalidInputError as k, InvalidInstanceIdError as l, ListeningNotActiveError as m, type LookupParams as n, type LookupResult as o, type LookupTelemetry as p, SDKError as q, ServiceUnavailableError as r, SessionExpiredError as s, type SnapshotBundle as t, type SnapshotItemPreview as u, type SnapshotItemRecord as v, type SynapErrorCode as w, type SynapErrorOptions as x, SynapPermanentError as y, SynapTransientError as z };
480
+ export { AnticipationCache as A, type BundleItem as B, ConflictError as C, SynapTransientError as D, type Encoder as E, TransientError as F, isSynapError as G, InsufficientCreditsError as I, ListeningAlreadyActiveError as L, NetworkTimeoutError as N, PermanentError as P, RateLimitError as R, SynapError as S, TranscriptConflictError as T, type AnticipationCacheSnapshot as a, ANY_SCOPE as b, AgentUnavailableError as c, type AnticipationCacheOptions as d, AuthenticationError as e, ConnectionError as f, type ContextBundle as g, ContextNotFoundError as h, CustomerIdNotAcceptedError as i, type ExitReason as j, InvalidConversationIdError as k, InvalidInputError as l, InvalidInstanceIdError as m, ListeningNotActiveError as n, type LookupParams as o, type LookupResult as p, type LookupTelemetry as q, SDKError as r, ServiceUnavailableError as s, SessionExpiredError as t, type SnapshotBundle as u, type SnapshotItemPreview as v, type SnapshotItemRecord as w, type SynapErrorCode as x, type SynapErrorOptions as y, SynapPermanentError as z };
@@ -1,10 +1,10 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
3
 
4
- var _chunkRE4DDIWOcjs = require('../chunk-RE4DDIWO.cjs');
4
+ var _chunkQHPVLTQ7cjs = require('../chunk-QHPVLTQ7.cjs');
5
5
 
6
6
 
7
- var _chunkT372OL3Qcjs = require('../chunk-T372OL3Q.cjs');
7
+ var _chunkUXNVTP4Dcjs = require('../chunk-UXNVTP4D.cjs');
8
8
 
9
9
  // src/grpc/index.ts
10
10
  async function checkGrpcAvailability() {
@@ -32,20 +32,20 @@ async function checkGrpcAvailability() {
32
32
  }
33
33
  async function listen(options) {
34
34
  if (!options.conversationId) {
35
- throw new (0, _chunkT372OL3Qcjs.ListeningNotActiveError)("conversation_id is required to start a listening stream");
35
+ throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)("conversation_id is required to start a listening stream");
36
36
  }
37
37
  const availability = await checkGrpcAvailability();
38
38
  if (!availability.available) {
39
- throw new (0, _chunkT372OL3Qcjs.ListeningNotActiveError)(availability.detail);
39
+ throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)(availability.detail);
40
40
  }
41
41
  const [{ GrpcStreamClient: StreamClient }, { AnticipationCache }, { getEnv }] = await Promise.all([
42
- Promise.resolve().then(() => _interopRequireWildcard(require("../stream-client-L6OQPZN7.cjs"))),
42
+ Promise.resolve().then(() => _interopRequireWildcard(require("../stream-client-5GYUWETN.cjs"))),
43
43
  Promise.resolve().then(() => _interopRequireWildcard(require("../anticipation-cache-LPNKMRBH.cjs"))),
44
44
  Promise.resolve().then(() => _interopRequireWildcard(require("../env-55ULHNJZ.cjs")))
45
45
  ]);
46
46
  const apiKey = _nullishCoalesce(_nullishCoalesce(options.apiKey, () => ( getEnv("SYNAP_API_KEY"))), () => ( ""));
47
47
  if (apiKey === "") {
48
- throw new (0, _chunkT372OL3Qcjs.ListeningNotActiveError)(
48
+ throw new (0, _chunkUXNVTP4Dcjs.ListeningNotActiveError)(
49
49
  "No Synap API key found. Set SYNAP_API_KEY or pass apiKey."
50
50
  );
51
51
  }
@@ -83,5 +83,5 @@ async function listen(options) {
83
83
 
84
84
 
85
85
 
86
- exports.GrpcStreamClient = _chunkRE4DDIWOcjs.GrpcStreamClient; exports.PROTO_SHA = _chunkRE4DDIWOcjs.PROTO_SHA; exports.checkGrpcAvailability = checkGrpcAvailability; exports.listen = listen;
86
+ exports.GrpcStreamClient = _chunkQHPVLTQ7cjs.GrpcStreamClient; exports.PROTO_SHA = _chunkQHPVLTQ7cjs.PROTO_SHA; exports.checkGrpcAvailability = checkGrpcAvailability; exports.listen = listen;
87
87
  //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,4 @@
1
- import { A as AnticipationCache, S as SynapError } from '../errors-Bdayqlzy.cjs';
1
+ import { A as AnticipationCache, S as SynapError } from '../errors-BvUA5EW8.cjs';
2
2
 
3
3
  /**
4
4
  * Bidirectional gRPC stream client for the Synap anticipation channel.
@@ -1,4 +1,4 @@
1
- import { A as AnticipationCache, S as SynapError } from '../errors-Bdayqlzy.js';
1
+ import { A as AnticipationCache, S as SynapError } from '../errors-BvUA5EW8.js';
2
2
 
3
3
  /**
4
4
  * Bidirectional gRPC stream client for the Synap anticipation channel.
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  GrpcStreamClient,
3
3
  PROTO_SHA
4
- } from "../chunk-I7TWR4S6.js";
4
+ } from "../chunk-LJ66WCV3.js";
5
5
  import {
6
6
  ListeningNotActiveError
7
- } from "../chunk-BWMPKLFG.js";
7
+ } from "../chunk-4GE7SORD.js";
8
8
 
9
9
  // src/grpc/index.ts
10
10
  async function checkGrpcAvailability() {
@@ -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-3WHXGW4U.js"),
42
+ import("../stream-client-ZBCKRU7S.js"),
43
43
  import("../anticipation-cache-RWKF55J4.js"),
44
44
  import("../env-QCUKKW36.js")
45
45
  ]);