wave-agent-sdk 0.13.6 → 0.14.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 (85) hide show
  1. package/dist/agent.d.ts.map +1 -1
  2. package/dist/agent.js +4 -2
  3. package/dist/core/plugin.d.ts +2 -2
  4. package/dist/core/plugin.d.ts.map +1 -1
  5. package/dist/core/plugin.js +7 -7
  6. package/dist/managers/aiManager.d.ts +3 -0
  7. package/dist/managers/aiManager.d.ts.map +1 -1
  8. package/dist/managers/aiManager.js +93 -8
  9. package/dist/managers/backgroundTaskManager.d.ts.map +1 -1
  10. package/dist/managers/backgroundTaskManager.js +0 -12
  11. package/dist/managers/messageManager.d.ts +15 -0
  12. package/dist/managers/messageManager.d.ts.map +1 -1
  13. package/dist/managers/messageManager.js +52 -2
  14. package/dist/managers/permissionManager.d.ts +4 -0
  15. package/dist/managers/permissionManager.d.ts.map +1 -1
  16. package/dist/managers/permissionManager.js +6 -0
  17. package/dist/managers/pluginManager.d.ts.map +1 -1
  18. package/dist/managers/pluginManager.js +1 -1
  19. package/dist/managers/subagentManager.d.ts.map +1 -1
  20. package/dist/managers/subagentManager.js +23 -17
  21. package/dist/prompts/index.d.ts +2 -1
  22. package/dist/prompts/index.d.ts.map +1 -1
  23. package/dist/prompts/index.js +50 -25
  24. package/dist/services/MarketplaceService.d.ts +53 -12
  25. package/dist/services/MarketplaceService.d.ts.map +1 -1
  26. package/dist/services/MarketplaceService.js +311 -123
  27. package/dist/services/aiService.d.ts.map +1 -1
  28. package/dist/services/aiService.js +11 -1
  29. package/dist/services/configurationService.d.ts +17 -1
  30. package/dist/services/configurationService.d.ts.map +1 -1
  31. package/dist/services/configurationService.js +104 -0
  32. package/dist/services/pluginLoader.d.ts +6 -0
  33. package/dist/services/pluginLoader.d.ts.map +1 -1
  34. package/dist/services/pluginLoader.js +52 -7
  35. package/dist/tools/agentTool.d.ts.map +1 -1
  36. package/dist/tools/agentTool.js +14 -2
  37. package/dist/tools/bashTool.d.ts.map +1 -1
  38. package/dist/tools/bashTool.js +27 -5
  39. package/dist/tools/types.d.ts +1 -0
  40. package/dist/tools/types.d.ts.map +1 -1
  41. package/dist/tools/webFetchTool.d.ts.map +1 -1
  42. package/dist/tools/webFetchTool.js +202 -78
  43. package/dist/types/configuration.d.ts +7 -0
  44. package/dist/types/configuration.d.ts.map +1 -1
  45. package/dist/types/marketplace.d.ts +28 -1
  46. package/dist/types/marketplace.d.ts.map +1 -1
  47. package/dist/types/messaging.d.ts +1 -0
  48. package/dist/types/messaging.d.ts.map +1 -1
  49. package/dist/types/plugins.d.ts +13 -1
  50. package/dist/types/plugins.d.ts.map +1 -1
  51. package/dist/utils/convertMessagesForAPI.js +1 -1
  52. package/dist/utils/groupMessagesByApiRound.d.ts +24 -0
  53. package/dist/utils/groupMessagesByApiRound.d.ts.map +1 -0
  54. package/dist/utils/groupMessagesByApiRound.js +97 -0
  55. package/dist/utils/messageOperations.d.ts +1 -0
  56. package/dist/utils/messageOperations.d.ts.map +1 -1
  57. package/dist/utils/microcompact.d.ts +7 -0
  58. package/dist/utils/microcompact.d.ts.map +1 -0
  59. package/dist/utils/microcompact.js +78 -0
  60. package/package.json +2 -1
  61. package/src/agent.ts +4 -2
  62. package/src/core/plugin.ts +13 -7
  63. package/src/managers/aiManager.ts +117 -15
  64. package/src/managers/backgroundTaskManager.ts +1 -20
  65. package/src/managers/messageManager.ts +64 -2
  66. package/src/managers/permissionManager.ts +7 -0
  67. package/src/managers/pluginManager.ts +4 -1
  68. package/src/managers/subagentManager.ts +28 -24
  69. package/src/prompts/index.ts +51 -25
  70. package/src/services/MarketplaceService.ts +425 -134
  71. package/src/services/aiService.ts +14 -1
  72. package/src/services/configurationService.ts +131 -0
  73. package/src/services/pluginLoader.ts +66 -7
  74. package/src/tools/agentTool.ts +14 -2
  75. package/src/tools/bashTool.ts +27 -5
  76. package/src/tools/types.ts +1 -0
  77. package/src/tools/webFetchTool.ts +276 -86
  78. package/src/types/configuration.ts +8 -0
  79. package/src/types/marketplace.ts +26 -1
  80. package/src/types/messaging.ts +1 -0
  81. package/src/types/plugins.ts +13 -1
  82. package/src/utils/convertMessagesForAPI.ts +1 -1
  83. package/src/utils/groupMessagesByApiRound.ts +120 -0
  84. package/src/utils/messageOperations.ts +1 -0
  85. package/src/utils/microcompact.ts +101 -0
