@usewhisper/sdk 3.10.1 → 3.11.0

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.
@@ -2236,6 +2236,16 @@ function classifyRuntimeErrorCode(error) {
2236
2236
  if (error.code === "PROJECT_NOT_FOUND" || error.code === "NOT_FOUND") return "PROJECT_NOT_FOUND";
2237
2237
  return "REQUEST_FAILED";
2238
2238
  }
2239
+ function detectSourceType(url) {
2240
+ const ghMatch = url.match(/github\.com\/([^/?#]+)\/([^/?#]+)/);
2241
+ if (ghMatch) {
2242
+ const [, owner, repo] = ghMatch;
2243
+ return { type: "github", owner, repo: repo.replace(/\.git$/, "") };
2244
+ }
2245
+ if (/youtube\.com|youtu\.be|loom\.com/.test(url)) return { type: "video" };
2246
+ if (/\.pdf(\?|$)/.test(url)) return { type: "pdf" };
2247
+ return { type: "web" };
2248
+ }
2239
2249
  var WhisperClient = class _WhisperClient {
2240
2250
  constructor(config) {
2241
2251
  this.config = config;
@@ -2762,7 +2772,14 @@ var WhisperClient = class _WhisperClient {
2762
2772
  }
2763
2773
  async query(params) {
2764
2774
  return this.runOrThrow(async () => {
2765
- const identityParams = await this.withIdentity(params);
2775
+ const { q, userId, ...rest } = params;
2776
+ const normalized = {
2777
+ ...rest,
2778
+ query: rest.query ?? q ?? "",
2779
+ user_id: rest.user_id ?? userId,
2780
+ include_memories: rest.include_memories ?? true
2781
+ };
2782
+ const identityParams = await this.withIdentity(normalized);
2766
2783
  const project = (await this.resolveProject(identityParams.project)).id;
2767
2784
  const response = await this.runtimeClient.request({
2768
2785
  endpoint: "/v1/context/query",
@@ -2777,6 +2794,40 @@ var WhisperClient = class _WhisperClient {
2777
2794
  return response.data;
2778
2795
  });
2779
2796
  }
2797
+ async remember(params) {
2798
+ if (!params.userId && !this.getIdentity) {
2799
+ throw new WhisperError({
2800
+ code: "AUTH_IDENTITY_REQUIRED",
2801
+ message: "remember() requires userId or a getIdentity() resolver on the client.",
2802
+ retryable: false,
2803
+ hint: "Pass userId in the call or configure getIdentity() in WhisperClient."
2804
+ });
2805
+ }
2806
+ const sessionId = params.sessionId ?? (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `session_${Math.random().toString(36).slice(2, 11)}`);
2807
+ return this.learn({
2808
+ mode: "conversation",
2809
+ project: params.project,
2810
+ user_id: params.userId,
2811
+ session_id: sessionId,
2812
+ messages: params.messages
2813
+ });
2814
+ }
2815
+ async ingest(params) {
2816
+ const detected = detectSourceType(params.url);
2817
+ return this.learn({
2818
+ mode: "source",
2819
+ project: params.project,
2820
+ type: detected.type,
2821
+ url: params.url,
2822
+ name: params.name,
2823
+ token: params.token,
2824
+ ...detected.owner ? { owner: detected.owner } : {},
2825
+ ...detected.repo ? { repo: detected.repo } : {}
2826
+ });
2827
+ }
2828
+ async userProfile(userId) {
2829
+ return this.memory.getUserProfile({ user_id: userId });
2830
+ }
2780
2831
  async ingestSession(params) {
2781
2832
  return this.runOrThrow(async () => {
2782
2833
  const identityParams = await this.withIdentity(params);