@chanl-ai/sdk 2.0.1

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 (137) hide show
  1. package/dist/adapters/openai.d.ts +106 -0
  2. package/dist/adapters/openai.d.ts.map +1 -0
  3. package/dist/adapters/openai.js +185 -0
  4. package/dist/adapters/openai.js.map +1 -0
  5. package/dist/client.d.ts +74 -0
  6. package/dist/client.d.ts.map +1 -0
  7. package/dist/client.js +293 -0
  8. package/dist/client.js.map +1 -0
  9. package/dist/errors/index.d.ts +179 -0
  10. package/dist/errors/index.d.ts.map +1 -0
  11. package/dist/errors/index.js +319 -0
  12. package/dist/errors/index.js.map +1 -0
  13. package/dist/index.d.ts +38 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +76 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/live/index.d.ts +9 -0
  18. package/dist/live/index.d.ts.map +1 -0
  19. package/dist/live/index.js +16 -0
  20. package/dist/live/index.js.map +1 -0
  21. package/dist/live/live-call.d.ts +48 -0
  22. package/dist/live/live-call.d.ts.map +1 -0
  23. package/dist/live/live-call.js +148 -0
  24. package/dist/live/live-call.js.map +1 -0
  25. package/dist/live/live-chat.d.ts +71 -0
  26. package/dist/live/live-chat.d.ts.map +1 -0
  27. package/dist/live/live-chat.js +95 -0
  28. package/dist/live/live-chat.js.map +1 -0
  29. package/dist/live/live-execution.d.ts +55 -0
  30. package/dist/live/live-execution.d.ts.map +1 -0
  31. package/dist/live/live-execution.js +170 -0
  32. package/dist/live/live-execution.js.map +1 -0
  33. package/dist/live/typed-emitter.d.ts +15 -0
  34. package/dist/live/typed-emitter.d.ts.map +1 -0
  35. package/dist/live/typed-emitter.js +40 -0
  36. package/dist/live/typed-emitter.js.map +1 -0
  37. package/dist/live/types.d.ts +24 -0
  38. package/dist/live/types.d.ts.map +1 -0
  39. package/dist/live/types.js +6 -0
  40. package/dist/live/types.js.map +1 -0
  41. package/dist/modules/agents.d.ts +378 -0
  42. package/dist/modules/agents.d.ts.map +1 -0
  43. package/dist/modules/agents.js +259 -0
  44. package/dist/modules/agents.js.map +1 -0
  45. package/dist/modules/alerts.d.ts +43 -0
  46. package/dist/modules/alerts.d.ts.map +1 -0
  47. package/dist/modules/alerts.js +56 -0
  48. package/dist/modules/alerts.js.map +1 -0
  49. package/dist/modules/audio.d.ts +47 -0
  50. package/dist/modules/audio.d.ts.map +1 -0
  51. package/dist/modules/audio.js +75 -0
  52. package/dist/modules/audio.js.map +1 -0
  53. package/dist/modules/auth.d.ts +76 -0
  54. package/dist/modules/auth.d.ts.map +1 -0
  55. package/dist/modules/auth.js +59 -0
  56. package/dist/modules/auth.js.map +1 -0
  57. package/dist/modules/calls.d.ts +825 -0
  58. package/dist/modules/calls.d.ts.map +1 -0
  59. package/dist/modules/calls.js +398 -0
  60. package/dist/modules/calls.js.map +1 -0
  61. package/dist/modules/chat.d.ts +165 -0
  62. package/dist/modules/chat.d.ts.map +1 -0
  63. package/dist/modules/chat.js +169 -0
  64. package/dist/modules/chat.js.map +1 -0
  65. package/dist/modules/health.d.ts +45 -0
  66. package/dist/modules/health.d.ts.map +1 -0
  67. package/dist/modules/health.js +22 -0
  68. package/dist/modules/health.js.map +1 -0
  69. package/dist/modules/knowledge.d.ts +202 -0
  70. package/dist/modules/knowledge.d.ts.map +1 -0
  71. package/dist/modules/knowledge.js +147 -0
  72. package/dist/modules/knowledge.js.map +1 -0
  73. package/dist/modules/mcp.d.ts +140 -0
  74. package/dist/modules/mcp.d.ts.map +1 -0
  75. package/dist/modules/mcp.js +110 -0
  76. package/dist/modules/mcp.js.map +1 -0
  77. package/dist/modules/memory.d.ts +163 -0
  78. package/dist/modules/memory.d.ts.map +1 -0
  79. package/dist/modules/memory.js +208 -0
  80. package/dist/modules/memory.js.map +1 -0
  81. package/dist/modules/personas.d.ts +168 -0
  82. package/dist/modules/personas.d.ts.map +1 -0
  83. package/dist/modules/personas.js +106 -0
  84. package/dist/modules/personas.js.map +1 -0
  85. package/dist/modules/prompts.d.ts +128 -0
  86. package/dist/modules/prompts.d.ts.map +1 -0
  87. package/dist/modules/prompts.js +93 -0
  88. package/dist/modules/prompts.js.map +1 -0
  89. package/dist/modules/scenarios.d.ts +294 -0
  90. package/dist/modules/scenarios.d.ts.map +1 -0
  91. package/dist/modules/scenarios.js +349 -0
  92. package/dist/modules/scenarios.js.map +1 -0
  93. package/dist/modules/scorecard.d.ts +642 -0
  94. package/dist/modules/scorecard.d.ts.map +1 -0
  95. package/dist/modules/scorecard.js +327 -0
  96. package/dist/modules/scorecard.js.map +1 -0
  97. package/dist/modules/tools.d.ts +222 -0
  98. package/dist/modules/tools.d.ts.map +1 -0
  99. package/dist/modules/tools.js +302 -0
  100. package/dist/modules/tools.js.map +1 -0
  101. package/dist/modules/toolsets.d.ts +173 -0
  102. package/dist/modules/toolsets.d.ts.map +1 -0
  103. package/dist/modules/toolsets.js +216 -0
  104. package/dist/modules/toolsets.js.map +1 -0
  105. package/dist/modules/transcript.d.ts +60 -0
  106. package/dist/modules/transcript.d.ts.map +1 -0
  107. package/dist/modules/transcript.js +69 -0
  108. package/dist/modules/transcript.js.map +1 -0
  109. package/dist/modules/workspace.d.ts +48 -0
  110. package/dist/modules/workspace.d.ts.map +1 -0
  111. package/dist/modules/workspace.js +49 -0
  112. package/dist/modules/workspace.js.map +1 -0
  113. package/dist/types/api.d.ts +8 -0
  114. package/dist/types/api.d.ts.map +1 -0
  115. package/dist/types/api.js +25 -0
  116. package/dist/types/api.js.map +1 -0
  117. package/dist/types/config.d.ts +70 -0
  118. package/dist/types/config.d.ts.map +1 -0
  119. package/dist/types/config.js +3 -0
  120. package/dist/types/config.js.map +1 -0
  121. package/dist/types/memory.d.ts +243 -0
  122. package/dist/types/memory.d.ts.map +1 -0
  123. package/dist/types/memory.js +9 -0
  124. package/dist/types/memory.js.map +1 -0
  125. package/dist/types/tool-calls.d.ts +61 -0
  126. package/dist/types/tool-calls.d.ts.map +1 -0
  127. package/dist/types/tool-calls.js +9 -0
  128. package/dist/types/tool-calls.js.map +1 -0
  129. package/dist/types/tools.d.ts +321 -0
  130. package/dist/types/tools.d.ts.map +1 -0
  131. package/dist/types/tools.js +9 -0
  132. package/dist/types/tools.js.map +1 -0
  133. package/dist/types/toolsets.d.ts +149 -0
  134. package/dist/types/toolsets.d.ts.map +1 -0
  135. package/dist/types/toolsets.js +8 -0
  136. package/dist/types/toolsets.js.map +1 -0
  137. package/package.json +60 -0
