@elliotding/ai-agent-mcp 0.1.26 → 0.1.28

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 (186) hide show
  1. package/README.md +330 -30
  2. package/dist/api/cached-client.d.ts +48 -0
  3. package/dist/api/cached-client.d.ts.map +1 -0
  4. package/dist/api/cached-client.js +126 -0
  5. package/dist/api/cached-client.js.map +1 -0
  6. package/dist/api/client.d.ts +295 -0
  7. package/dist/api/client.d.ts.map +1 -0
  8. package/dist/api/client.js +385 -0
  9. package/dist/api/client.js.map +1 -0
  10. package/dist/auth/index.d.ts +8 -0
  11. package/dist/auth/index.d.ts.map +1 -0
  12. package/dist/auth/index.js +26 -0
  13. package/dist/auth/index.js.map +1 -0
  14. package/dist/auth/middleware.d.ts +36 -0
  15. package/dist/auth/middleware.d.ts.map +1 -0
  16. package/dist/auth/middleware.js +194 -0
  17. package/dist/auth/middleware.js.map +1 -0
  18. package/dist/auth/permissions.d.ts +60 -0
  19. package/dist/auth/permissions.d.ts.map +1 -0
  20. package/dist/auth/permissions.js +262 -0
  21. package/dist/auth/permissions.js.map +1 -0
  22. package/dist/auth/token-validator.d.ts +52 -0
  23. package/dist/auth/token-validator.d.ts.map +1 -0
  24. package/dist/auth/token-validator.js +215 -0
  25. package/dist/auth/token-validator.js.map +1 -0
  26. package/dist/cache/cache-manager.d.ts +49 -0
  27. package/dist/cache/cache-manager.d.ts.map +1 -0
  28. package/dist/cache/cache-manager.js +191 -0
  29. package/dist/cache/cache-manager.js.map +1 -0
  30. package/dist/cache/index.d.ts +6 -0
  31. package/dist/cache/index.d.ts.map +1 -0
  32. package/dist/cache/index.js +12 -0
  33. package/dist/cache/index.js.map +1 -0
  34. package/dist/cache/redis-client.d.ts +45 -0
  35. package/dist/cache/redis-client.d.ts.map +1 -0
  36. package/dist/cache/redis-client.js +210 -0
  37. package/dist/cache/redis-client.js.map +1 -0
  38. package/dist/config/constants.d.ts +28 -0
  39. package/dist/config/constants.d.ts.map +1 -0
  40. package/dist/config/constants.js +31 -0
  41. package/dist/config/constants.js.map +1 -0
  42. package/dist/config/index.d.ts +71 -0
  43. package/dist/config/index.d.ts.map +1 -0
  44. package/dist/config/index.js +190 -0
  45. package/dist/config/index.js.map +1 -0
  46. package/dist/filesystem/manager.d.ts +45 -0
  47. package/dist/filesystem/manager.d.ts.map +1 -0
  48. package/dist/filesystem/manager.js +246 -0
  49. package/dist/filesystem/manager.js.map +1 -0
  50. package/dist/git/multi-source-manager.d.ts +105 -0
  51. package/dist/git/multi-source-manager.d.ts.map +1 -0
  52. package/dist/git/multi-source-manager.js +677 -0
  53. package/dist/git/multi-source-manager.js.map +1 -0
  54. package/dist/git/operations.d.ts +27 -0
  55. package/dist/git/operations.d.ts.map +1 -0
  56. package/dist/git/operations.js +83 -0
  57. package/dist/git/operations.js.map +1 -0
  58. package/dist/index.d.ts +6 -0
  59. package/dist/index.d.ts.map +1 -0
  60. package/dist/index.js +122 -0
  61. package/dist/index.js.map +1 -0
  62. package/dist/monitoring/health.d.ts +35 -0
  63. package/dist/monitoring/health.d.ts.map +1 -0
  64. package/dist/monitoring/health.js +105 -0
  65. package/dist/monitoring/health.js.map +1 -0
  66. package/dist/prompts/cache.d.ts +69 -0
  67. package/dist/prompts/cache.d.ts.map +1 -0
  68. package/dist/prompts/cache.js +163 -0
  69. package/dist/prompts/cache.js.map +1 -0
  70. package/dist/prompts/generator.d.ts +49 -0
  71. package/dist/prompts/generator.d.ts.map +1 -0
  72. package/dist/prompts/generator.js +160 -0
  73. package/dist/prompts/generator.js.map +1 -0
  74. package/dist/prompts/index.d.ts +13 -0
  75. package/dist/prompts/index.d.ts.map +1 -0
  76. package/dist/prompts/index.js +24 -0
  77. package/dist/prompts/index.js.map +1 -0
  78. package/dist/prompts/manager.d.ts +213 -0
  79. package/dist/prompts/manager.d.ts.map +1 -0
  80. package/dist/prompts/manager.js +587 -0
  81. package/dist/prompts/manager.js.map +1 -0
  82. package/dist/resources/index.d.ts +6 -0
  83. package/dist/resources/index.d.ts.map +1 -0
  84. package/dist/resources/index.js +10 -0
  85. package/dist/resources/index.js.map +1 -0
  86. package/dist/resources/loader.d.ts +88 -0
  87. package/dist/resources/loader.d.ts.map +1 -0
  88. package/dist/resources/loader.js +492 -0
  89. package/dist/resources/loader.js.map +1 -0
  90. package/dist/server/http.d.ts +57 -0
  91. package/dist/server/http.d.ts.map +1 -0
  92. package/dist/server/http.js +435 -0
  93. package/dist/server/http.js.map +1 -0
  94. package/dist/server.d.ts +13 -0
  95. package/dist/server.d.ts.map +1 -0
  96. package/dist/server.js +201 -0
  97. package/dist/server.js.map +1 -0
  98. package/dist/session/manager.d.ts +91 -0
  99. package/dist/session/manager.d.ts.map +1 -0
  100. package/dist/session/manager.js +251 -0
  101. package/dist/session/manager.js.map +1 -0
  102. package/dist/telemetry/index.d.ts +3 -0
  103. package/dist/telemetry/index.d.ts.map +1 -0
  104. package/dist/telemetry/index.js +7 -0
  105. package/dist/telemetry/index.js.map +1 -0
  106. package/dist/telemetry/manager.d.ts +151 -0
  107. package/dist/telemetry/manager.d.ts.map +1 -0
  108. package/dist/telemetry/manager.js +367 -0
  109. package/dist/telemetry/manager.js.map +1 -0
  110. package/dist/tools/index.d.ts +13 -0
  111. package/dist/tools/index.d.ts.map +1 -0
  112. package/dist/tools/index.js +29 -0
  113. package/dist/tools/index.js.map +1 -0
  114. package/dist/tools/manage-subscription.d.ts +47 -0
  115. package/dist/tools/manage-subscription.d.ts.map +1 -0
  116. package/dist/tools/manage-subscription.js +317 -0
  117. package/dist/tools/manage-subscription.js.map +1 -0
  118. package/dist/tools/registry.d.ts +40 -0
  119. package/dist/tools/registry.d.ts.map +1 -0
  120. package/dist/tools/registry.js +85 -0
  121. package/dist/tools/registry.js.map +1 -0
  122. package/dist/tools/resolve-prompt-content.d.ts +35 -0
  123. package/dist/tools/resolve-prompt-content.d.ts.map +1 -0
  124. package/dist/tools/resolve-prompt-content.js +99 -0
  125. package/dist/tools/resolve-prompt-content.js.map +1 -0
  126. package/dist/tools/search-resources.d.ts +35 -0
  127. package/dist/tools/search-resources.d.ts.map +1 -0
  128. package/dist/tools/search-resources.js +159 -0
  129. package/dist/tools/search-resources.js.map +1 -0
  130. package/dist/tools/sync-resources.d.ts +54 -0
  131. package/dist/tools/sync-resources.d.ts.map +1 -0
  132. package/dist/tools/sync-resources.js +793 -0
  133. package/dist/tools/sync-resources.js.map +1 -0
  134. package/dist/tools/track-usage.d.ts +63 -0
  135. package/dist/tools/track-usage.d.ts.map +1 -0
  136. package/dist/tools/track-usage.js +90 -0
  137. package/dist/tools/track-usage.js.map +1 -0
  138. package/dist/tools/uninstall-resource.d.ts +30 -0
  139. package/dist/tools/uninstall-resource.d.ts.map +1 -0
  140. package/dist/tools/uninstall-resource.js +186 -0
  141. package/dist/tools/uninstall-resource.js.map +1 -0
  142. package/dist/tools/upload-resource.d.ts +81 -0
  143. package/dist/tools/upload-resource.d.ts.map +1 -0
  144. package/dist/tools/upload-resource.js +393 -0
  145. package/dist/tools/upload-resource.js.map +1 -0
  146. package/dist/transport/sse.d.ts +29 -0
  147. package/dist/transport/sse.d.ts.map +1 -0
  148. package/dist/transport/sse.js +271 -0
  149. package/dist/transport/sse.js.map +1 -0
  150. package/dist/types/errors.d.ts +60 -0
  151. package/dist/types/errors.d.ts.map +1 -0
  152. package/dist/types/errors.js +112 -0
  153. package/dist/types/errors.js.map +1 -0
  154. package/dist/types/index.d.ts +7 -0
  155. package/dist/types/index.d.ts.map +1 -0
  156. package/dist/types/index.js +23 -0
  157. package/dist/types/index.js.map +1 -0
  158. package/dist/types/mcp.d.ts +50 -0
  159. package/dist/types/mcp.d.ts.map +1 -0
  160. package/dist/types/mcp.js +6 -0
  161. package/dist/types/mcp.js.map +1 -0
  162. package/dist/types/resources.d.ts +109 -0
  163. package/dist/types/resources.d.ts.map +1 -0
  164. package/dist/types/resources.js +7 -0
  165. package/dist/types/resources.js.map +1 -0
  166. package/dist/types/tools.d.ts +274 -0
  167. package/dist/types/tools.d.ts.map +1 -0
  168. package/dist/types/tools.js +6 -0
  169. package/dist/types/tools.js.map +1 -0
  170. package/dist/utils/cursor-paths.d.ts +84 -0
  171. package/dist/utils/cursor-paths.d.ts.map +1 -0
  172. package/dist/utils/cursor-paths.js +166 -0
  173. package/dist/utils/cursor-paths.js.map +1 -0
  174. package/dist/utils/log-cleaner.d.ts +18 -0
  175. package/dist/utils/log-cleaner.d.ts.map +1 -0
  176. package/dist/utils/log-cleaner.js +112 -0
  177. package/dist/utils/log-cleaner.js.map +1 -0
  178. package/dist/utils/logger.d.ts +59 -0
  179. package/dist/utils/logger.d.ts.map +1 -0
  180. package/dist/utils/logger.js +292 -0
  181. package/dist/utils/logger.js.map +1 -0
  182. package/dist/utils/validation.d.ts +58 -0
  183. package/dist/utils/validation.d.ts.map +1 -0
  184. package/dist/utils/validation.js +214 -0
  185. package/dist/utils/validation.js.map +1 -0
  186. package/package.json +1 -1
