@yushaw/sanqian-sdk 0.3.5 → 0.3.7

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.
@@ -455,6 +455,36 @@ interface AgentUpdateConfig {
455
455
  */
456
456
  searchable?: boolean;
457
457
  }
458
+ /**
459
+ * Session resource pushed by an app.
460
+ * Content is provided at push time (not fetched like attached_resources).
461
+ * Global scope - visible in all Chat UI instances, persists until app disconnects.
462
+ */
463
+ interface SessionResource {
464
+ /** Resource ID (auto-generated if not provided) */
465
+ id?: string;
466
+ /** Display title (required) */
467
+ title: string;
468
+ /** Content (required, format controlled by app) */
469
+ content: string;
470
+ /** Optional summary for UI tooltip */
471
+ summary?: string;
472
+ /** Optional icon (emoji or URL) */
473
+ icon?: string;
474
+ /** Optional resource type for styling */
475
+ type?: ResourceType;
476
+ }
477
+ /**
478
+ * Stored session resource with full metadata
479
+ */
480
+ interface StoredSessionResource extends SessionResource {
481
+ /** Full ID: "appName:resourceId" */
482
+ fullId: string;
483
+ /** Source app name */
484
+ appName: string;
485
+ /** Push timestamp (ISO 8601) */
486
+ pushedAt: string;
487
+ }
458
488
  interface SDKEvents {
459
489
  connected: () => void;
460
490
  disconnected: (reason: string) => void;
@@ -464,6 +494,10 @@ interface SDKEvents {
464
494
  name: string;
465
495
  arguments: Record<string, unknown>;
466
496
  }) => void;
497
+ /** Called when a session resource is pushed or updated */
498
+ resourcePushed: (resource: StoredSessionResource) => void;
499
+ /** Called when user removes a session resource from Chat UI */
500
+ resourceRemoved: (resourceId: string) => void;
467
501
  }
468
502
  type SDKEventName = keyof SDKEvents;
469
503
 
package/dist/index.d.mts CHANGED
@@ -575,6 +575,10 @@ interface ListCapabilitiesOptions {
575
575
  source?: string;
576
576
  /** Filter by category (tools only) */
577
577
  category?: string;
578
+ /** SDK app name (for including own private agents) */
579
+ appName?: string;
580
+ /** Agent scope filter: "searchable" (default) or "available" (includes non-searchable but enabled agents) */
581
+ scope?: "searchable" | "available";
578
582
  }
579
583
  /** Options for searching capabilities */
580
584
  interface SearchCapabilitiesOptions {
@@ -585,6 +589,36 @@ interface SearchCapabilitiesOptions {
585
589
  /** Exclude these IDs */
586
590
  exclude?: string[];
587
591
  }
592
+ /**
593
+ * Session resource pushed by an app.
594
+ * Content is provided at push time (not fetched like attached_resources).
595
+ * Global scope - visible in all Chat UI instances, persists until app disconnects.
596
+ */
597
+ interface SessionResource {
598
+ /** Resource ID (auto-generated if not provided) */
599
+ id?: string;
600
+ /** Display title (required) */
601
+ title: string;
602
+ /** Content (required, format controlled by app) */
603
+ content: string;
604
+ /** Optional summary for UI tooltip */
605
+ summary?: string;
606
+ /** Optional icon (emoji or URL) */
607
+ icon?: string;
608
+ /** Optional resource type for styling */
609
+ type?: ResourceType;
610
+ }
611
+ /**
612
+ * Stored session resource with full metadata
613
+ */
614
+ interface StoredSessionResource extends SessionResource {
615
+ /** Full ID: "appName:resourceId" */
616
+ fullId: string;
617
+ /** Source app name */
618
+ appName: string;
619
+ /** Push timestamp (ISO 8601) */
620
+ pushedAt: string;
621
+ }
588
622
  interface SDKEvents {
589
623
  connected: () => void;
590
624
  disconnected: (reason: string) => void;
@@ -594,8 +628,45 @@ interface SDKEvents {
594
628
  name: string;
595
629
  arguments: Record<string, unknown>;
596
630
  }) => void;
631
+ /** Called when a session resource is pushed or updated */
632
+ resourcePushed: (resource: StoredSessionResource) => void;
633
+ /** Called when user removes a session resource from Chat UI */
634
+ resourceRemoved: (resourceId: string) => void;
597
635
  }