@@ -0,0 +1,140 @@
1
+ /**
2
+ * McpModule - SDK module for MCP server configuration and status
3
+ *
4
+ * Provides access to MCP server configuration and health status.
5
+ * Used by CLI and admin UI to get ready-to-use agent configurations.
6
+ */
7
+ import { ChanlSDK } from '../client';
8
+ import { ApiResponse } from '../types/config';
9
+ export interface AgentConfig {
10
+ url: string;
11
+ headers: Record<string, string>;
12
+ transport?: string;
13
+ }
14
+ export interface AgentConfigs {
15
+ claude: {
16
+ mcpServers: {
17
+ chanl: AgentConfig;
18
+ };
19
+ };
20
+ cursor: {
21
+ mcpServers: {
22
+ chanl: AgentConfig;
23
+ };
24
+ };
25
+ generic: AgentConfig;
26
+ }
27
+ export interface McpConfigResponse {
28
+ serverUrl: string;
29
+ environment: 'production' | 'staging' | 'development';
30
+ status: 'active' | 'disabled';
31
+ toolCount: number;
32
+ resourceCount: number;
33
+ promptCount: number;
34
+ toolsetId?: string;
35
+ toolsetName?: string;
36
+ agentConfigs: AgentConfigs;
37
+ }
38
+ export interface McpStatusResponse {
39
+ healthy: boolean;
40
+ message: string;
41
+ responseTimeMs?: number;
42
+ error?: string;
43
+ }
44
+ export interface McpConfigOptions {
45
+ toolsetId?: string;
46
+ }
47
+ export interface McpTool {
48
+ name: string;
49
+ description?: string;
50
+ inputSchema: Record<string, unknown>;
51
+ }
52
+ export interface McpToolCallResult {
53
+ content: Array<{
54
+ type: string;
55
+ text?: string;
56
+ [key: string]: unknown;
57
+ }>;
58
+ isError?: boolean;
59
+ }
60
+ export declare class McpModule {
61
+ private sdk;
62
+ constructor(sdk: ChanlSDK);
63
+ /**
64
+ * Get MCP configuration for a workspace
65
+ *
66
+ * @param options - Optional configuration options (e.g., toolsetId filter)
67
+ * @returns MCP configuration including server URL and agent configs
68
+ *
69
+ * @example
70
+ * typescript
71
+ * const { data } = await sdk.mcp.getConfig('ws_123');
72
+ * console.log(data.serverUrl);
73
+ * console.log(data.agentConfigs.claude);
74
+ */
75
+ getConfig(options?: McpConfigOptions): Promise<ApiResponse<McpConfigResponse>>;
76
+ /**
77
+ * Check MCP server health status
78
+ *
79
+ * @returns Health status of the MCP server
80
+ *
81
+ * @example
82
+ * typescript
83
+ * const { data } = await sdk.mcp.getStatus('ws_123');
84
+ * if (data.healthy) {
85
+ * console.log('MCP server is running');
86
+ * }
87
+ */
88
+ getStatus(): Promise<ApiResponse<McpStatusResponse>>;
89
+ /**
90
+ * List MCP tools available for an agent
91
+ *
92
+ * @param agentId - Agent ID to list tools for
93
+ * @returns List of MCP tools with their schemas
94
+ *
95
+ * @example
96
+ * ```typescript
97
+ * const { data } = await sdk.mcp.listTools('ws_123', 'agent_456');
98
+ * for (const tool of data.tools) {
99
+ * console.log(tool.name, tool.description);
100
+ * }
101
+ * ```
102
+ */
103
+ listTools(agentId: string): Promise<ApiResponse<{
104
+ tools: McpTool[];
105
+ }>>;
106
+ /**
107
+ * Call an MCP tool by name
108
+ *
109
+ * @param agentId - Agent ID that owns the tool
110
+ * @param toolName - Name of the tool to invoke
111
+ * @param args - Optional arguments to pass to the tool
112
+ * @returns Tool call result with content array
113
+ *
114
+ * @example
115
+ * ```typescript
116
+ * const { data } = await sdk.mcp.callTool('ws_123', 'agent_456', 'get_weather', { city: 'London' });
117
+ * if (!data.isError) {
118
+ * console.log(data.content[0].text);
119
+ * }
120
+ * ```
121
+ */
122
+ callTool(agentId: string, toolName: string, args?: Record<string, unknown>): Promise<ApiResponse<McpToolCallResult>>;
123
+ /**
124
+ * Get details and schema for a specific MCP tool
125
+ *
126
+ * @param agentId - Agent ID that owns the tool
127
+ * @param toolName - Name of the tool to inspect
128
+ * @returns Tool details including input schema
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const { data } = await sdk.mcp.getTool('ws_123', 'agent_456', 'get_weather');
133
+ * console.log(data.tool.inputSchema);
134
+ * ```
135
+ */
136
+ getTool(agentId: string, toolName: string): Promise<ApiResponse<{
137
+ tool: McpTool;
138
+ }>>;
139
+ }
140
+ //# sourceMappingURL=mcp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/modules/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAM9C,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,WAAW,CAAC;SACpB,CAAC;KACH,CAAC;IACF,MAAM,EAAE;QACN,UAAU,EAAE;YACV,KAAK,EAAE,WAAW,CAAC;SACpB,CAAC;KACH,CAAC;IACF,OAAO,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,YAAY,GAAG,SAAS,GAAG,aAAa,CAAC;IACtD,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,YAAY,CAAC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CAAC,CAAC;IAO1C;;;;;;;;;;;;OAYG;IACG,OAAO,CACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,WAAW,CAAC;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CAG3C"}
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ /**
3
+ * McpModule - SDK module for MCP server configuration and status
4
+ *
5
+ * Provides access to MCP server configuration and health status.
6
+ * Used by CLI and admin UI to get ready-to-use agent configurations.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.McpModule = void 0;
10
+ // ============================================================================
11
+ // MCP MODULE
12
+ // ============================================================================
13
+ class McpModule {
14
+ constructor(sdk) {
15
+ this.sdk = sdk;
16
+ }
17
+ /**
18
+ * Get MCP configuration for a workspace
19
+ *
20
+ * @param options - Optional configuration options (e.g., toolsetId filter)
21
+ * @returns MCP configuration including server URL and agent configs
22
+ *
23
+ * @example
24
+ * typescript
25
+ * const { data } = await sdk.mcp.getConfig('ws_123');
26
+ * console.log(data.serverUrl);
27
+ * console.log(data.agentConfigs.claude);
28
+ */
29
+ async getConfig(options) {
30
+ const queryParams = new URLSearchParams();
31
+ if (options?.toolsetId) {
32
+ queryParams.append('toolsetId', options.toolsetId);
33
+ }
34
+ const queryString = queryParams.toString();
35
+ const url = '/api/v1/mcp/config' + (queryString ? '?' + queryString : '');
36
+ return this.sdk.request('GET', url);
37
+ }
38
+ /**
39
+ * Check MCP server health status
40
+ *
41
+ * @returns Health status of the MCP server
42
+ *
43
+ * @example
44
+ * typescript
45
+ * const { data } = await sdk.mcp.getStatus('ws_123');
46
+ * if (data.healthy) {
47
+ * console.log('MCP server is running');
48
+ * }
49
+ */
50
+ async getStatus() {
51
+ return this.sdk.request('GET', '/api/v1/mcp/status');
52
+ }
53
+ /**
54
+ * List MCP tools available for an agent
55
+ *
56
+ * @param agentId - Agent ID to list tools for
57
+ * @returns List of MCP tools with their schemas
58
+ *
59
+ * @example
60
+ * ```typescript
61
+ * const { data } = await sdk.mcp.listTools('ws_123', 'agent_456');
62
+ * for (const tool of data.tools) {
63
+ * console.log(tool.name, tool.description);
64
+ * }
65
+ * ```
66
+ */
67
+ async listTools(agentId) {
68
+ return this.sdk.request('GET', `/api/v1/mcp/agents/${agentId}/tools`);
69
+ }
70
+ /**
71
+ * Call an MCP tool by name
72
+ *
73
+ * @param agentId - Agent ID that owns the tool
74
+ * @param toolName - Name of the tool to invoke
75
+ * @param args - Optional arguments to pass to the tool
76
+ * @returns Tool call result with content array
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * const { data } = await sdk.mcp.callTool('ws_123', 'agent_456', 'get_weather', { city: 'London' });
81
+ * if (!data.isError) {
82
+ * console.log(data.content[0].text);
83
+ * }
84
+ * ```
85
+ */
86
+ async callTool(agentId, toolName, args) {
87
+ return this.sdk.request('POST', `/api/v1/mcp/agents/${agentId}/tools/call`, {
88
+ name: toolName,
89
+ arguments: args,
90
+ });
91
+ }
92
+ /**
93
+ * Get details and schema for a specific MCP tool
94
+ *
95
+ * @param agentId - Agent ID that owns the tool
96
+ * @param toolName - Name of the tool to inspect
97
+ * @returns Tool details including input schema
98
+ *
99
+ * @example
100
+ * ```typescript
101
+ * const { data } = await sdk.mcp.getTool('ws_123', 'agent_456', 'get_weather');
102
+ * console.log(data.tool.inputSchema);
103
+ * ```
104
+ */
105
+ async getTool(agentId, toolName) {
106
+ return this.sdk.request('GET', `/api/v1/mcp/agents/${agentId}/tools/${toolName}`);
107
+ }
108
+ }
109
+ exports.McpModule = McpModule;
110
+ //# sourceMappingURL=mcp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp.js","sourceRoot":"","sources":["../../src/modules/mcp.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA+DH,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,MAAa,SAAS;IACpB,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAA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AC,CAAC;IACpF,CAAC;CACF;AA/GD,8BA+GC"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * MemoryModule - SDK module for agent memory management
3
+ *
4
+ * Provides CRUD operations for memories, semantic search,
5
+ * and bulk deletion. All methods require a workspaceId which
6
+ * is passed via the x-workspace-id header.
7
+ */
8
+ import { ChanlSDK } from '../client';
9
+ import { ApiResponse } from '../types/config';
10
+ import type { CreateMemoryInput, UpdateMemoryInput, SearchMemoryInput, ExtractMemoryInput, BulkDeleteMemoryInput, MemoryFilters, MemoryResponse, MemoryListResponse, MemorySearchResponse, MemoryExtractResponse, MemoryDeleteResponse, MemoryBulkDeleteResponse } from '../types/memory';
11
+ export declare class MemoryModule {
12
+ private sdk;
13
+ constructor(sdk: ChanlSDK);
14
+ /**
15
+ * List memories with optional filters
16
+ *
17
+ * @param filters - Optional filters for the query
18
+ * @returns Paginated list of memories
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // List all memories
23
+ * const { data } = await sdk.memory.list();
24
+ *
25
+ * // Filter by entity type and agent
26
+ * const { data } = await sdk.memory.list({
27
+ * entityType: 'customer',
28
+ * agentId: 'agent_abc',
29
+ * isActive: true,
30
+ * page: 1,
31
+ * limit: 20
32
+ * });
33
+ * ```
34
+ */
35
+ list(filters?: MemoryFilters): Promise<ApiResponse<MemoryListResponse>>;
36
+ /**
37
+ * Get a single memory by ID
38
+ *
39
+ * @param id - Memory ID
40
+ * @returns Memory details
41
+ * @throws NotFoundError if memory doesn't exist
42
+ *
43
+ * @example
44
+ * ```typescript
45
+ * const { data } = await sdk.memory.get('mem_abc123');
46
+ * console.log(data.memory.content);
47
+ * ```
48
+ */
49
+ get(id: string): Promise<ApiResponse<MemoryResponse>>;
50
+ /**
51
+ * Create a new memory
52
+ *
53
+ * @param input - Memory creation data
54
+ * @returns Created memory
55
+ * @throws ValidationError if input is invalid
56
+ *
57
+ * @example
58
+ * ```typescript
59
+ * const { data } = await sdk.memory.create({
60
+ * entityType: 'customer',
61
+ * entityId: 'cust_456',
62
+ * content: 'Customer prefers email communication',
63
+ * metadata: { source: 'conversation', confidence: 0.95 }
64
+ * });
65
+ * ```
66
+ */
67
+ create(input: CreateMemoryInput): Promise<ApiResponse<MemoryResponse>>;
68
+ /**
69
+ * Update an existing memory
70
+ *
71
+ * @param id - Memory ID
72
+ * @param input - Update data
73
+ * @returns Updated memory
74
+ * @throws NotFoundError if memory doesn't exist
75
+ * @throws ValidationError if input is invalid
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * const { data } = await sdk.memory.update('mem_abc123', {
80
+ * content: 'Updated preference: customer prefers phone calls',
81
+ * isActive: true
82
+ * });
83
+ * ```
84
+ */
85
+ update(id: string, input: UpdateMemoryInput): Promise<ApiResponse<MemoryResponse>>;
86
+ /**
87
+ * Delete a memory
88
+ *
89
+ * @param id - Memory ID
90
+ * @returns Deletion confirmation
91
+ * @throws NotFoundError if memory doesn't exist
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * const { data } = await sdk.memory.delete('mem_abc123');
96
+ * console.log(data.deleted); // true
97
+ * ```
98
+ */
99
+ delete(id: string): Promise<ApiResponse<MemoryDeleteResponse>>;
100
+ /**
101
+ * Search memories using semantic similarity
102
+ *
103
+ * @param input - Search parameters
104
+ * @returns Matching memories with relevance scores
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * const { data } = await sdk.memory.search({
109
+ * entityType: 'customer',
110
+ * entityId: 'cust_456',
111
+ * query: 'communication preferences',
112
+ * limit: 5,
113
+ * minScore: 0.7
114
+ * });
115
+ * data.memories.forEach(m => {
116
+ * console.log(`${m.content} (score: ${m.score})`);
117
+ * });
118
+ * ```
119
+ */
120
+ search(input: SearchMemoryInput): Promise<ApiResponse<MemorySearchResponse>>;
121
+ /**
122
+ * Extract structured facts from text using LLM
123
+ *
124
+ * Analyzes free-form text and extracts key facts (preferences, personal details,
125
+ * account info). Optionally saves them as memory entries with source='extraction'.
126
+ *
127
+ * @param input - Extraction parameters
128
+ * @returns Extracted facts with content, key, value, and confidence
129
+ *
130
+ * @example
131
+ * ```typescript
132
+ * const { data } = await sdk.memory.extract({
133
+ * text: 'Customer moved from Seattle to Portland, prefers email.',
134
+ * entityType: 'customer',
135
+ * entityId: 'cust_456',
136
+ * save: true,
137
+ * });
138
+ * data.facts.forEach(f => {
139
+ * console.log(`${f.key}: ${f.value} (confidence: ${f.confidence})`);
140
+ * });
141
+ * ```
142
+ */
143
+ extract(input: ExtractMemoryInput): Promise<ApiResponse<MemoryExtractResponse>>;
144
+ /**
145
+ * Bulk delete memories matching criteria
146
+ *
147
+ * @param input - Deletion criteria
148
+ * @returns Deletion confirmation with count
149
+ *
150
+ * @example
151
+ * ```typescript
152
+ * // Delete all inactive memories for an entity
153
+ * const { data } = await sdk.memory.bulkDelete('ws_123', {
154
+ * entityType: 'customer',
155
+ * entityId: 'cust_456',
156
+ * inactiveOnly: true
157
+ * });
158
+ * console.log(`Deleted ${data.deletedCount} memories`);
159
+ * ```
160
+ */
161
+ bulkDelete(input: BulkDeleteMemoryInput): Promise<ApiResponse<MemoryBulkDeleteResponse>>;
162
+ }
163
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/modules/memory.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,EACV,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,EACrB,oBAAoB,EACpB,wBAAwB,EACzB,MAAM,iBAAiB,CAAC;AAMzB,qBAAa,YAAY;IACX,OAAO,CAAC,GAAG;gBAAH,GAAG,EAAE,QAAQ;IAEjC;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;IA8B7E;;;;;;;;;;;;OAYG;IACG,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAI3D;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAI5E;;;;;;;;;;;;;;;;OAgBG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC;IAIxF;;;;;;;;;;;;OAYG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAIpE;;;;;;;;;;;;;;;;;;;OAmBG;IACG,MAAM,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC,oBAAoB,CAAC,CAAC;IAIlF;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,OAAO,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAIrF;;;;;;;;;;;;;;;;OAgBG;IACG,UAAU,CAAC,KAAK,EAAE,qBAAqB,GAAG,OAAO,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAC;CAG/F"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * MemoryModule - SDK module for agent memory management
4
+ *
5
+ * Provides CRUD operations for memories, semantic search,
6
+ * and bulk deletion. All methods require a workspaceId which
7
+ * is passed via the x-workspace-id header.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MemoryModule = void 0;
11
+ // ============================================================================
12
+ // MEMORY MODULE
13
+ // ============================================================================
14
+ class MemoryModule {
15
+ constructor(sdk) {
16
+ this.sdk = sdk;
17
+ }
18
+ /**
19
+ * List memories with optional filters
20
+ *
21
+ * @param filters - Optional filters for the query
22
+ * @returns Paginated list of memories
23
+ *
24
+ * @example
25
+ * ```typescript
26
+ * // List all memories
27
+ * const { data } = await sdk.memory.list();
28
+ *
29
+ * // Filter by entity type and agent
30
+ * const { data } = await sdk.memory.list({
31
+ * entityType: 'customer',
32
+ * agentId: 'agent_abc',
33
+ * isActive: true,
34
+ * page: 1,
35
+ * limit: 20
36
+ * });
37
+ * ```
38
+ */
39
+ async list(filters) {
40
+ const params = new URLSearchParams();
41
+ if (filters?.entityType) {
42
+ params.append('entityType', filters.entityType);
43
+ }
44
+ if (filters?.entityId) {
45
+ params.append('entityId', filters.entityId);
46
+ }
47
+ if (filters?.agentId) {
48
+ params.append('agentId', filters.agentId);
49
+ }
50
+ if (filters?.source) {
51
+ params.append('source', filters.source);
52
+ }
53
+ if (filters?.isActive !== undefined) {
54
+ params.append('isActive', String(filters.isActive));
55
+ }
56
+ if (filters?.page) {
57
+ params.append('page', String(filters.page));
58
+ }
59
+ if (filters?.limit) {
60
+ params.append('limit', String(filters.limit));
61
+ }
62
+ const query = params.toString();
63
+ const url = `/api/v1/memory${query ? `?${query}` : ''}`;
64
+ return this.sdk.request('GET', url);
65
+ }
66
+ /**
67
+ * Get a single memory by ID
68
+ *
69
+ * @param id - Memory ID
70
+ * @returns Memory details
71
+ * @throws NotFoundError if memory doesn't exist
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * const { data } = await sdk.memory.get('mem_abc123');
76
+ * console.log(data.memory.content);
77
+ * ```
78
+ */
79
+ async get(id) {
80
+ return this.sdk.request('GET', `/api/v1/memory/${id}`);
81
+ }
82
+ /**
83
+ * Create a new memory
84
+ *
85
+ * @param input - Memory creation data
86
+ * @returns Created memory
87
+ * @throws ValidationError if input is invalid
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const { data } = await sdk.memory.create({
92
+ * entityType: 'customer',
93
+ * entityId: 'cust_456',
94
+ * content: 'Customer prefers email communication',
95
+ * metadata: { source: 'conversation', confidence: 0.95 }
96
+ * });
97
+ * ```
98
+ */
99
+ async create(input) {
100
+ return this.sdk.request('POST', '/api/v1/memory', input);
101
+ }
102
+ /**
103
+ * Update an existing memory
104
+ *
105
+ * @param id - Memory ID
106
+ * @param input - Update data
107
+ * @returns Updated memory
108
+ * @throws NotFoundError if memory doesn't exist
109
+ * @throws ValidationError if input is invalid
110
+ *
111
+ * @example
112
+ * ```typescript
113
+ * const { data } = await sdk.memory.update('mem_abc123', {
114
+ * content: 'Updated preference: customer prefers phone calls',
115
+ * isActive: true
116
+ * });
117
+ * ```
118
+ */
119
+ async update(id, input) {
120
+ return this.sdk.request('PATCH', `/api/v1/memory/${id}`, input);
121
+ }
122
+ /**
123
+ * Delete a memory
124
+ *
125
+ * @param id - Memory ID
126
+ * @returns Deletion confirmation
127
+ * @throws NotFoundError if memory doesn't exist
128
+ *
129
+ * @example
130
+ * ```typescript
131
+ * const { data } = await sdk.memory.delete('mem_abc123');
132
+ * console.log(data.deleted); // true
133
+ * ```
134
+ */
135
+ async delete(id) {
136
+ return this.sdk.request('DELETE', `/api/v1/memory/${id}`);
137
+ }
138
+ /**
139
+ * Search memories using semantic similarity
140
+ *
141
+ * @param input - Search parameters
142
+ * @returns Matching memories with relevance scores
143
+ *
144
+ * @example
145
+ * ```typescript
146
+ * const { data } = await sdk.memory.search({
147
+ * entityType: 'customer',
148
+ * entityId: 'cust_456',
149
+ * query: 'communication preferences',
150
+ * limit: 5,
151
+ * minScore: 0.7
152
+ * });
153
+ * data.memories.forEach(m => {
154
+ * console.log(`${m.content} (score: ${m.score})`);
155
+ * });
156
+ * ```
157
+ */
158
+ async search(input) {
159
+ return this.sdk.request('POST', '/api/v1/memory/search', input);
160
+ }
161
+ /**
162
+ * Extract structured facts from text using LLM
163
+ *
164
+ * Analyzes free-form text and extracts key facts (preferences, personal details,
165
+ * account info). Optionally saves them as memory entries with source='extraction'.
166
+ *
167
+ * @param input - Extraction parameters
168
+ * @returns Extracted facts with content, key, value, and confidence
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * const { data } = await sdk.memory.extract({
173
+ * text: 'Customer moved from Seattle to Portland, prefers email.',
174
+ * entityType: 'customer',
175
+ * entityId: 'cust_456',
176
+ * save: true,
177
+ * });
178
+ * data.facts.forEach(f => {
179
+ * console.log(`${f.key}: ${f.value} (confidence: ${f.confidence})`);
180
+ * });
181
+ * ```
182
+ */
183
+ async extract(input) {
184
+ return this.sdk.request('POST', '/api/v1/memory/extract', input);
185
+ }
186
+ /**
187
+ * Bulk delete memories matching criteria
188
+ *
189
+ * @param input - Deletion criteria
190
+ * @returns Deletion confirmation with count
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * // Delete all inactive memories for an entity
195
+ * const { data } = await sdk.memory.bulkDelete('ws_123', {
196
+ * entityType: 'customer',
197
+ * entityId: 'cust_456',
198
+ * inactiveOnly: true
199
+ * });
200
+ * console.log(`Deleted ${data.deletedCount} memories`);
201
+ * ```
202
+ */
203
+ async bulkDelete(input) {
204
+ return this.sdk.request('DELETE', '/api/v1/memory', input);
205
+ }
206
+ }
207
+ exports.MemoryModule = MemoryModule;
208
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../src/modules/memory.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAmBH,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E,MAAa,YAAY;IACvB,YAAoB,GAAa;QAAb,QAAG,GAAH,GAAG,CAAU;IAAG,CAAC;IAErC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,KAAK,CAAC,IAAI,CAAC,OAAuB;QAChC,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;QAErC,IAAI,OAAO,EAAE,UAAU,EAAE,CAAC;YACxB,MAAM,CAAC,MAAM,CAAC,YAAY,EAA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