@@ -0,0 +1,109 @@
1
+ /**
2
+ * AI Resources Type Definitions
3
+ * Defines types for multi-source AI resource management
4
+ */
5
+ /**
6
+ * Resource type enumeration
7
+ */
8
+ export type ResourceType = 'commands' | 'skills' | 'mcp' | 'rules';
9
+ /**
10
+ * Resource source configuration
11
+ */
12
+ export interface ResourceSource {
13
+ /** Source name (identifier) */
14
+ name: string;
15
+ /** Relative path to AI-Resources root */
16
+ path: string;
17
+ /** Whether this source is enabled */
18
+ enabled: boolean;
19
+ /** Priority (higher number = higher priority) */
20
+ priority: number;
21
+ /** Mapping of resource types to subdirectories */
22
+ resources: Partial<Record<ResourceType, string>>;
23
+ /** Optional description */
24
+ description?: string;
25
+ }
26
+ /**
27
+ * AI Resources configuration
28
+ */
29
+ export interface AIResourcesConfig {
30
+ /** Configuration version */
31
+ version: string;
32
+ /** Optional description */
33
+ description?: string;
34
+ /** Default resource source (always loaded) */
35
+ default_source: ResourceSource;
36
+ /** Extended resource sources */
37
+ extended_sources: ResourceSource[];
38
+ /** Supported resource types */
39
+ resource_types: ResourceType[];
40
+ /** Loading order strategy */
41
+ loading_order: 'priority_desc' | 'priority_asc' | 'name_asc';
42
+ /** Conflict resolution strategy */
43
+ conflict_resolution: 'highest_priority_wins' | 'merge' | 'error';
44
+ /** Cache configuration */
45
+ cache?: {
46
+ enabled: boolean;
47
+ ttl: number;
48
+ };
49
+ }
50
+ /**
51
+ * Resource metadata
52
+ */
53
+ export interface ResourceMetadata {
54
+ /** Resource ID */
55
+ id: string;
56
+ /** Resource name */
57
+ name: string;
58
+ /** Resource type */
59
+ type: ResourceType;
60
+ /** Source name */
61
+ source: string;
62
+ /** Source priority */
63
+ priority: number;
64
+ /** Full file path */
65
+ path: string;
66
+ /** Version (if available) */
67
+ version?: string;
68
+ /** Description (if available) */
69
+ description?: string;
70
+ /** Tags (if available) */
71
+ tags?: string[];
72
+ }
73
+ /**
74
+ * Resource conflict information
75
+ */
76
+ export interface ResourceConflict {
77
+ /** Resource name */
78
+ name: string;
79
+ /** Resource type */
80
+ type: ResourceType;
81
+ /** Conflicting resources */
82
+ conflicts: Array<{
83
+ source: string;
84
+ priority: number;
85
+ path: string;
86
+ }>;
87
+ /** Selected resource (after conflict resolution) */
88
+ selected: {
89
+ source: string;
90
+ priority: number;
91
+ path: string;
92
+ };
93
+ }
94
+ /**
95
+ * Resource loader statistics
96
+ */
97
+ export interface LoaderStats {
98
+ /** Total sources loaded */
99
+ sourcesLoaded: number;
100
+ /** Total resources indexed */
101
+ resourcesIndexed: number;
102
+ /** Resources by type */
103
+ byType: Record<ResourceType, number>;
104
+ /** Conflicts detected */
105
+ conflictsDetected: number;
106
+ /** Load duration (ms) */
107
+ loadDuration: number;
108
+ }
109
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../src/types/resources.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,UAAU,GAAG,QAAQ,GAAG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,IAAI,EAAE,MAAM,CAAC;IAEb,6BAA6B;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,iCAAiC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAC;IAEb,oBAAoB;IACpB,IAAI,EAAE,YAAY,CAAC;IAEnB,4BAA4B;IAC5B,SAAS,EAAE,KAAK,CAAC;QACf,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IAEH,oDAAoD;IACpD,QAAQ,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,aAAa,EAAE,MAAM,CAAC;IAEtB,8BAA8B;IAC9B,gBAAgB,EAAE,MAAM,CAAC;IAEzB,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;IAErC,yBAAyB;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,yBAAyB;IACzB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * AI Resources Type Definitions
4
+ * Defines types for multi-source AI resource management
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=resources.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.js","sourceRoot":"","sources":["../../src/types/resources.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
@@ -0,0 +1,274 @@
1
+ /**
2
+ * MCP Tool Types
3
+ */
4
+ import type { MCPToolSchema } from './mcp';
5
+ export interface WriteFileAction {
6
+ action: 'write_file';
7
+ /** Absolute path on the user's local machine (may start with ~). */
8
+ path: string;
9
+ /** File content to write. */
10
+ content: string;
11
+ /** File encoding (default: utf8). Set to base64 for binary files. */
12
+ encoding?: 'utf8' | 'base64';
13
+ /** File permissions in octal string format (e.g. "0755" for executable, "0644" for regular). Unix only. */
14
+ mode?: string;
15
+ /**
16
+ * Special marker for SKILL.md files in complex skills.
17
+ * When true, client should check this file's content FIRST.
18
+ * If content matches local file exactly (string equality), skip this action AND all subsequent write_file actions until next skill or different action type.
19
+ * This enables atomic skill-level updates (skip all or download all).
20
+ */
21
+ is_skill_manifest?: boolean;
22
+ }
23
+ export interface DeleteFileAction {
24
+ action: 'delete_file';
25
+ /** Absolute path on the user's local machine (may start with ~). */
26
+ path: string;
27
+ /** When true, recursively delete a directory. */
28
+ recursive?: boolean;
29
+ }
30
+ export interface MergeMcpJsonAction {
31
+ action: 'merge_mcp_json';
32
+ /** Absolute path to the user's mcp.json file. */
33
+ mcp_json_path: string;
34
+ /** Key under mcpServers to add or update. */
35
+ server_name: string;
36
+ /** The MCP server entry object to merge in. */
37
+ entry: Record<string, unknown>;
38
+ /** env keys that are currently empty and must be filled by the user. */
39
+ missing_env?: string[];
40
+ /** Human-readable hint when manual env configuration is required. */
41
+ setup_hint?: string;
42
+ /** Path to a local setup/readme doc if one exists in the install dir. */
43
+ setup_doc?: string;
44
+ /**
45
+ * When true, the AI MUST skip this action if `mcpServers[server_name]`
46
+ * already exists in mcp.json (regardless of content).
47
+ * Use this for idempotent installs where re-writing would clobber
48
+ * user-customised values (e.g. env vars the user has already filled in).
49
+ */
50
+ skip_if_exists?: boolean;
51
+ }
52
+ export interface RemoveMcpJsonEntryAction {
53
+ action: 'remove_mcp_json_entry';
54
+ /** Absolute path to the user's mcp.json file. */
55
+ mcp_json_path: string;
56
+ /** Key under mcpServers to remove. */
57
+ server_name: string;
58
+ }
59
+ export type LocalAction = WriteFileAction | DeleteFileAction | MergeMcpJsonAction | RemoveMcpJsonEntryAction;
60
+ export type ToolHandler = (params: unknown) => Promise<ToolResult>;
61
+ export interface ToolDefinition {
62
+ name: string;
63
+ description: string;
64
+ inputSchema: MCPToolSchema;
65
+ handler: ToolHandler;
66
+ }
67
+ export interface ToolResult<T = unknown> {
68
+ success: boolean;
69
+ data?: T;
70
+ error?: {
71
+ code: string;
72
+ message: string;
73
+ details?: unknown;
74
+ };
75
+ }
76
+ export interface SyncResourcesParams {
77
+ mode?: 'check' | 'incremental' | 'full';
78
+ scope?: 'global' | 'workspace' | 'all';
79
+ types?: string[];
80
+ /**
81
+ * CSP API token from the user's mcp.json env configuration.
82
+ * Overrides the server-level fallback token so that each user
83
+ * makes API calls with their own identity.
84
+ */
85
+ user_token?: string;
86
+ /**
87
+ * List of MCP server names that are already configured in the user's
88
+ * ~/.cursor/mcp.json. The server will skip downloading and generating
89
+ * write_file actions for these MCP resources to reduce overhead.
90
+ *
91
+ * Set this to the keys from mcpServers in ~/.cursor/mcp.json:
92
+ * Object.keys(JSON.parse(fs.readFileSync('~/.cursor/mcp.json')).mcpServers || {})
93
+ *
94
+ * Only applies in 'incremental' mode; 'full' mode always downloads everything.
95
+ */
96
+ configured_mcp_servers?: string[];
97
+ }
98
+ export interface McpSetupItem {
99
+ /** MCP server name as it appears in mcp.json */
100
+ server_name: string;
101
+ /** Human-readable path to mcp.json on this platform */
102
+ mcp_json_path: string;
103
+ /** env keys that are currently empty and need user input */
104
+ missing_env: string[];
105
+ /** true when the registered command might not be correct for this machine */
106
+ command_needs_verification: boolean;
107
+ /** the command string that was registered */
108
+ command: string;
109
+ /** freeform guidance shown to the user */
110
+ setup_hint: string;
111
+ /** absolute path to a local setup/readme doc found in the install directory, if any */
112
+ setup_doc?: string;
113
+ }
114
+ export interface SyncResourcesResult {
115
+ mode: string;
116
+ health_score: number;
117
+ summary: {
118
+ total: number;
119
+ synced: number;
120
+ cached: number;
121
+ /** Number of resources skipped due to no local changes (incremental mode only). */
122
+ skipped: number;
123
+ failed: number;
124
+ };
125
+ details: Array<{
126
+ id: string;
127
+ name: string;
128
+ action: string;
129
+ version: string;
130
+ }>;
131
+ /**
132
+ * List of resource names that were skipped during incremental sync because
133
+ * local files are already up-to-date (hash match). Present only when skipped > 0.
134
+ */
135
+ skipped_resources?: Array<{
136
+ name: string;
137
+ reason: 'already_up_to_date' | 'no_local_sync_needed' | 'mcp_already_configured';
138
+ }>;
139
+ /**
140
+ * MCP servers that were installed/updated but require manual configuration
141
+ * before they can be used. Present only when at least one server needs setup.
142
+ * @deprecated use local_actions_required MergeMcpJsonAction.missing_env instead
143
+ */
144
+ pending_setup?: McpSetupItem[];
145
+ /**
146
+ * Ordered list of file-system and mcp.json operations the AI Agent must
147
+ * execute on the user's LOCAL machine after receiving this response.
148
+ * Present only when at least one Rule or MCP resource was synced.
149
+ *
150
+ * The AI MUST execute every action in order before reporting success to the
151
+ * user. See LocalAction type variants for details.
152
+ */
153
+ local_actions_required?: LocalAction[];
154
+ }
155
+ export interface ManageSubscriptionParams {
156
+ action: 'subscribe' | 'unsubscribe' | 'list' | 'batch_subscribe' | 'batch_unsubscribe';
157
+ resource_ids?: string[];
158
+ auto_sync?: boolean;
159
+ scope?: 'global' | 'workspace';
160
+ notify?: boolean;
161
+ /** CSP API token from the user's mcp.json env configuration. */
162
+ user_token?: string;
163
+ }
164
+ export interface ManageSubscriptionResult {
165
+ action: string;
166
+ success: boolean;
167
+ subscriptions?: Array<{
168
+ id: string;
169
+ name: string;
170
+ type: string;
171
+ subscribed_at: string;
172
+ }>;
173
+ message?: string;
174
+ /** Sync results for each resource after auto-sync on subscribe */
175
+ sync_details?: Array<{
176
+ id: string;
177
+ name: string;
178
+ action: string;
179
+ }>;
180
+ /** MCP servers that need manual configuration after auto-sync */
181
+ pending_setup?: unknown[];
182
+ }
183
+ export interface SearchResourcesParams {
184
+ team?: string;
185
+ type?: string;
186
+ keyword: string;
187
+ /** CSP API token from the user's mcp.json env configuration. */
188
+ user_token?: string;
189
+ }
190
+ export interface SearchResourcesResult {
191
+ total: number;
192
+ results: Array<{
193
+ id: string;
194
+ name: string;
195
+ type: string;
196
+ team: string;
197
+ version: string;
198
+ description: string;
199
+ score: number;
200
+ is_subscribed: boolean;
201
+ is_installed: boolean;
202
+ }>;
203
+ }
204
+ export interface ResolvePromptContentParams {
205
+ prompt_name?: string;
206
+ resource_id?: string;
207
+ /** CSP API token from the user's mcp.json env configuration. */
208
+ user_token?: string;
209
+ /** Optional Jira Issue ID for usage correlation. */
210
+ jira_id?: string;
211
+ }
212
+ export interface ResolvePromptContentResult {
213
+ prompt_name: string;
214
+ resource_id: string;
215
+ resource_type: 'command' | 'skill';
216
+ resource_name: string;
217
+ description: string;
218
+ content: string;
219
+ content_source: 'cache' | 'generated' | 'raw_fallback';
220
+ usage_tracked: boolean;
221
+ }
222
+ export interface FileEntry {
223
+ path: string;
224
+ content: string;
225
+ }
226
+ export interface UploadResourceParams {
227
+ resource_id: string;
228
+ /** Resource category. Optional — auto-detected from file structure when omitted. */
229
+ type?: 'command' | 'skill' | 'rule' | 'mcp';
230
+ message: string;
231
+ /** Human-readable resource name sent to the CSP API. Defaults to the primary file name (without extension). */
232
+ name?: string;
233
+ /** Target source repo from ai-resources-config.json (e.g. "csp", "client-sdk-ai-hub"). Defaults to default_source. */
234
+ target_source?: string;
235
+ team?: string;
236
+ /** File list to upload. Paths are relative to the type subdir of the chosen source. Any file extension allowed. */
237
+ files: FileEntry[];
238
+ title?: string;
239
+ metadata?: Record<string, unknown>;
240
+ /** CSP API token from the user's mcp.json env configuration. */
241
+ user_token?: string;
242
+ }
243
+ export interface UploadResourceResult {
244
+ resource_id: string;
245
+ version: string;
246
+ url: string;
247
+ commit_hash: string;
248
+ message: string;
249
+ }
250
+ export interface UninstallResourceParams {
251
+ resource_id_or_name: string;
252
+ remove_from_account?: boolean;
253
+ /** When known, the resource type — narrows which local_actions are emitted. */
254
+ resource_type?: 'command' | 'skill' | 'rule' | 'mcp';
255
+ /** CSP API token from the user's mcp.json env configuration. */
256
+ user_token?: string;
257
+ }
258
+ export interface UninstallResourceResult {
259
+ success: boolean;
260
+ removed_resources: Array<{
261
+ id: string;
262
+ name: string;
263
+ path: string;
264
+ }>;
265
+ subscription_removed: boolean;
266
+ message: string;
267
+ /**
268
+ * Ordered list of file-system and mcp.json operations the AI Agent must
269
+ * execute on the user's LOCAL machine after receiving this response.
270
+ * Present only for Rule and local-executable MCP resources.
271
+ */
272
+ local_actions_required?: LocalAction[];
273
+ }
274
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAc3C,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,YAAY,CAAC;IACrB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC7B,2GAA2G;IAC3G,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,aAAa,CAAC;IACtB,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,CAAC;IACzB,iDAAiD;IACjD,aAAa,EAAE,MAAM,CAAC;IACtB,6CAA6C;IAC7C,WAAW,EAAE,MAAM,CAAC;IACpB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B,wEAAwE;IAC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ChB,GAAG,EAAE,MAAM,CAAC;IACZ,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAGD,MAAM,WAAW,uBAAuB;IACtC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,+EAA+E;IAC/E,aAAa,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC;IACrD,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,OAAO,CAAC;IACjB,iBAAiB,EAAE,KAAK,CAAC;QACvB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,WAAW,EAAE,CAAC;CACxC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ /**
3
+ * MCP Tool Types
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ //# sourceMappingURL=tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/types/tools.ts"],"names":[],"mappings":";AAAA;;GAEG"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Cursor IDE standard directory path resolver.
3
+ *
4
+ * Cursor stores user-level assets in platform-specific locations:
5
+ * macOS / Linux : ~/.cursor/<type>/
6
+ * Windows : %APPDATA%\Cursor\User\<type>\
7
+ * (typically C:\Users\<user>\AppData\Roaming\Cursor\User\<type>\)
8
+ *
9
+ * Resource type → subdirectory mapping mirrors the actual Cursor directory layout.
10
+ */
11
+ /** Supported Cursor resource types and their directory names. */
12
+ export declare const CURSOR_TYPE_DIRS: Record<string, string>;
13
+ /**
14
+ * Returns the root of the Cursor user directory on the current platform.
15
+ *
16
+ * macOS / Linux : ~/.cursor
17
+ * Windows : %APPDATA%\Cursor\User
18
+ *
19
+ * NOTE: Only use this when running code on the USER's local machine.
20
+ * When generating paths for LocalAction instructions (which are executed by the
21
+ * AI on the user's machine, not on this server), use getCursorRootDirForClient()
22
+ * instead to avoid returning the server's home directory.
23
+ */
24
+ export declare function getCursorRootDir(): string;
25
+ /**
26
+ * Returns a platform-neutral Cursor root path for use in LocalAction instructions.
27
+ *
28
+ * LocalAction paths are sent to the AI Agent running on the USER's local machine,
29
+ * not executed on this (possibly remote) server. Using os.homedir() here would
30
+ * produce the server's home directory (e.g. /root/.cursor on a Linux server),
31
+ * which is wrong when the user is on macOS or Windows.
32
+ *
33
+ * We return a tilde-prefixed path ("~/.cursor") which the AI / shell on the
34
+ * user's machine will expand to the correct home directory automatically.
35
+ * For Windows we still return the APPDATA-relative form as a hint, but note
36
+ * that the AI is expected to expand %APPDATA% on the client side.
37
+ */
38
+ export declare function getCursorRootDirForClient(): string;
39
+ /**
40
+ * Returns the Cursor subdirectory for a given resource type, using a
41
+ * client-side portable path (tilde-based). Use this when building paths
42
+ * that will be included in LocalAction instructions.
43
+ */
44
+ export declare function getCursorTypeDirForClient(resourceType: string): string;
45
+ /**
46
+ * Returns the Cursor subdirectory for a given resource type.
47
+ *
48
+ * @param resourceType - API resource type string (e.g. 'skill', 'command', 'rule', 'mcp')
49
+ * @returns Absolute path to the matching Cursor directory
50
+ * @throws Error if the resource type is not recognised
51
+ *
52
+ * @example
53
+ * getCursorTypeDir('skill') // ~/.cursor/skills
54
+ * getCursorTypeDir('command') // ~/.cursor/commands
55
+ * getCursorTypeDir('rule') // ~/.cursor/rules
56
+ * getCursorTypeDir('mcp') // ~/.cursor/mcp-servers
57
+ */
58
+ export declare function getCursorTypeDir(resourceType: string): string;
59
+ /**
60
+ * Returns the install path for a specific named resource.
61
+ *
62
+ * For directory-based resources (skill, mcp) the result is a directory:
63
+ * ~/.cursor/skills/<name>/
64
+ *
65
+ * For file-based resources (command, rule) the result is the file path
66
+ * preserving the original filename (caller should pass name with extension):
67
+ * ~/.cursor/commands/<name> (e.g. generate-testcase.md)
68
+ * ~/.cursor/rules/<name> (e.g. elliotTest.mdc)
69
+ *
70
+ * @param resourceType - Resource type string
71
+ * @param resourceName - Resource name (with or without extension)
72
+ */
73
+ export declare function getCursorResourcePath(resourceType: string, resourceName: string): string;
74
+ /**
75
+ * Returns the path to the local AI resource telemetry file.
76
+ *
77
+ * Stored at the Cursor root level (not inside a resource-type subdirectory)
78
+ * so it persists independently of individual resource installs/uninstalls.
79
+ *
80
+ * macOS / Linux : ~/.cursor/ai-resource-telemetry.json
81
+ * Windows : %APPDATA%\Cursor\User\ai-resource-telemetry.json
82
+ */
83
+ export declare function getTelemetryFilePath(): string;
84
+ //# sourceMappingURL=cursor-paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cursor-paths.d.ts","sourceRoot":"","sources":["../../src/utils/cursor-paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,iEAAiE;AACjE,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CASnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAQzC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAGlD;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAStE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAS7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CAAC,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAExF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C"}
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ /**
3
+ * Cursor IDE standard directory path resolver.
4
+ *
5
+ * Cursor stores user-level assets in platform-specific locations:
6
+ * macOS / Linux : ~/.cursor/<type>/
7
+ * Windows : %APPDATA%\Cursor\User\<type>\
8
+ * (typically C:\Users\<user>\AppData\Roaming\Cursor\User\<type>\)
9
+ *
10
+ * Resource type → subdirectory mapping mirrors the actual Cursor directory layout.
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.CURSOR_TYPE_DIRS = void 0;
47
+ exports.getCursorRootDir = getCursorRootDir;
48
+ exports.getCursorRootDirForClient = getCursorRootDirForClient;
49
+ exports.getCursorTypeDirForClient = getCursorTypeDirForClient;
50
+ exports.getCursorTypeDir = getCursorTypeDir;
51
+ exports.getCursorResourcePath = getCursorResourcePath;
52
+ exports.getTelemetryFilePath = getTelemetryFilePath;
53
+ const os = __importStar(require("os"));
54
+ const path = __importStar(require("path"));
55
+ /** Supported Cursor resource types and their directory names. */
56
+ exports.CURSOR_TYPE_DIRS = {
57
+ skill: 'skills',
58
+ skills: 'skills',
59
+ command: 'commands',
60
+ commands: 'commands',
61
+ rule: 'rules',
62
+ rules: 'rules',
63
+ mcp: 'mcp-servers',
64
+ 'mcp-servers': 'mcp-servers',
65
+ };
66
+ /**
67
+ * Returns the root of the Cursor user directory on the current platform.
68
+ *
69
+ * macOS / Linux : ~/.cursor
70
+ * Windows : %APPDATA%\Cursor\User
71
+ *
72
+ * NOTE: Only use this when running code on the USER's local machine.
73
+ * When generating paths for LocalAction instructions (which are executed by the
74
+ * AI on the user's machine, not on this server), use getCursorRootDirForClient()
75
+ * instead to avoid returning the server's home directory.
76
+ */
77
+ function getCursorRootDir() {
78
+ if (process.platform === 'win32') {
79
+ // APPDATA is always set on Windows; fall back to USERPROFILE as a safety net
80
+ const appData = process.env.APPDATA ?? path.join(os.homedir(), 'AppData', 'Roaming');
81
+ return path.join(appData, 'Cursor', 'User');
82
+ }
83
+ // macOS and Linux both use ~/.cursor
84
+ return path.join(os.homedir(), '.cursor');
85
+ }
86
+ /**
87
+ * Returns a platform-neutral Cursor root path for use in LocalAction instructions.
88
+ *
89
+ * LocalAction paths are sent to the AI Agent running on the USER's local machine,
90
+ * not executed on this (possibly remote) server. Using os.homedir() here would
91
+ * produce the server's home directory (e.g. /root/.cursor on a Linux server),
92
+ * which is wrong when the user is on macOS or Windows.
93
+ *
94
+ * We return a tilde-prefixed path ("~/.cursor") which the AI / shell on the
95
+ * user's machine will expand to the correct home directory automatically.
96
+ * For Windows we still return the APPDATA-relative form as a hint, but note
97
+ * that the AI is expected to expand %APPDATA% on the client side.
98
+ */
99
+ function getCursorRootDirForClient() {
100
+ // Return a portable ~-based path; the AI on the user's machine expands it.
101
+ return '~/.cursor';
102
+ }
103
+ /**
104
+ * Returns the Cursor subdirectory for a given resource type, using a
105
+ * client-side portable path (tilde-based). Use this when building paths
106
+ * that will be included in LocalAction instructions.
107
+ */
108
+ function getCursorTypeDirForClient(resourceType) {
109
+ const subdir = exports.CURSOR_TYPE_DIRS[resourceType.toLowerCase()];
110
+ if (!subdir) {
111
+ throw new Error(`Unknown resource type "${resourceType}". ` +
112
+ `Supported types: ${Object.keys(exports.CURSOR_TYPE_DIRS).join(', ')}`);
113
+ }
114
+ return `${getCursorRootDirForClient()}/${subdir}`;
115
+ }
116
+ /**
117
+ * Returns the Cursor subdirectory for a given resource type.
118
+ *
119
+ * @param resourceType - API resource type string (e.g. 'skill', 'command', 'rule', 'mcp')
120
+ * @returns Absolute path to the matching Cursor directory
121
+ * @throws Error if the resource type is not recognised
122
+ *
123
+ * @example
124
+ * getCursorTypeDir('skill') // ~/.cursor/skills
125
+ * getCursorTypeDir('command') // ~/.cursor/commands
126
+ * getCursorTypeDir('rule') // ~/.cursor/rules
127
+ * getCursorTypeDir('mcp') // ~/.cursor/mcp-servers
128
+ */
129
+ function getCursorTypeDir(resourceType) {
130
+ const subdir = exports.CURSOR_TYPE_DIRS[resourceType.toLowerCase()];
131
+ if (!subdir) {
132
+ throw new Error(`Unknown resource type "${resourceType}". ` +
133
+ `Supported types: ${Object.keys(exports.CURSOR_TYPE_DIRS).join(', ')}`);
134
+ }
135
+ return path.join(getCursorRootDir(), subdir);
136
+ }
137
+ /**
138
+ * Returns the install path for a specific named resource.
139
+ *
140
+ * For directory-based resources (skill, mcp) the result is a directory:
141
+ * ~/.cursor/skills/<name>/
142
+ *
143
+ * For file-based resources (command, rule) the result is the file path
144
+ * preserving the original filename (caller should pass name with extension):
145
+ * ~/.cursor/commands/<name> (e.g. generate-testcase.md)
146
+ * ~/.cursor/rules/<name> (e.g. elliotTest.mdc)
147
+ *
148
+ * @param resourceType - Resource type string
149
+ * @param resourceName - Resource name (with or without extension)
150
+ */
151
+ function getCursorResourcePath(resourceType, resourceName) {
152
+ return path.join(getCursorTypeDir(resourceType), resourceName);
153
+ }
154
+ /**
155
+ * Returns the path to the local AI resource telemetry file.
156
+ *
157
+ * Stored at the Cursor root level (not inside a resource-type subdirectory)
158
+ * so it persists independently of individual resource installs/uninstalls.
159
+ *
160
+ * macOS / Linux : ~/.cursor/ai-resource-telemetry.json
161
+ * Windows : %APPDATA%\Cursor\User\ai-resource-telemetry.json
162
+ */
163
+ function getTelemetryFilePath() {
164
+ return path.join(getCursorRootDir(), 'ai-resource-telemetry.json');
165
+ }
166
+ //# sourceMappingURL=cursor-paths.js.map