598
636
  type SDKEventName = keyof SDKEvents;
637
+ /**
638
+ * Extended SDK methods available on SanqianSDK instance.
639
+ * Use this interface when you need type-safe access to these methods
640
+ * without type assertions.
641
+ */
642
+ interface SDKExtendedMethods {
643
+ /** Get all session resources pushed by this app */
644
+ getSessionResources(): StoredSessionResource[];
645
+ /** Cancel an in-flight chat run */
646
+ cancelRun(runId: string): void;
647
+ /** Remove a session resource */
648
+ removeSessionResource(resourceId: string): Promise<void>;
649
+ /** Get messages from a conversation */
650
+ getMessages?(conversationId: string, options?: {
651
+ limit?: number;
652
+ offset?: number;
653
+ }): Promise<{
654
+ messages?: Array<{
655
+ id?: string;
656
+ role: string;
657
+ content: string;
658
+ thinking?: string | null;
659
+ tool_calls?: ToolCall[] | null;
660
+ created_at?: string;
661
+ file_paths?: string[];
662
+ }>;
663
+ has_more?: boolean;
664
+ }>;
665
+ /** Subscribe to events */
666
+ on<T extends SDKEventName>(event: T, listener: SDKEvents[T]): void;
667
+ /** Unsubscribe from events */
668
+ off<T extends SDKEventName>(event: T, listener: SDKEvents[T]): void;
669
+ }
599
670
 