@@ -371,20 +371,23 @@ export class SubagentManager {
371
371
  instance.logStream?.end();
372
372
  const task = backgroundTaskManager.getTask(instance.backgroundTaskId);
373
373
  if (task) {
374
+ const wasAlreadyKilled = task.status === "killed";
374
375
  task.status = "completed";
375
376
  task.stdout = response || "Agent completed with no text response";
376
377
  task.endTime = Date.now();
377
378
  if (task.startTime) {
378
379
  task.runtime = task.endTime - task.startTime;
379
380
  }
380
- }
381
- // Enqueue completion notification
382
- const notificationQueue = this.container.has("NotificationQueue")
383
- ? this.container.get("NotificationQueue")
384
- : undefined;
385
- if (notificationQueue) {
386
- const summary = `Agent task "${instance.description}" completed`;
387
- notificationQueue.enqueue(`<task-notification>\n<task-id>${instance.backgroundTaskId}</task-id>\n<task-type>agent</task-type>\n<status>completed</status>\n<summary>${summary}</summary>\n</task-notification>`);
381
+ // Skip notification if task was already stopped (e.g. by main agent shutdown)
382
+ if (!wasAlreadyKilled) {
383
+ const notificationQueue = this.container.has("NotificationQueue")
384
+ ? this.container.get("NotificationQueue")
385
+ : undefined;
386
+ if (notificationQueue) {
387
+ const summary = `Agent task "${instance.description}" completed`;
388
+ notificationQueue.enqueue(`<task-notification>\n<task-id>${instance.backgroundTaskId}</task-id>\n<task-type>agent</task-type>\n<status>completed</status>\n<summary>${summary}</summary>\n</task-notification>`);
389
+ }
390
+ }
388
391
  }
389
392
  }
390
393
  return response || "Agent completed with no text response";
