@usewhisper/sdk 3.4.0 → 3.5.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.
Files changed (5) hide show
  1. package/index.d.mts +242 -1
  2. package/index.d.ts +242 -1
  3. package/index.js +755 -11
  4. package/index.mjs +755 -11
  5. package/package.json +1 -1
package/index.d.mts CHANGED
@@ -618,6 +618,217 @@ declare class AnalyticsModule {
618
618
  queueStatus(): WriteQueueStatus;
619
619
  }
620
620
 
621
+ interface AgentRunContext {
622
+ workspacePath?: string;
623
+ project?: string;
624
+ userId?: string;
625
+ sessionId?: string;
626
+ traceId?: string;
627
+ clientName?: string;
628
+ }
629
+ interface TurnInput {
630
+ userMessage: string;
631
+ taskSummary?: string;
632
+ touchedFiles?: string[];
633
+ toolContext?: string;
634
+ }
635
+ type WorkEventKind = "decision" | "constraint" | "outcome" | "failure" | "task_update" | "file_edit" | "tool_result";
636
+ type WorkEventSalience = "low" | "medium" | "high";
637
+ interface WorkEvent {
638
+ kind: WorkEventKind;
639
+ summary: string;
640
+ details?: string;
641
+ salience?: WorkEventSalience;
642
+ timestamp?: string;
643
+ filePaths?: string[];
644
+ toolName?: string;
645
+ success?: boolean;
646
+ }
647
+ interface PreparedTurn {
648
+ scope: AgentRunContext & {
649
+ project: string;
650
+ userId: string;
651
+ sessionId: string;
652
+ };
653
+ retrieval: {
654
+ primaryQuery: string;
655
+ taskFrameQuery: string | null;
656
+ warnings: string[];
657
+ degraded: boolean;
658
+ degradedReason?: string;
659
+ durationMs: number;
660
+ targetBudgetMs: number;
661
+ hardTimeoutMs: number;
662
+ branchStatus: Record<string, "ok" | "error" | "timeout" | "skipped">;
663
+ };
664
+ context: string;
665
+ items: Array<{
666
+ id: string;
667
+ content: string;
668
+ type: "project" | "memory";
669
+ score: number;
670
+ sourceQuery: "primary" | "task_frame" | "bootstrap";
671
+ metadata?: Record<string, unknown>;
672
+ }>;
673
+ }
674
+ interface TurnCaptureResult {
675
+ success: boolean;
676
+ sessionIngested: boolean;
677
+ memoriesCreated: number;
678
+ relationsCreated: number;
679
+ invalidatedCount: number;
680
+ mergedCount: number;
681
+ droppedCount: number;
682
+ warnings: string[];
683
+ }
684
+ interface AgentRuntimeStatus {
685
+ clientName: string;
686
+ scope: {
687
+ project?: string;
688
+ userId?: string;
689
+ sessionId?: string;
690
+ source?: "explicit" | "workspace" | "config" | "generated";
691
+ warning?: string;
692
+ };
693
+ queue: {
694
+ queued: number;
695
+ flushing: boolean;
696
+ lastFlushAt?: string;
697
+ lastFlushCount: number;
698
+ };
699
+ retrieval: PreparedTurn["retrieval"] | null;
700
+ counters: {
701
+ mergedCount: number;
702
+ droppedCount: number;
703
+ bufferedLowSalience: number;
704
+ };
705
+ }
706
+ interface AgentRuntimeOptions extends AgentRunContext {
707
+ topK?: number;
708
+ maxTokens?: number;
709
+ targetRetrievalMs?: number;
710
+ hardRetrievalTimeoutMs?: number;
711
+ bindingStorePath?: string;
712
+ recentWorkLimit?: number;
713
+ }
714
+ interface QueueStatus {
715
+ queued: number;
716
+ flushing: boolean;
717
+ lastFlushAt?: string;
718
+ lastFlushCount: number;
719
+ }
720
+ interface RuntimeAdapter {
721
+ resolveProject(project?: string): Promise<Project>;
722
+ query(params: QueryParams): Promise<QueryResult>;
723
+ ingestSession(params: {
724
+ project?: string;
725
+ session_id: string;
726
+ user_id?: string;
727
+ messages: Array<{
728
+ role: string;
729
+ content: string;
730
+ timestamp: string;
731
+ }>;
732
+ async?: boolean;
733
+ write_mode?: "async" | "sync";
734
+ }): Promise<{
735
+ success: boolean;
736
+ memories_created: number;
737
+ relations_created: number;
738
+ memories_invalidated: number;
739
+ errors?: string[];
740
+ } & MemoryWriteAck$1>;
741
+ getSessionMemories(params: {
742
+ project?: string;
743
+ session_id: string;
744
+ include_pending?: boolean;
745
+ limit?: number;
746
+ }): Promise<{
747
+ memories: Array<Record<string, unknown>>;
748
+ count: number;
749
+ }>;
750
+ getUserProfile(params: {
751
+ project?: string;
752
+ user_id: string;
753
+ include_pending?: boolean;
754
+ memory_types?: string;
755
+ }): Promise<{
756
+ user_id: string;
757
+ memories: Array<Record<string, unknown>>;
758
+ count: number;
759
+ }>;
760
+ searchMemories(params: {
761
+ project?: string;
762
+ query: string;
763
+ user_id?: string;
764
+ session_id?: string;
765
+ top_k?: number;
766
+ memory_type?: MemoryKind$1;
767
+ profile?: "fast" | "balanced" | "quality";
768
+ include_pending?: boolean;
769
+ }): Promise<MemorySearchResponse$1>;
770
+ addMemory(params: {
771
+ project?: string;
772
+ content: string;
773
+ memory_type?: MemoryKind$1;
774
+ user_id?: string;
775
+ session_id?: string;
776
+ importance?: number;
777
+ confidence?: number;
778
+ metadata?: Record<string, unknown>;
779
+ event_date?: string;
780
+ write_mode?: "async" | "sync";
781
+ async?: boolean;
782
+ }): Promise<MemoryWriteAck$1>;
783
+ queueStatus(): QueueStatus;
784
+ flushQueue(): Promise<void>;
785
+ }
786
+ declare class WhisperAgentRuntime {
787
+ private readonly args;
788
+ private readonly bindingStore;
789
+ private readonly topK;
790
+ private readonly maxTokens;
791
+ private readonly targetRetrievalMs;
792
+ private readonly hardRetrievalTimeoutMs;
793
+ private readonly recentWorkLimit;
794
+ private readonly baseContext;
795
+ private readonly clientName;
796
+ private bindings;
797
+ private touchedFiles;
798
+ private recentWork;
799
+ private bufferedLowSalience;
800
+ private lastPreparedTurn;
801
+ private mergedCount;
802
+ private droppedCount;
803
+ private lastScope;
804
+ constructor(args: {
805
+ baseContext: AgentRunContext;
806
+ options: AgentRuntimeOptions;
807
+ adapter: RuntimeAdapter;
808
+ });
809
+ private getBindings;
810
+ private pushTouchedFiles;
811
+ private pushWorkEvent;
812
+ private makeTaskFrameQuery;
813
+ private resolveScope;
814
+ private runBranch;
815
+ private contextItems;
816
+ private memoryItems;
817
+ private rerank;
818
+ private buildContext;
819
+ bootstrap(context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
820
+ beforeTurn(input: TurnInput, context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
821
+ recordWork(event: WorkEvent, context?: Partial<AgentRunContext>): Promise<MemoryWriteAck$1 | {
822
+ success: true;
823
+ buffered: true;
824
+ }>;
825
+ afterTurn(input: TurnInput & {
826
+ assistantMessage: string;
827
+ }, context?: Partial<AgentRunContext>): Promise<TurnCaptureResult>;
828
+ flush(reason?: string, context?: Partial<AgentRunContext>): Promise<AgentRuntimeStatus>;
829
+ status(): AgentRuntimeStatus;
830
+ }
831
+
621
832
  interface WhisperClientConfig {
622
833
  apiKey: string;
623
834
  baseUrl?: string;
@@ -711,8 +922,38 @@ declare class WhisperClient {
711
922
  private readonly sessionModule;
712
923
  private readonly profileModule;
713
924
  private readonly analyticsModule;
925
+ private readonly projectRefToId;
926
+ private projectCache;
927
+ private projectCacheExpiresAt;
714
928
  constructor(config: WhisperClientConfig);
715
929
  static fromEnv(overrides?: Partial<WhisperClientConfig>): WhisperClient;
930
+ private createQueueStore;
931
+ private defaultQueuePersistence;
932
+ private defaultQueueFilePath;
933
+ private getRequiredProject;
934
+ private refreshProjectCache;
935
+ private fetchResolvedProject;
936
+ resolveProject(projectRef?: string): Promise<Project>;
937
+ query(params: QueryParams): Promise<QueryResult>;
938
+ ingestSession(params: {
939
+ project?: string;
940
+ session_id: string;
941
+ user_id?: string;
942
+ messages: Array<{
943
+ role: string;
944
+ content: string;
945
+ timestamp: string;
946
+ }>;
947
+ async?: boolean;
948
+ write_mode?: "async" | "sync";
949
+ }): Promise<{
950
+ success: boolean;
951
+ memories_created: number;
952
+ relations_created: number;
953
+ memories_invalidated: number;
954
+ errors?: string[];
955
+ } & MemoryWriteAck$1>;
956
+ createAgentRuntime(options?: AgentRuntimeOptions): WhisperAgentRuntime;
716
957
  withRunContext(context: RunContext): {
717
958
  memory: {
718
959
  add: (params: Omit<Parameters<MemoryModule["add"]>[0], "project" | "user_id" | "session_id"> & {
@@ -1814,4 +2055,4 @@ declare class WhisperContext {
1814
2055
  };
1815
2056
  }
1816
2057
 
1817
- export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
2058
+ export { type AgentRunContext, type AgentRuntimeOptions, type AgentRuntimeStatus, type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type PreparedTurn, type Project, type QueryParams, type QueryResult, type Source, type TurnCaptureResult, type TurnInput, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, type WorkEvent, type WorkEventKind, type WorkEventSalience, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
package/index.d.ts CHANGED
@@ -618,6 +618,217 @@ declare class AnalyticsModule {
618
618
  queueStatus(): WriteQueueStatus;
619
619
  }
620
620
 
621
+ interface AgentRunContext {
622
+ workspacePath?: string;
623
+ project?: string;
624
+ userId?: string;
625
+ sessionId?: string;
626
+ traceId?: string;
627
+ clientName?: string;
628
+ }
629
+ interface TurnInput {
630
+ userMessage: string;
631
+ taskSummary?: string;
632
+ touchedFiles?: string[];
633
+ toolContext?: string;
634
+ }
635
+ type WorkEventKind = "decision" | "constraint" | "outcome" | "failure" | "task_update" | "file_edit" | "tool_result";
636
+ type WorkEventSalience = "low" | "medium" | "high";
637
+ interface WorkEvent {
638
+ kind: WorkEventKind;
639
+ summary: string;
640
+ details?: string;
641
+ salience?: WorkEventSalience;
642
+ timestamp?: string;
643
+ filePaths?: string[];
644
+ toolName?: string;
645
+ success?: boolean;
646
+ }
647
+ interface PreparedTurn {
648
+ scope: AgentRunContext & {
649
+ project: string;
650
+ userId: string;
651
+ sessionId: string;
652
+ };
653
+ retrieval: {
654
+ primaryQuery: string;
655
+ taskFrameQuery: string | null;
656
+ warnings: string[];
657
+ degraded: boolean;
658
+ degradedReason?: string;
659
+ durationMs: number;
660
+ targetBudgetMs: number;
661
+ hardTimeoutMs: number;
662
+ branchStatus: Record<string, "ok" | "error" | "timeout" | "skipped">;
663
+ };
664
+ context: string;
665
+ items: Array<{
666
+ id: string;
667
+ content: string;
668
+ type: "project" | "memory";
669
+ score: number;
670
+ sourceQuery: "primary" | "task_frame" | "bootstrap";
671
+ metadata?: Record<string, unknown>;
672
+ }>;
673
+ }
674
+ interface TurnCaptureResult {
675
+ success: boolean;
676
+ sessionIngested: boolean;
677
+ memoriesCreated: number;
678
+ relationsCreated: number;
679
+ invalidatedCount: number;
680
+ mergedCount: number;
681
+ droppedCount: number;
682
+ warnings: string[];
683
+ }
684
+ interface AgentRuntimeStatus {
685
+ clientName: string;
686
+ scope: {
687
+ project?: string;
688
+ userId?: string;
689
+ sessionId?: string;
690
+ source?: "explicit" | "workspace" | "config" | "generated";
691
+ warning?: string;
692
+ };
693
+ queue: {
694
+ queued: number;
695
+ flushing: boolean;
696
+ lastFlushAt?: string;
697
+ lastFlushCount: number;
698
+ };
699
+ retrieval: PreparedTurn["retrieval"] | null;
700
+ counters: {
701
+ mergedCount: number;
702
+ droppedCount: number;
703
+ bufferedLowSalience: number;
704
+ };
705
+ }
706
+ interface AgentRuntimeOptions extends AgentRunContext {
707
+ topK?: number;
708
+ maxTokens?: number;
709
+ targetRetrievalMs?: number;
710
+ hardRetrievalTimeoutMs?: number;
711
+ bindingStorePath?: string;
712
+ recentWorkLimit?: number;
713
+ }
714
+ interface QueueStatus {
715
+ queued: number;
716
+ flushing: boolean;
717
+ lastFlushAt?: string;
718
+ lastFlushCount: number;
719
+ }
720
+ interface RuntimeAdapter {
721
+ resolveProject(project?: string): Promise<Project>;
722
+ query(params: QueryParams): Promise<QueryResult>;
723
+ ingestSession(params: {
724
+ project?: string;
725
+ session_id: string;
726
+ user_id?: string;
727
+ messages: Array<{
728
+ role: string;
729
+ content: string;
730
+ timestamp: string;
731
+ }>;
732
+ async?: boolean;
733
+ write_mode?: "async" | "sync";
734
+ }): Promise<{
735
+ success: boolean;
736
+ memories_created: number;
737
+ relations_created: number;
738
+ memories_invalidated: number;
739
+ errors?: string[];
740
+ } & MemoryWriteAck$1>;
741
+ getSessionMemories(params: {
742
+ project?: string;
743
+ session_id: string;
744
+ include_pending?: boolean;
745
+ limit?: number;
746
+ }): Promise<{
747
+ memories: Array<Record<string, unknown>>;
748
+ count: number;
749
+ }>;
750
+ getUserProfile(params: {
751
+ project?: string;
752
+ user_id: string;
753
+ include_pending?: boolean;
754
+ memory_types?: string;
755
+ }): Promise<{
756
+ user_id: string;
757
+ memories: Array<Record<string, unknown>>;
758
+ count: number;
759
+ }>;
760
+ searchMemories(params: {
761
+ project?: string;
762
+ query: string;
763
+ user_id?: string;
764
+ session_id?: string;
765
+ top_k?: number;
766
+ memory_type?: MemoryKind$1;
767
+ profile?: "fast" | "balanced" | "quality";
768
+ include_pending?: boolean;
769
+ }): Promise<MemorySearchResponse$1>;
770
+ addMemory(params: {
771
+ project?: string;
772
+ content: string;
773
+ memory_type?: MemoryKind$1;
774
+ user_id?: string;
775
+ session_id?: string;
776
+ importance?: number;
777
+ confidence?: number;
778
+ metadata?: Record<string, unknown>;
779
+ event_date?: string;
780
+ write_mode?: "async" | "sync";
781
+ async?: boolean;
782
+ }): Promise<MemoryWriteAck$1>;
783
+ queueStatus(): QueueStatus;
784
+ flushQueue(): Promise<void>;
785
+ }
786
+ declare class WhisperAgentRuntime {
787
+ private readonly args;
788
+ private readonly bindingStore;
789
+ private readonly topK;
790
+ private readonly maxTokens;
791
+ private readonly targetRetrievalMs;
792
+ private readonly hardRetrievalTimeoutMs;
793
+ private readonly recentWorkLimit;
794
+ private readonly baseContext;
795
+ private readonly clientName;
796
+ private bindings;
797
+ private touchedFiles;
798
+ private recentWork;
799
+ private bufferedLowSalience;
800
+ private lastPreparedTurn;
801
+ private mergedCount;
802
+ private droppedCount;
803
+ private lastScope;
804
+ constructor(args: {
805
+ baseContext: AgentRunContext;
806
+ options: AgentRuntimeOptions;
807
+ adapter: RuntimeAdapter;
808
+ });
809
+ private getBindings;
810
+ private pushTouchedFiles;
811
+ private pushWorkEvent;
812
+ private makeTaskFrameQuery;
813
+ private resolveScope;
814
+ private runBranch;
815
+ private contextItems;
816
+ private memoryItems;
817
+ private rerank;
818
+ private buildContext;
819
+ bootstrap(context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
820
+ beforeTurn(input: TurnInput, context?: Partial<AgentRunContext>): Promise<PreparedTurn>;
821
+ recordWork(event: WorkEvent, context?: Partial<AgentRunContext>): Promise<MemoryWriteAck$1 | {
822
+ success: true;
823
+ buffered: true;
824
+ }>;
825
+ afterTurn(input: TurnInput & {
826
+ assistantMessage: string;
827
+ }, context?: Partial<AgentRunContext>): Promise<TurnCaptureResult>;
828
+ flush(reason?: string, context?: Partial<AgentRunContext>): Promise<AgentRuntimeStatus>;
829
+ status(): AgentRuntimeStatus;
830
+ }
831
+
621
832
  interface WhisperClientConfig {
622
833
  apiKey: string;
623
834
  baseUrl?: string;
@@ -711,8 +922,38 @@ declare class WhisperClient {
711
922
  private readonly sessionModule;
712
923
  private readonly profileModule;
713
924
  private readonly analyticsModule;
925
+ private readonly projectRefToId;
926
+ private projectCache;
927
+ private projectCacheExpiresAt;
714
928
  constructor(config: WhisperClientConfig);
715
929
  static fromEnv(overrides?: Partial<WhisperClientConfig>): WhisperClient;
930
+ private createQueueStore;
931
+ private defaultQueuePersistence;
932
+ private defaultQueueFilePath;
933
+ private getRequiredProject;
934
+ private refreshProjectCache;
935
+ private fetchResolvedProject;
936
+ resolveProject(projectRef?: string): Promise<Project>;
937
+ query(params: QueryParams): Promise<QueryResult>;
938
+ ingestSession(params: {
939
+ project?: string;
940
+ session_id: string;
941
+ user_id?: string;
942
+ messages: Array<{
943
+ role: string;
944
+ content: string;
945
+ timestamp: string;
946
+ }>;
947
+ async?: boolean;
948
+ write_mode?: "async" | "sync";
949
+ }): Promise<{
950
+ success: boolean;
951
+ memories_created: number;
952
+ relations_created: number;
953
+ memories_invalidated: number;
954
+ errors?: string[];
955
+ } & MemoryWriteAck$1>;
956
+ createAgentRuntime(options?: AgentRuntimeOptions): WhisperAgentRuntime;
716
957
  withRunContext(context: RunContext): {
717
958
  memory: {
718
959
  add: (params: Omit<Parameters<MemoryModule["add"]>[0], "project" | "user_id" | "session_id"> & {
@@ -1814,4 +2055,4 @@ declare class WhisperContext {
1814
2055
  };
1815
2056
  }
1816
2057
 
1817
- export { type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type Project, type QueryParams, type QueryResult, type Source, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };
2058
+ export { type AgentRunContext, type AgentRuntimeOptions, type AgentRuntimeStatus, type CanonicalSourceCreateParams, type CanonicalSourceCreateResult, type CanonicalSourceType, type ExtractedMemory, LangChainMemoryAdapter, LangGraphCheckpointAdapter, type Memory, type MemoryExtractionResult, type MemoryKind, type MemoryLatencyBreakdown, type MemorySearchResponse, type MemoryWriteAck, type MemoryWriteResult, type PreparedTurn, type Project, type QueryParams, type QueryResult, type Source, type TurnCaptureResult, type TurnInput, type VideoIngestionStatus, type VideoSourceMetadata, Whisper, WhisperAgentMiddleware, WhisperClient, type WhisperConfig, WhisperContext, Whisper as WhisperDefault, WhisperError, type WhisperErrorCode, WhisperClient as WhisperRuntimeClient, type WorkEvent, type WorkEventKind, type WorkEventSalience, createAgentMiddleware, createLangChainMemoryAdapter, createLangGraphCheckpointAdapter, WhisperContext as default, memoryGraphToMermaid };