600
671
  declare class SanqianSDK {
601
672
  private config;
@@ -605,6 +676,7 @@ declare class SanqianSDK {
605
676
  private state;
606
677
  private toolHandlers;
607
678
  private contextProviders;
679
+ private sessionResources;
608
680
  private pendingRequests;
609
681
  private heartbeatTimer;
610
682
  private reconnectTimer;
@@ -674,6 +746,7 @@ declare class SanqianSDK {
674
746
  private handleContextGetCurrent;
675
747
  private handleContextGetList;
676
748
  private handleContextGetById;
749
+ private handleResourceRemovedByUser;
677
750
  private handleDisconnect;
678
751
  /**
679
752
  * Check if auto-reconnect should be enabled
@@ -839,6 +912,7 @@ declare class SanqianSDK {
839
912
  persistHistory?: boolean;
840
913
  attachedContexts?: string[];
841
914
  attachedResources?: string[];
915
+ sessionResources?: string[];
842
916
  }): AsyncGenerator<ChatStreamEvent>;
843
917
  /**
844
918
  * Send HITL (Human-in-the-Loop) response to resume after interrupt
@@ -897,6 +971,66 @@ declare class SanqianSDK {
897
971
  * @returns Embedding configuration or { available: false } if not configured
898
972
  */
899
973
  getEmbeddingConfig(): Promise<EmbeddingConfigResult>;
974
+ /**
975
+ * Push a session resource to Sanqian
976
+ *
977
+ * Session resources are temporary context pushed by the app, visible in all Chat UI instances.
978
+ * They persist until the app disconnects or explicitly removes them.
979
+ *
980
+ * @example
981
+ * ```typescript
982
+ * const stored = await sdk.pushResource({
983
+ * title: 'Current Note',
984
+ * content: '<note>\n# My Note\nContent here...\n</note>',
985
+ * summary: 'My Note - 2024-01-15',
986
+ * icon: '📝',
987
+ * type: 'note',
988
+ * });
989
+ * console.log(`Pushed: ${stored.fullId}`); // "my-app:abc123"
990
+ * ```
991
+ *
992
+ * @param resource - Resource to push
993
+ * @returns Stored resource with full ID and metadata
994
+ */
995
+ pushResource(resource: SessionResource): Promise<StoredSessionResource>;
996
+ /**
997
+ * Remove a session resource
998
+ *
999
+ * @example
1000
+ * ```typescript
1001
+ * await sdk.removeResource('my-app:abc123');
1002
+ * ```
1003
+ *
1004
+ * @param resourceId - Full resource ID (appName:resourceId)
1005
+ */
1006
+ removeResource(resourceId: string): Promise<void>;
1007
+ /**
1008
+ * Clear all session resources pushed by this app
1009
+ *
1010
+ * @example
1011
+ * ```typescript
1012
+ * await sdk.clearResources();
1013
+ * ```
1014
+ */
1015
+ clearResources(): Promise<void>;
1016
+ /**
1017
+ * Get all session resources pushed by this app
1018
+ *
1019
+ * Returns the local cache of resources pushed by this SDK instance.
1020
+ * Does NOT fetch from server - use this for quick local state access.
1021
+ *
1022
+ * @example
1023
+ * ```typescript
1024
+ * const resources = sdk.getSessionResources();
1025
+ * console.log(`Active resources: ${resources.length}`);
1026
+ * for (const r of resources) {
1027
+ * console.log(`- ${r.fullId}: ${r.title}`);
1028
+ * }
1029
+ * ```
1030
+ *
1031
+ * @returns Array of stored session resources
1032
+ */
1033
+ getSessionResources(): StoredSessionResource[];
900
1034
  /**
901
1035
  * List available capabilities (tools, skills, agents)
902
1036
  *
@@ -951,7 +1085,8 @@ declare class SanqianSDK {
951
1085
  * List all available agents (not just own agents)
952
1086
  *
953
1087
  * Unlike listAgents() which returns only this app's private agents,
954
- * this method returns all discoverable agents in the system.
1088
+ * this method returns all enabled agents in the system,
1089
+ * including non-searchable ones and this app's own private agents.
955
1090
  *
956
1091
  * @example
957
1092
  * ```typescript
@@ -1168,4 +1303,4 @@ declare class SanqianSDKError extends Error {
1168
1303
  */
1169
1304
  declare function createSDKError(code: SDKErrorCode, details?: string): SanqianSDKError;
1170
1305
 
1171
- export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextCapability, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationHistoryResult, type ConversationInfo, type ConversationMessage, DiscoveryManager, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type RemoteToolDefinition, type ResourceListOptions, type ResourceListResult, type ResourceType, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SkillCapability, type ToolCall, type ToolCapability, type ToolDefinition, createSDKError };
1306
+ export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextCapability, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationHistoryResult, type ConversationInfo, type ConversationMessage, DiscoveryManager, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type RemoteToolDefinition, type ResourceListOptions, type ResourceListResult, type ResourceType, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, type SDKExtendedMethods, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, createSDKError };
package/dist/index.d.ts CHANGED
@@ -575,6 +575,10 @@ interface ListCapabilitiesOptions {
575
575
  source?: string;
576
576
  /** Filter by category (tools only) */
577
577
  category?: string;
578
+ /** SDK app name (for including own private agents) */
579
+ appName?: string;
580
+ /** Agent scope filter: "searchable" (default) or "available" (includes non-searchable but enabled agents) */
581
+ scope?: "searchable" | "available";
578
582
  }
579
583
  /** Options for searching capabilities */
580
584
  interface SearchCapabilitiesOptions {
@@ -585,6 +589,36 @@ interface SearchCapabilitiesOptions {
585
589
  /** Exclude these IDs */
586
590
  exclude?: string[];
587
591
  }
592
+ /**
593
+ * Session resource pushed by an app.
594
+ * Content is provided at push time (not fetched like attached_resources).
595
+ * Global scope - visible in all Chat UI instances, persists until app disconnects.
596
+ */
597
+ interface SessionResource {
598
+ /** Resource ID (auto-generated if not provided) */
599
+ id?: string;
600
+ /** Display title (required) */
601
+ title: string;
602
+ /** Content (required, format controlled by app) */
603
+ content: string;
604
+ /** Optional summary for UI tooltip */
605
+ summary?: string;
606
+ /** Optional icon (emoji or URL) */
607
+ icon?: string;
608
+ /** Optional resource type for styling */
609
+ type?: ResourceType;
610
+ }
611
+ /**
612
+ * Stored session resource with full metadata
613
+ */
614
+ interface StoredSessionResource extends SessionResource {
615
+ /** Full ID: "appName:resourceId" */
616
+ fullId: string;
617
+ /** Source app name */
618
+ appName: string;
619
+ /** Push timestamp (ISO 8601) */
620
+ pushedAt: string;
621
+ }
588
622
  interface SDKEvents {
589
623
  connected: () => void;
590
624
  disconnected: (reason: string) => void;
@@ -594,8 +628,45 @@ interface SDKEvents {
594
628
  name: string;
595
629
  arguments: Record<string, unknown>;
596
630
  }) => void;
631
+ /** Called when a session resource is pushed or updated */
632
+ resourcePushed: (resource: StoredSessionResource) => void;
633
+ /** Called when user removes a session resource from Chat UI */
634
+ resourceRemoved: (resourceId: string) => void;
597
635
  }
598
636
  type SDKEventName = keyof SDKEvents;
637
+ /**
638
+ * Extended SDK methods available on SanqianSDK instance.
639
+ * Use this interface when you need type-safe access to these methods
640
+ * without type assertions.
641
+ */
642
+ interface SDKExtendedMethods {
643
+ /** Get all session resources pushed by this app */
644
+ getSessionResources(): StoredSessionResource[];
645
+ /** Cancel an in-flight chat run */
646
+ cancelRun(runId: string): void;
647
+ /** Remove a session resource */
648
+ removeSessionResource(resourceId: string): Promise<void>;
649
+ /** Get messages from a conversation */
650
+ getMessages?(conversationId: string, options?: {
651
+ limit?: number;
652
+ offset?: number;
653
+ }): Promise<{
654
+ messages?: Array<{
655
+ id?: string;
656
+ role: string;
657
+ content: string;
658
+ thinking?: string | null;
659
+ tool_calls?: ToolCall[] | null;
660
+ created_at?: string;
661
+ file_paths?: string[];
662
+ }>;
663
+ has_more?: boolean;
664
+ }>;
665
+ /** Subscribe to events */
666
+ on<T extends SDKEventName>(event: T, listener: SDKEvents[T]): void;
667
+ /** Unsubscribe from events */
668
+ off<T extends SDKEventName>(event: T, listener: SDKEvents[T]): void;
669
+ }
599
670
 
600
671
  declare class SanqianSDK {
601
672
  private config;
@@ -605,6 +676,7 @@ declare class SanqianSDK {
605
676
  private state;
606
677
  private toolHandlers;
607
678
  private contextProviders;
679
+ private sessionResources;
608
680
  private pendingRequests;
609
681
  private heartbeatTimer;
610
682
  private reconnectTimer;
@@ -674,6 +746,7 @@ declare class SanqianSDK {
674
746
  private handleContextGetCurrent;
675
747
  private handleContextGetList;
676
748
  private handleContextGetById;
749
+ private handleResourceRemovedByUser;
677
750
  private handleDisconnect;
678
751
  /**
679
752
  * Check if auto-reconnect should be enabled
@@ -839,6 +912,7 @@ declare class SanqianSDK {
839
912
  persistHistory?: boolean;
840
913
  attachedContexts?: string[];
841
914
  attachedResources?: string[];
915
+ sessionResources?: string[];
842
916
  }): AsyncGenerator<ChatStreamEvent>;
843
917
  /**
844
918
  * Send HITL (Human-in-the-Loop) response to resume after interrupt
@@ -897,6 +971,66 @@ declare class SanqianSDK {
897
971
  * @returns Embedding configuration or { available: false } if not configured
898
972
  */
899
973
  getEmbeddingConfig(): Promise<EmbeddingConfigResult>;
974
+ /**
975
+ * Push a session resource to Sanqian
976
+ *
977
+ * Session resources are temporary context pushed by the app, visible in all Chat UI instances.
978
+ * They persist until the app disconnects or explicitly removes them.
979
+ *
980
+ * @example
981
+ * ```typescript
982
+ * const stored = await sdk.pushResource({
983
+ * title: 'Current Note',
984
+ * content: '<note>\n# My Note\nContent here...\n</note>',
985
+ * summary: 'My Note - 2024-01-15',
986
+ * icon: '📝',
987
+ * type: 'note',
988
+ * });
989
+ * console.log(`Pushed: ${stored.fullId}`); // "my-app:abc123"
990
+ * ```
991
+ *
992
+ * @param resource - Resource to push
993
+ * @returns Stored resource with full ID and metadata
994
+ */
995
+ pushResource(resource: SessionResource): Promise<StoredSessionResource>;
996
+ /**
997
+ * Remove a session resource
998
+ *
999
+ * @example
1000
+ * ```typescript
1001
+ * await sdk.removeResource('my-app:abc123');
1002
+ * ```
1003
+ *
1004
+ * @param resourceId - Full resource ID (appName:resourceId)
1005
+ */
1006
+ removeResource(resourceId: string): Promise<void>;
1007
+ /**
1008
+ * Clear all session resources pushed by this app
1009
+ *
1010
+ * @example
1011
+ * ```typescript
1012
+ * await sdk.clearResources();
1013
+ * ```
1014
+ */
1015
+ clearResources(): Promise<void>;
1016
+ /**
1017
+ * Get all session resources pushed by this app
1018
+ *
1019
+ * Returns the local cache of resources pushed by this SDK instance.
1020
+ * Does NOT fetch from server - use this for quick local state access.
1021
+ *
1022
+ * @example
1023
+ * ```typescript
1024
+ * const resources = sdk.getSessionResources();
1025
+ * console.log(`Active resources: ${resources.length}`);
1026
+ * for (const r of resources) {
1027
+ * console.log(`- ${r.fullId}: ${r.title}`);
1028
+ * }
1029
+ * ```
1030
+ *
1031
+ * @returns Array of stored session resources
1032
+ */
1033
+ getSessionResources(): StoredSessionResource[];
900
1034
  /**
901
1035
  * List available capabilities (tools, skills, agents)
902
1036
  *
@@ -951,7 +1085,8 @@ declare class SanqianSDK {
951
1085
  * List all available agents (not just own agents)
952
1086
  *
953
1087
  * Unlike listAgents() which returns only this app's private agents,
954
- * this method returns all discoverable agents in the system.
1088
+ * this method returns all enabled agents in the system,
1089
+ * including non-searchable ones and this app's own private agents.
955
1090
  *
956
1091
  * @example
957
1092
  * ```typescript
@@ -1168,4 +1303,4 @@ declare class SanqianSDKError extends Error {
1168
1303
  */
1169
1304
  declare function createSDKError(code: SDKErrorCode, details?: string): SanqianSDKError;
1170
1305
 
1171
- export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextCapability, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationHistoryResult, type ConversationInfo, type ConversationMessage, DiscoveryManager, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type RemoteToolDefinition, type ResourceListOptions, type ResourceListResult, type ResourceType, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SkillCapability, type ToolCall, type ToolCapability, type ToolDefinition, createSDKError };
1306
+ export { type AgentCapability, type AgentConfig, type AgentInfo, type AgentUpdateConfig, type Capability, type CapabilitySearchResult, type CapabilityType, type ChatMessage, type ChatRequest, type ChatResponse, type ChatStreamEvent, type ConnectionInfo, type ConnectionState, type ContextCapability, type ContextData, type ContextListItem, type ContextProvider, Conversation, type ConversationDetail, type ConversationHistoryResult, type ConversationInfo, type ConversationMessage, DiscoveryManager, type EmbeddingConfigResult, ErrorMessages, type HitlInterruptPayload, type HitlInterruptType, type HitlResponse, type HitlRiskLevel, type JSONSchema, type JSONSchemaProperty, type ListCapabilitiesOptions, type RemoteToolDefinition, type ResourceListOptions, type ResourceListResult, type ResourceType, SANQIAN_WEBSITE, type SDKConfig, SDKErrorCode, type SDKEventName, type SDKEvents, type SDKExtendedMethods, SanqianSDK, SanqianSDKError, type SearchCapabilitiesOptions, type SessionResource, type SkillCapability, type StoredSessionResource, type ToolCall, type ToolCapability, type ToolDefinition, createSDKError };
package/dist/index.js CHANGED
@@ -515,6 +515,8 @@ var SanqianSDK = class _SanqianSDK {
515
515
  toolHandlers = /* @__PURE__ */ new Map();
516
516
  // Context providers by id
517
517
  contextProviders = /* @__PURE__ */ new Map();
518
+ // Session resources pushed by this app (local cache)
519
+ sessionResources = /* @__PURE__ */ new Map();
518
520
  // Pending request futures
519
521
  pendingRequests = /* @__PURE__ */ new Map();
520
522
  // Timers
@@ -716,6 +718,7 @@ var SanqianSDK = class _SanqianSDK {
716
718
  this.ws.close(1e3, "Client disconnect");
717
719
  this.ws = null;
718
720
  }
721
+ this.sessionResources.clear();
719
722
  this.state = {
720
723
  connected: false,
721
724
  registering: false,
@@ -803,6 +806,9 @@ var SanqianSDK = class _SanqianSDK {
803
806
  case "context_get_by_id":
804
807
  this.handleContextGetById(message);
805
808
  break;
809
+ case "resource_removed_by_user":
810
+ this.handleResourceRemovedByUser(message);
811
+ break;
806
812
  default:
807
813
  this.warn(`Unknown message type: ${type}`);
808
814
  }
@@ -1055,6 +1061,15 @@ var SanqianSDK = class _SanqianSDK {
1055
1061
  }
1056
1062
  }
1057
1063
  // ============================================
1064
+ // Session Resource Handlers
1065
+ // ============================================
1066
+ handleResourceRemovedByUser(message) {
1067
+ const { resourceId } = message;
1068
+ this.log(`Resource removed by user: ${resourceId}`);
1069
+ this.sessionResources.delete(resourceId);
1070
+ this.emit("resourceRemoved", resourceId);
1071
+ }
1072
+ // ============================================
1058
1073
  // Connection Management
1059
1074
  // ============================================
1060
1075
  handleDisconnect(reason) {
@@ -1602,6 +1617,7 @@ var SanqianSDK = class _SanqianSDK {
1602
1617
  auto_discover_subagents: options?.autoDiscoverSubagents ?? false,
1603
1618
  attached_contexts: options?.attachedContexts,
1604
1619
  attached_resources: options?.attachedResources,
1620
+ session_resources: options?.sessionResources,
1605
1621
  remote_tools: options?.remoteTools?.map((t) => ({
1606
1622
  name: t.name,
1607
1623
  description: t.description,
@@ -1754,6 +1770,121 @@ var SanqianSDK = class _SanqianSDK {
1754
1770
  return response.config || { available: false };
1755
1771
  }
1756
1772
  // ============================================
1773
+ // Session Resources API
1774
+ // ============================================
1775
+ /**
1776
+ * Push a session resource to Sanqian
1777
+ *
1778
+ * Session resources are temporary context pushed by the app, visible in all Chat UI instances.
1779
+ * They persist until the app disconnects or explicitly removes them.
1780
+ *
1781
+ * @example
1782
+ * ```typescript
1783
+ * const stored = await sdk.pushResource({
1784
+ * title: 'Current Note',
1785
+ * content: '<note>\n# My Note\nContent here...\n</note>',
1786
+ * summary: 'My Note - 2024-01-15',
1787
+ * icon: '📝',
1788
+ * type: 'note',
1789
+ * });
1790
+ * console.log(`Pushed: ${stored.fullId}`); // "my-app:abc123"
1791
+ * ```
1792
+ *
1793
+ * @param resource - Resource to push
1794
+ * @returns Stored resource with full ID and metadata
1795
+ */
1796
+ async pushResource(resource) {
1797
+ await this.ensureReady();
1798
+ const msgId = this.generateId();
1799
+ const message = {
1800
+ id: msgId,
1801
+ type: "resource_push",
1802
+ resource
1803
+ };
1804
+ const response = await this.sendAndWait(message, msgId, 1e4);
1805
+ if (!response.success || !response.resourceId) {
1806
+ throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, response.error || "Failed to push resource");
1807
+ }
1808
+ const stored = {
1809
+ ...resource,
1810
+ fullId: response.resourceId,
1811
+ appName: this.config.appName,
1812
+ pushedAt: (/* @__PURE__ */ new Date()).toISOString()
1813
+ };
1814
+ this.sessionResources.set(stored.fullId, stored);
1815
+ this.emit("resourcePushed", stored);
1816
+ this.log(`Pushed resource: ${stored.fullId}`);
1817
+ return stored;
1818
+ }
1819
+ /**
1820
+ * Remove a session resource
1821
+ *
1822
+ * @example
1823
+ * ```typescript
1824
+ * await sdk.removeResource('my-app:abc123');
1825
+ * ```
1826
+ *
1827
+ * @param resourceId - Full resource ID (appName:resourceId)
1828
+ */
1829
+ async removeResource(resourceId) {
1830
+ await this.ensureReady();
1831
+ const msgId = this.generateId();
1832
+ const message = {
1833
+ id: msgId,
1834
+ type: "resource_remove",
1835
+ resourceId
1836
+ };
1837
+ const response = await this.sendAndWait(message, msgId, 1e4);
1838
+ if (!response.success) {
1839
+ throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, response.error || "Failed to remove resource");
1840
+ }
1841
+ this.sessionResources.delete(resourceId);
1842
+ this.emit("resourceRemoved", resourceId);
1843
+ this.log(`Removed resource: ${resourceId}`);
1844
+ }
1845
+ /**
1846
+ * Clear all session resources pushed by this app
1847
+ *
1848
+ * @example
1849
+ * ```typescript
1850
+ * await sdk.clearResources();
1851
+ * ```
1852
+ */
1853
+ async clearResources() {
1854
+ await this.ensureReady();
1855
+ const msgId = this.generateId();
1856
+ const message = {
1857
+ id: msgId,
1858
+ type: "resource_clear"
1859
+ };
1860
+ const response = await this.sendAndWait(message, msgId, 1e4);
1861
+ if (!response.success) {
1862
+ throw createSDKError("REQUEST_FAILED" /* REQUEST_FAILED */, response.error || "Failed to clear resources");
1863
+ }
1864
+ this.sessionResources.clear();
1865
+ this.log("Cleared all resources");
1866
+ }
1867
+ /**
1868
+ * Get all session resources pushed by this app
1869
+ *
1870
+ * Returns the local cache of resources pushed by this SDK instance.
1871
+ * Does NOT fetch from server - use this for quick local state access.
1872
+ *
1873
+ * @example
1874
+ * ```typescript
1875
+ * const resources = sdk.getSessionResources();
1876
+ * console.log(`Active resources: ${resources.length}`);
1877
+ * for (const r of resources) {
1878
+ * console.log(`- ${r.fullId}: ${r.title}`);
1879
+ * }
1880
+ * ```
1881
+ *
1882
+ * @returns Array of stored session resources
1883
+ */
1884
+ getSessionResources() {
1885
+ return Array.from(this.sessionResources.values());
1886
+ }
1887
+ // ============================================
1757
1888
  // Capability Discovery API
1758
1889
  // ============================================
1759
1890
  /**
@@ -1783,6 +1914,12 @@ var SanqianSDK = class _SanqianSDK {
1783
1914
  if (options?.category) {
1784
1915
  params.append("category", options.category);
1785
1916
  }
1917
+ if (options?.appName) {
1918
+ params.append("appName", options.appName);
1919
+ }
1920
+ if (options?.scope) {
1921
+ params.append("scope", options.scope);
1922
+ }
1786
1923
  const url = `${this.getHttpBaseUrl()}/api/capabilities?${params.toString()}`;
1787
1924
  const response = await fetch(url);
1788
1925
  if (!response.ok) {
@@ -1855,7 +1992,8 @@ var SanqianSDK = class _SanqianSDK {
1855
1992
  * List all available agents (not just own agents)
1856
1993
  *
1857
1994
  * Unlike listAgents() which returns only this app's private agents,
1858
- * this method returns all discoverable agents in the system.
1995
+ * this method returns all enabled agents in the system,
1996
+ * including non-searchable ones and this app's own private agents.
1859
1997
  *
1860
1998
  * @example
1861
1999
  * ```typescript
@@ -1864,7 +2002,11 @@ var SanqianSDK = class _SanqianSDK {
1864
2002
  * ```
1865
2003
  */
1866
2004
  async listAvailableAgents() {
1867
- const caps = await this.listCapabilities({ type: "agent" });
2005
+ const caps = await this.listCapabilities({
2006
+ type: "agent",
2007
+ appName: this.config.appName,
2008
+ scope: "available"
2009
+ });
1868
2010
  return caps;
1869
2011
  }
1870
2012
  // ============================================