@@ -400,21 +403,24 @@ export class SubagentManager {
400
403
  instance.logStream?.end();
401
404
  const task = backgroundTaskManager.getTask(instance.backgroundTaskId);
402
405
  if (task) {
406
+ const wasAlreadyKilled = task.status === "killed";
403
407
  task.status = "failed";
404
408
  task.stderr = error instanceof Error ? error.message : String(error);
405
409
  task.endTime = Date.now();
406
410
  if (task.startTime) {
407
411
  task.runtime = task.endTime - task.startTime;
408
412
  }
409
- }
410
- // Enqueue error notification
411
- const notificationQueue = this.container.has("NotificationQueue")
412
- ? this.container.get("NotificationQueue")
413
- : undefined;
414
- if (notificationQueue) {
415
- const errorMsg = error instanceof Error ? error.message : String(error);
416
- const summary = `Agent task "${instance.description}" failed: ${errorMsg}`;
417
- notificationQueue.enqueue(`<task-notification>\n<task-id>${instance.backgroundTaskId}</task-id>\n<task-type>agent</task-type>\n<status>failed</status>\n<summary>${summary}</summary>\n</task-notification>`);
413
+ // Skip notification if task was already stopped (e.g. by main agent shutdown)
414
+ if (!wasAlreadyKilled) {
415
+ const notificationQueue = this.container.has("NotificationQueue")
416
+ ? this.container.get("NotificationQueue")
417
+ : undefined;
418
+ if (notificationQueue) {
419
+ const errorMsg = error instanceof Error ? error.message : String(error);
420
+ const summary = `Agent task "${instance.description}" failed: ${errorMsg}`;
421
+ notificationQueue.enqueue(`<task-notification>\n<task-id>${instance.backgroundTaskId}</task-id>\n<task-type>agent</task-type>\n<status>failed</status>\n<summary>${summary}</summary>\n</task-notification>`);
422
+ }
423
+ }
418
424
  }
419
425
  }
420
426
  throw error;
@@ -12,11 +12,12 @@ export declare const OUTPUT_EFFICIENCY_PROMPT = "# Output efficiency\n\nIMPORTAN
12
12
  export declare const TONE_AND_STYLE_PROMPT = "# Tone and style\n\n- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.\n- Your responses should be short and concise.\n- When referencing specific functions or pieces of code include the pattern file_path:line_number to allow the user to easily navigate to the source code location.\n- When referencing GitHub issues or pull requests, use the owner/repo#123 format (e.g. anthropics/claude-code#100) so they render as clickable links.\n- Do not use a colon before tool calls. Your tool calls may not be shown directly in the output, so text like \"Let me read the file:\" followed by a read tool call should just be \"Let me read the file.\" with a period.";
13
13
  export declare function buildPlanModePrompt(planFilePath: string, planExists: boolean, isSubagent?: boolean): string;
14
14
  export declare const DEFAULT_SYSTEM_PROMPT = "You are an interactive CLI tool that helps users with software engineering tasks. Use the instructions below and the tools available to you to assist the user.";
15
- export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:\n1. Task Overview\nThe user's core request and success criteria\nAny clarifications or constraints they specified\n2. Current State\nWhat has been completed so far\nFiles created, modified, or analyzed (with paths if relevant)\nKey outputs or artifacts produced\n3. Important Discoveries\nTechnical constraints or requirements uncovered\nDecisions made and their rationale\nErrors encountered and how they were resolved\nWhat approaches were tried that didn't work (and why)\n4. Next Steps\nSpecific actions needed to complete the task\nAny blockers or open questions to resolve\nPriority order if multiple steps remain\n5. Context to Preserve\nUser preferences or style requirements\nDomain-specific details that aren't obvious\nAny promises made to the user\nBe concise but complete\u2014err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.\nWrap your summary in <summary></summary> tags.";
15
+ export declare const COMPRESS_MESSAGES_SYSTEM_PROMPT = "You are continuing work on a software engineering task. Write a detailed continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary.\n\nFirst, write your analysis in <analysis> tags as a thinking scratchpad:\n- Chronologically review the conversation\n- Identify user intents and goals\n- Note files read/modified, approaches tried, decisions made\n- Check for accuracy and completeness \u2014 ensure nothing critical is missing\n\nThen produce a structured summary in <summary> tags with these sections:\n\n## Primary Request and Intent\n- The user's core request and success criteria\n- Clarifications, constraints, or scope changes\n\n## Key Technical Concepts\n- Frameworks, libraries, patterns, architectural decisions\n\n## Files and Code Sections\n- Files read, modified, created (with full paths)\n- Critical code snippets (function signatures, bug fixes, key logic)\n- Focus on recent messages \u2014 include full code for important sections\n\n## Errors and Fixes\n- Errors encountered, root causes, how they were resolved\n- Approaches tried that didn't work and why\n\n## Problem Solving\n- Approach evolution, trade-offs considered, decisions made\n\n## All User Messages\n- Complete list of all user messages (non-tool content)\n- Preserve exact wording where load-bearing\n\n## Pending Tasks\n- Outstanding work, TODOs, unresolved questions\n\n## Current Work\n- What was being worked on at the time of summarization\n- Exact state of in-progress changes\n\n## Optional Next Step\n- Immediate next action needed\n- Include verbatim quotes from recent conversation if relevant\n\nBe concise but complete \u2014 include information that prevents duplicate work or repeated mistakes.\nRespond with text only. Do NOT call any tools.\nWrap your summary in <summary></summary> tags.";
16
16
  export declare const WEB_CONTENT_SYSTEM_PROMPT = "You are a helpful assistant that extracts information from web content. The content is provided in Markdown format.";
17
17
  export declare const BTW_SYSTEM_PROMPT = "You are a helpful assistant. Answer the user's side question based on the conversation history. \nDo NOT say things like \"Let me try...\", \"I'll now...\", \"Let me check...\", or promise to take any action. \nIf you don't know the answer, say so - do not offer to look it up or investigate. \nSimply answer the question with the information you have.";
18
18
  export declare function buildSystemPrompt(basePrompt: string | undefined, tools: ToolPlugin[], options?: {
19
19
  workdir?: string;
20
+ originalWorkdir?: string;
20
21
  memory?: string;
21
22
  language?: string;
22
23
  isSubagent?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prompts/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAiBzD,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,eAAO,MAAM,kBAAkB,oKAAoK,CAAC;AAEpM,eAAO,MAAM,kBAAkB,opIAcqQ,CAAC;AAErS,eAAO,MAAM,wBAAwB,25DASqmB,CAAC;AAE3oB,eAAO,MAAM,WAAW,knDAYqH,CAAC;AAE9I;;GAEG;AACH,eAAO,MAAM,wBAAwB,+uBAWiH,CAAC;AAEvJ,eAAO,MAAM,qBAAqB,6sBAMuL,CAAC;AAE1N,wBAAgB,mBAAmB,CACjC,YA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E9I;;GAEG;AACH,eAAO,MAAM,wBAAwB,+uBAWiH,CAAC;AAEvJ,eAAO,MAAM,qBAAqB,6sBAMuL,CAAC;AAE1N,wBAAgB,mBAAmB,CACjC,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,OAAO,EACnB,UAAU,GAAE,OAAe,GAC1B,MAAM,CAmFR;AAED,eAAO,MAAM,qBAAqB,oKAAqB,CAAC;AAExD,eAAO,MAAM,+BAA+B,44DA8CG,CAAC;AAEhD,eAAO,MAAM,yBAAyB,wHAAwH,CAAC;AAC/J,eAAO,MAAM,iBAAiB,qWAG4B,CAAC;AAE3D,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,KAAK,EAAE,UAAU,EAAE,EACnB,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC;IACF,UAAU,CAAC,EAAE;QACX,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,cAAc,CAAC,EAAE,cAAc,CAAC;CAC5B,GACL,MAAM,CA+DR;AAED,wBAAgB,iCAAiC,CAC/C,oBAAoB,EAAE,MAAM,EAC5B,OAAO,EAAE,MAAM,GACd,MAAM,CAgCR"}
@@ -148,28 +148,52 @@ This is critical - your turn should only end with either using the ${ASK_USER_QU
148
148
  NOTE: At any point in time through this workflow you should feel free to ask the user questions or clarifications using the ${ASK_USER_QUESTION_TOOL_NAME} tool. Don't make large assumptions about user intent. The goal is to present a well researched plan to the user, and tie any loose ends before implementation begins.`;
149
149
  }
150
150
  export const DEFAULT_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
151
- export const COMPRESS_MESSAGES_SYSTEM_PROMPT = `You have been working on the task described above but have not yet completed it. Write a continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary. Your summary should be structured, concise, and actionable. Include:
152
- 1. Task Overview
153
- The user's core request and success criteria
154
- Any clarifications or constraints they specified
155
- 2. Current State
156
- What has been completed so far
157
- Files created, modified, or analyzed (with paths if relevant)
158
- Key outputs or artifacts produced
159
- 3. Important Discoveries
160
- Technical constraints or requirements uncovered
161
- Decisions made and their rationale
162
- Errors encountered and how they were resolved
163
- What approaches were tried that didn't work (and why)
164
- 4. Next Steps
165
- Specific actions needed to complete the task
166
- Any blockers or open questions to resolve
167
- Priority order if multiple steps remain
168
- 5. Context to Preserve
169
- User preferences or style requirements
170
- Domain-specific details that aren't obvious
171
- Any promises made to the user
172
- Be concise but complete—err on the side of including information that would prevent duplicate work or repeated mistakes. Write in a way that enables immediate resumption of the task.
151
+ export const COMPRESS_MESSAGES_SYSTEM_PROMPT = `You are continuing work on a software engineering task. Write a detailed continuation summary that will allow you (or another instance of yourself) to resume work efficiently in a future context window where the conversation history will be replaced with this summary.
152
+
153
+ First, write your analysis in <analysis> tags as a thinking scratchpad:
154
+ - Chronologically review the conversation
155
+ - Identify user intents and goals
156
+ - Note files read/modified, approaches tried, decisions made
157
+ - Check for accuracy and completeness ensure nothing critical is missing
158
+
159
+ Then produce a structured summary in <summary> tags with these sections:
160
+
161
+ ## Primary Request and Intent
162
+ - The user's core request and success criteria
163
+ - Clarifications, constraints, or scope changes
164
+
165
+ ## Key Technical Concepts
166
+ - Frameworks, libraries, patterns, architectural decisions
167
+
168
+ ## Files and Code Sections
169
+ - Files read, modified, created (with full paths)
170
+ - Critical code snippets (function signatures, bug fixes, key logic)
171
+ - Focus on recent messages — include full code for important sections
172
+
173
+ ## Errors and Fixes
174
+ - Errors encountered, root causes, how they were resolved
175
+ - Approaches tried that didn't work and why
176
+
177
+ ## Problem Solving
178
+ - Approach evolution, trade-offs considered, decisions made
179
+
180
+ ## All User Messages
181
+ - Complete list of all user messages (non-tool content)
182
+ - Preserve exact wording where load-bearing
183
+
184
+ ## Pending Tasks
185
+ - Outstanding work, TODOs, unresolved questions
186
+
187
+ ## Current Work
188
+ - What was being worked on at the time of summarization
189
+ - Exact state of in-progress changes
190
+
191
+ ## Optional Next Step
192
+ - Immediate next action needed
193
+ - Include verbatim quotes from recent conversation if relevant
194
+
195
+ Be concise but complete — include information that prevents duplicate work or repeated mistakes.
196
+ Respond with text only. Do NOT call any tools.
173
197
  Wrap your summary in <summary></summary> tags.`;
174
198
  export const WEB_CONTENT_SYSTEM_PROMPT = `You are a helpful assistant that extracts information from web content. The content is provided in Markdown format.`;
175
199
  export const BTW_SYSTEM_PROMPT = `You are a helpful assistant. Answer the user's side question based on the conversation history.
@@ -194,8 +218,9 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
194
218
  if (options.planMode) {
195
219
  prompt += `\n\n${buildPlanModePrompt(options.planMode.planFilePath, options.planMode.planExists, options.isSubagent)}`;
196
220
  }
197
- if (options.workdir) {
198
- const isGitRepo = isGitRepository(options.workdir);
221
+ const workdirForPrompt = options.originalWorkdir || options.workdir;
222
+ if (workdirForPrompt) {
223
+ const isGitRepo = isGitRepository(workdirForPrompt);
199
224
  const platform = os.platform();
200
225
  const osVersion = `${os.type()} ${os.release()}`;
201
226
  const today = new Date().toISOString().split("T")[0];
@@ -209,7 +234,7 @@ export function buildSystemPrompt(basePrompt, tools, options = {}) {
209
234
 
210
235
  Here is useful information about the environment you are running in:
211
236
  <env>
212
- Working directory: ${options.workdir}
237
+ Working directory: ${workdirForPrompt}
213
238
  Is directory a git repo: ${isGitRepo}
214
239
  Platform: ${platform}
215
240
  Shell: ${shellName}
@@ -1,9 +1,14 @@
1
- import { KnownMarketplace, KnownMarketplacesRegistry, InstalledPlugin, InstalledPluginsRegistry, MarketplaceManifest } from "../types/marketplace.js";
1
+ import { KnownMarketplace, KnownMarketplacesRegistry, InstalledPlugin, InstalledPluginsRegistry, MarketplaceManifest, MarketplaceSource } from "../types/marketplace.js";
2
+ import { ConfigurationService } from "./configurationService.js";
3
+ import type { Scope } from "../types/configuration.js";
2
4
  /**
3
5
  * Marketplace Service
4
6
  *
5
7
  * Handles local plugin marketplace registration, plugin installation,
6
8
  * and state management for installed plugins.
9
+ *
10
+ * Marketplace declarations are now scoped (user/project/local) via settings files.
11
+ * known_marketplaces.json is kept as a cache for installLocation/lastUpdated metadata.
7
12
  */
8
13
  export declare class MarketplaceService {
9
14
  private static isLockedInProcess;
@@ -15,12 +20,19 @@ export declare class MarketplaceService {
15
20
  private cacheDir;
16
21
  private marketplacesDir;
17
22
  private gitService;
23
+ private configurationService;
24
+ private workdir;
18
25
  private static readonly BUILTIN_MARKETPLACE;
19
- constructor();
26
+ constructor(workdir?: string, configurationService?: ConfigurationService);
20
27
  /**
21
28
  * Ensures the required directory structure exists in ~/.wave/plugins
22
29
  */
23
30
  private ensureDirectoryStructure;
31
+ /**
32
+ * Backwards compatibility migration: migrate entries from known_marketplaces.json
33
+ * to user-level settings if they aren't already declared there.
34
+ */
35
+ private runMigration;
24
36
  /**
25
37
  * Check if a lock file is stale by reading its PID and checking if the process is alive.
26
38
  * Returns true if the lock is stale and safe to remove.
@@ -32,21 +44,37 @@ export declare class MarketplaceService {
32
44
  */
33
45
  private withLock;
34
46
  /**
35
- * Loads the known marketplaces registry
47
+ * Loads the cache registry from known_marketplaces.json
48
+ * Returns null if the file doesn't exist or has no parseable content (for first-run detection).
49
+ */
50
+ getCacheRegistry(): Promise<KnownMarketplacesRegistry | null>;
51
+ /**
52
+ * Legacy method: loads known marketplaces with builtin injection.
53
+ * @deprecated Use listMarketplaces() instead, which combines scoped settings.
36
54
  */
37
55
  getKnownMarketplaces(): Promise<KnownMarketplacesRegistry>;
38
56
  /**
39
- * Loads the installed plugins registry
57
+ * Updates the cache registry with metadata for a marketplace
40
58
  */
41
- getInstalledPlugins(): Promise<InstalledPluginsRegistry>;
59
+ private updateCacheMarketplace;
42
60
  /**
43
- * Saves the known marketplaces registry
61
+ * Removes a marketplace from the cache registry
44
62
  */
45
- saveKnownMarketplaces(registry: KnownMarketplacesRegistry): Promise<void>;
63
+ private removeFromCache;
64
+ /**
65
+ * Loads the installed plugins registry
66
+ */
67
+ getInstalledPlugins(): Promise<InstalledPluginsRegistry>;
46
68
  /**
47
69
  * Saves the installed plugins registry
48
70
  */
49
71
  saveInstalledPlugins(registry: InstalledPluginsRegistry): Promise<void>;
72
+ /**
73
+ * Finds the first existing marketplace manifest path.
74
+ * Prefers .wave-plugin/ for backward compatibility, falls back to .claude-plugin/.
75
+ * Returns null if neither exists.
76
+ */
77
+ private findMarketplaceManifestPath;
50
78
  /**
51
79
  * Loads a marketplace manifest from a local path
52
80
  */
@@ -54,19 +82,27 @@ export declare class MarketplaceService {
54
82
  /**
55
83
  * Resolves the local path for a marketplace
56
84
  */
57
- getMarketplacePath(marketplace: KnownMarketplace): string;
85
+ getMarketplacePath(source: MarketplaceSource): string;
86
+ /**
87
+ * Builds a KnownMarketplace from a scoped config, enriched with cache metadata
88
+ */
89
+ private buildMarketplaceEntry;
90
+ /**
91
+ * Finds which scope declared a marketplace (user, project, local, or builtin)
92
+ */
93
+ getMarketplaceDeclaringSource(name: string): Scope | "builtin" | null;
58
94
  /**
59
95
  * Adds a new marketplace (local directory, GitHub repo, or Git URL)
60
96
  */
61
- addMarketplace(input: string): Promise<KnownMarketplace>;
97
+ addMarketplace(input: string, scope?: Scope): Promise<KnownMarketplace>;
62
98
  /**
63
- * Lists all registered marketplaces
99
+ * Lists all registered marketplaces by combining scoped settings + built-in
64
100
  */
65
101
  listMarketplaces(): Promise<KnownMarketplace[]>;
66
102
  /**
67
- * Removes a marketplace by name
103
+ * Removes a marketplace by name from the specified scope
68
104
  */
69
- removeMarketplace(name: string): Promise<void>;
105
+ removeMarketplace(name: string, scope?: Scope): Promise<void>;
70
106
  /**
71
107
  * Updates a specific marketplace or all marketplaces
72
108
  */
@@ -81,6 +117,11 @@ export declare class MarketplaceService {
81
117
  * Toggles auto-update for a marketplace
82
118
  */
83
119
  toggleAutoUpdate(name: string, enabled: boolean): Promise<void>;
120
+ /**
121
+ * Resolves a plugin source into a consistent format for installation.
122
+ * Handles both string sources (local paths or git URLs) and object-style MarketplaceSource.
123
+ */
124
+ private resolvePluginSource;
84
125
  /**
85
126
  * Installs a plugin from a marketplace
86
127
  */
@@ -1 +1 @@
1
- {"version":3,"file":"MarketplaceService.d.ts","sourceRoot":"","sources":["../../src/services/MarketplaceService.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,eAAe,EACf,wBAAwB,EACxB,mBAAmB,EACpB,MAAM,yBAAyB,CAAC;AAGjC;;;;;GAKG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,iBAAiB,CAAS;IACzC,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,qBAAqB,CAAS;IACtC,OAAO,CAAC,oBAAoB,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAOzC;;IAqBF;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAUhC;;;OAGG;YACW,WAAW;IAiBzB;;;OAGG;YACW,QAAQ;IAsDtB;;OAEG;IACG,oBAAoB,IAAI,OAAO,CAAC,yBAAyB,CAAC;IA8BhE;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,wBAAwB,CAAC;IAgB9D;;OAEG;IACG,qBAAqB,CACzB,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,IAAI,CAAC;IAMhB;;OAEG;IACG,oBAAoB,CACxB,QAAQ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