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
@@ -1 +1 @@
1
- {"version":3,"file":"aiService.d.ts","sourceRoot":"","sources":["../../src/services/aiService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAGL,0BAA0B,EAC1B,0BAA0B,EAE3B,MAAM,qBAAqB,CAAC;AAI7B,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,EAKL,KAAK,WAAW,EACjB,MAAM,+BAA+B,CAAC;AAgEvC;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAEvC;AA6DD,MAAM,WAAW,gBAAgB;IAE/B,aAAa,EAAE,aAAa,CAAC;IAC7B,WAAW,EAAE,WAAW,CAAC;IAGzB,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,0BAA0B,EAAE,CAAC;IACrC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IAC5C,YAAY,CAAC,EAAE,CAAC,QAAQ,EAAE;QACxB,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,eAAe,CAAC,EAAE,MAAM,C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AE,WAAW,CAAC;IAGzB,QAAQ,EAAE,0BAA0B,EAAE,CAAC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE;QACN,aAAa,EAAE,MAAM,CAAC;QACtB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;CACH;AAED,wBAAsB,GAAG,CAAC,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,SAAS,CAAC,CAuFjE"}
@@ -457,6 +457,16 @@ export async function compressMessages(options) {
457
457
  modelConfig.model === "rate-limit-test") {
458
458
  await acquireSlot(abortSignal);
459
459
  }
460
+ // Strip images from messages before compact API call to reduce token usage
461
+ const cleanedMessages = messages.map((msg) => {
462
+ // Handle user/assistant messages with array content
463
+ if (Array.isArray(msg.content)) {
464
+ const textParts = msg.content.filter((part) => part.type === "text");
465
+ const text = textParts.map((p) => p.text).join("\n");
466
+ return { ...msg, content: text || "(empty message)" };
467
+ }
468
+ return msg;
469
+ });
460
470
  // Create OpenAI client with injected configuration
461
471
  const openai = new OpenAIClient({
462
472
  apiKey: gatewayConfig.apiKey,
@@ -484,7 +494,7 @@ export async function compressMessages(options) {
484
494
  role: "system",
485
495
  content: COMPRESS_MESSAGES_SYSTEM_PROMPT,
486
496
  },
487
- ...messages,
497
+ ...cleanedMessages,
488
498
  {
489
499
  role: "user",
490
500
  content: `Please create a detailed summary of the conversation so far.`,
@@ -4,7 +4,7 @@
4
4
  * Centralized service for loading, validating, and managing Wave configuration files.
5
5
  * Replaces distributed configuration logic previously embedded in hook.ts.
6
6
  */
7
- import type { ConfigurationLoadResult, ValidationResult, ConfigurationPaths, WaveConfiguration, Scope } from "../types/configuration.js";
7
+ import type { ConfigurationLoadResult, ValidationResult, ConfigurationPaths, WaveConfiguration, Scope, MarketplaceConfig } from "../types/configuration.js";
8
8
  import { type EnvironmentValidationResult, type MergedEnvironmentContext, type EnvironmentMergeOptions } from "../types/environment.js";
9
9
  import { GatewayConfig, ModelConfig, PermissionMode, AgentOptions } from "../types/index.js";
10
10
  import { ClientOptions } from "openai";
@@ -114,6 +114,22 @@ export declare class ConfigurationService {
114
114
  * Update the enabled state of a plugin in the specified scope
115
115
  */
116
116
  updateEnabledPlugin(workdir: string, scope: Scope, pluginId: string, enabled: boolean): Promise<void>;
117
+ /**
118
+ * Get merged marketplaces from all scopes
119
+ */
120
+ getMergedMarketplaces(workdir: string): Record<string, MarketplaceConfig>;
121
+ /**
122
+ * Get marketplaces at a specific scope
123
+ */
124
+ getScopedMarketplaces(workdir: string, scope: Scope): Record<string, MarketplaceConfig>;
125
+ /**
126
+ * Add a marketplace to the specified scope
127
+ */
128
+ addMarketplaceToScope(workdir: string, scope: Scope, name: string, config: MarketplaceConfig): Promise<void>;
129
+ /**
130
+ * Remove a marketplace from the specified scope
131
+ */
132
+ removeMarketplaceFromScope(workdir: string, scope: Scope, name: string): Promise<void>;
117
133
  /**
118
134
  * Remove a plugin from the enabled plugins in the specified scope
119
135
  */
@@ -1 +1 @@
1
- {"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACN,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBA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,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAyJ1B"}
1
+ {"version":3,"file":"configurationService.d.ts","sourceRoot":"","sources":["../../src/services/configurationService.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH,OAAO,KAAK,EACV,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EACL,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,KAAK,uBAAuB,EAE7B,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,aAAa,EACb,WAAW,EAGX,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAK3B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAGvC;;;;;GAKG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,oBAAoB,CAAkC;IAC9D,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,kBAAkB,CAAqB;IAE/C;;OAEG;IACH,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAMvC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,uBAAuB,CAAC;IA4DnC;;OAEG;IACH,qBAAqB,CAAC,MAAM,EAAE,iBAAiB,GAAG,gBAAgB;IAkLlE;;OAEG;IACH,yBAAyB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB;IAwC7D;;;OAGG;IACH,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI;IAcrD;;;;;;;;;;OAUG;IACH,oBAAoB,CAClB,MAAM,CAAC,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,EAChB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACvC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAA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B,CACzB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,IAAI,CAAC;IAyChB;;OAEG;IACG,0BAA0B,CAC9B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAmChB;;OAEG;IACG,mBAAmB,CACvB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;IAmChB;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAKjE;;;OAGG;IACH,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,iBAAiB,GAAG,IAAI;CAGnE;AAKD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,OAAO,EACZ,UAAU,CAAC,EAAE,MAAM,GAClB,2BAA2B,CAsD7B;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC3C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,EAC9C,OAAO,GAAE,uBAA4B,GACpC,wBAAwB,CAoC1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GACf,iBAAiB,GAAG,IAAI,CA8B1B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,GACd,iBAAiB,GAAG,IAAI,CAoK1B"}
@@ -627,6 +627,99 @@ export class ConfigurationService {
627
627
  config.enabledPlugins[pluginId] = enabled;
628
628
  await fs.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
629
629
  }
630
+ /**
631
+ * Get merged marketplaces from all scopes
632
+ */
633
+ getMergedMarketplaces(workdir) {
634
+ const mergedConfig = loadMergedWaveConfig(workdir);
635
+ return mergedConfig?.marketplaces || {};
636
+ }
637
+ /**
638
+ * Get marketplaces at a specific scope
639
+ */
640
+ getScopedMarketplaces(workdir, scope) {
641
+ let configPath;
642
+ if (scope === "user") {
643
+ configPath = getUserConfigPaths()[0];
644
+ }
645
+ else if (scope === "project") {
646
+ configPath = getProjectConfigPaths(workdir)[1];
647
+ }
648
+ else {
649
+ configPath = getProjectConfigPaths(workdir)[0];
650
+ }
651
+ const config = loadWaveConfigFromFile(configPath);
652
+ return config?.marketplaces || {};
653
+ }
654
+ /**
655
+ * Add a marketplace to the specified scope
656
+ */
657
+ async addMarketplaceToScope(workdir, scope, name, config) {
658
+ if (scope !== "user" && !existsSync(workdir)) {
659
+ throw new Error(`Working directory does not exist: ${workdir}`);
660
+ }
661
+ let configPath;
662
+ if (scope === "user") {
663
+ configPath = getUserConfigPaths()[0];
664
+ }
665
+ else if (scope === "project") {
666
+ configPath = getProjectConfigPaths(workdir)[1];
667
+ }
668
+ else {
669
+ configPath = getProjectConfigPaths(workdir)[0];
670
+ }
671
+ const configDir = path.dirname(configPath);
672
+ if (!existsSync(configDir)) {
673
+ await fs.mkdir(configDir, { recursive: true });
674
+ }
675
+ let fileConfig = {};
676
+ if (existsSync(configPath)) {
677
+ try {
678
+ const content = await fs.readFile(configPath, "utf-8");
679
+ fileConfig = JSON.parse(content);
680
+ }
681
+ catch {
682
+ // Start with empty config if file is corrupted
683
+ }
684
+ }
685
+ if (!fileConfig.marketplaces) {
686
+ fileConfig.marketplaces = {};
687
+ }
688
+ fileConfig.marketplaces[name] = config;
689
+ await fs.writeFile(configPath, JSON.stringify(fileConfig, null, 2), "utf-8");
690
+ }
691
+ /**
692
+ * Remove a marketplace from the specified scope
693
+ */
694
+ async removeMarketplaceFromScope(workdir, scope, name) {
695
+ if (scope !== "user" && !existsSync(workdir)) {
696
+ throw new Error(`Working directory does not exist: ${workdir}`);
697
+ }
698
+ let configPath;
699
+ if (scope === "user") {
700
+ configPath = getUserConfigPaths()[0];
701
+ }
702
+ else if (scope === "project") {
703
+ configPath = getProjectConfigPaths(workdir)[1];
704
+ }
705
+ else {
706
+ configPath = getProjectConfigPaths(workdir)[0];
707
+ }
708
+ if (!existsSync(configPath)) {
709
+ return;
710
+ }
711
+ try {
712
+ const content = await fs.readFile(configPath, "utf-8");
713
+ const fileConfig = JSON.parse(content);
714
+ if (fileConfig.marketplaces && name in fileConfig.marketplaces) {
715
+ delete fileConfig.marketplaces[name];
716
+ await fs.writeFile(configPath, JSON.stringify(fileConfig, null, 2), "utf-8");
717
+ }
718
+ }
719
+ catch {
720
+ // Ignore errors for corrupted or non-existent files
721
+ }
722
+ }
630
723
  /**
631
724
  * Remove a plugin from the enabled plugins in the specified scope
632
725
  */
@@ -777,6 +870,7 @@ export function loadWaveConfigFromFile(filePath) {
777
870
  ? config.autoMemoryEnabled
778
871
  : undefined,
779
872
  models: config.models || undefined,
873
+ marketplaces: config.marketplaces || undefined,
780
874
  };
781
875
  }
782
876
  catch (error) {
@@ -893,6 +987,12 @@ export function loadMergedWaveConfig(workdir) {
893
987
  if (config.autoMemoryFrequency !== undefined) {
894
988
  mergedConfig.autoMemoryFrequency = config.autoMemoryFrequency;
895
989
  }
990
+ // Merge marketplaces (last one wins for same key)
991
+ if (config.marketplaces) {
992
+ if (!mergedConfig.marketplaces)
993
+ mergedConfig.marketplaces = {};
994
+ Object.assign(mergedConfig.marketplaces, config.marketplaces);
995
+ }
896
996
  // Merge models
897
997
  if (config.models) {
898
998
  if (!mergedConfig.models)
@@ -922,6 +1022,10 @@ export function loadMergedWaveConfig(workdir) {
922
1022
  : undefined,
923
1023
  language: mergedConfig.language,
924
1024
  autoMemoryEnabled: mergedConfig.autoMemoryEnabled,
1025
+ marketplaces: mergedConfig.marketplaces &&
1026
+ Object.keys(mergedConfig.marketplaces).length > 0
1027
+ ? mergedConfig.marketplaces
1028
+ : undefined,
925
1029
  models: mergedConfig.models && Object.keys(mergedConfig.models).length > 0
926
1030
  ? mergedConfig.models
927
1031
  : undefined,
@@ -1,5 +1,11 @@
1
1
  import { PluginManifest, CustomSlashCommand, Skill, LspConfig, McpConfig, PartialHookConfiguration } from "../types/index.js";
2
2
  export declare class PluginLoader {
3
+ /**
4
+ * Finds the first existing plugin manifest path.
5
+ * Prefers .wave-plugin/ for backward compatibility, falls back to .claude-plugin/.
6
+ * Returns null if neither exists.
7
+ */
8
+ private static findPluginManifestPath;
3
9
  /**
4
10
  * Load and validate a plugin manifest from a directory
5
11
  * @param pluginPath Absolute path to the plugin directory
@@ -1 +1 @@
1
- {"version":3,"file":"pluginLoader.d.ts","sourceRoot":"","sources":["../../src/services/pluginLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,SAAS,EACT,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAK3B,qBAAa,YAAY;IACvB;;;OAGG;WACU,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IA6CtE;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAK7D;;;OAGG;WACU,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAuC7D;;OAEG;WACU,aAAa,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAUjC;;OAEG;WACU,aAAa,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAUjC;;OAEG;WACU,eAAe,CAC1B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAUhD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAgBhC"}
1
+ {"version":3,"file":"pluginLoader.d.ts","sourceRoot":"","sources":["../../src/services/pluginLoader.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,KAAK,EACL,SAAS,EACT,SAAS,EACT,wBAAwB,EACzB,MAAM,mBAAmB,CAAC;AAK3B,qBAAa,YAAY;IACvB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,sBAAsB;IAkCrC;;;OAGG;WACU,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAgEtE;;;OAGG;IACH,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,EAAE;IAK7D;;;OAGG;WACU,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAuC7D;;OAEG;WACU,aAAa,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAUjC;;OAEG;WACU,aAAa,CACxB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAUjC;;OAEG;WACU,eAAe,CAC1B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,wBAAwB,GAAG,SAAS,CAAC;IAUhD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,gBAAgB;CAgBhC"}
@@ -1,28 +1,73 @@
1
1
  import * as fs from "fs/promises";
2
+ import * as fsSync from "fs";
2
3
  import * as path from "path";
3
4
  import { scanCommandsDirectory } from "../utils/customCommands.js";
4
5
  import { parseSkillFile } from "../utils/skillParser.js";
5
6
  import { resolveMcpConfig } from "../managers/mcpManager.js";
6
7
  export class PluginLoader {
8
+ /**
9
+ * Finds the first existing plugin manifest path.
10
+ * Prefers .wave-plugin/ for backward compatibility, falls back to .claude-plugin/.
11
+ * Returns null if neither exists.
12
+ */
13
+ static findPluginManifestPath(pluginPath) {
14
+ const waveManifestPath = path.join(pluginPath, ".wave-plugin", "plugin.json");
15
+ const claudeManifestPath = path.join(pluginPath, ".claude-plugin", "plugin.json");
16
+ // Check .wave-plugin first for backward compatibility
17
+ try {
18
+ const waveStat = fsSync.statSync(waveManifestPath);
19
+ if (waveStat.isFile()) {
20
+ return waveManifestPath;
21
+ }
22
+ }
23
+ catch {
24
+ // .wave-plugin/plugin.json doesn't exist
25
+ }
26
+ try {
27
+ const claudeStat = fsSync.statSync(claudeManifestPath);
28
+ if (claudeStat.isFile()) {
29
+ return claudeManifestPath;
30
+ }
31
+ }
32
+ catch {
33
+ // .claude-plugin/plugin.json doesn't exist
34
+ }
35
+ return null;
36
+ }
7
37
  /**
8
38
  * Load and validate a plugin manifest from a directory
9
39
  * @param pluginPath Absolute path to the plugin directory
10
40
  */
11
41
  static async loadManifest(pluginPath) {
12
- const dotWavePluginPath = path.join(pluginPath, ".wave-plugin");
13
- const manifestPath = path.join(dotWavePluginPath, "plugin.json");
14
- // T018: Ensure plugin.json is the only file in .wave-plugin/
42
+ const manifestPath = this.findPluginManifestPath(pluginPath);
43
+ if (!manifestPath) {
44
+ throw new Error(`Plugin manifest not found at ${pluginPath}. Neither .wave-plugin/plugin.json nor .claude-plugin/plugin.json exists.`);
45
+ }
46
+ // Determine which directory is being used for validation
47
+ const pluginDirName = manifestPath.includes(".claude-plugin")
48
+ ? ".claude-plugin"
49
+ : ".wave-plugin";
50
+ const pluginDirPath = path.join(pluginPath, pluginDirName);
51
+ // T018: Ensure plugin.json is the only file in the manifest directory
52
+ // For .claude-plugin/, marketplace.json is also allowed (Claude Code convention)
15
53
  try {
16
- const entries = await fs.readdir(dotWavePluginPath);
17
- const misplaced = entries.filter((e) => e !== "plugin.json");
54
+ const entries = await fs.readdir(pluginDirPath);
55
+ const allowedFiles = ["plugin.json"];
56
+ if (pluginDirName === ".claude-plugin") {
57
+ allowedFiles.push("marketplace.json");
58
+ }
59
+ const misplaced = entries.filter((e) => !allowedFiles.includes(e));
18
60
  if (misplaced.length > 0) {
19
- throw new Error(`Misplaced files/directories in .wave-plugin/: ${misplaced.join(", ")}. Only plugin.json should be in this directory.`);
61
+ const allowedMsg = pluginDirName === ".claude-plugin"
62
+ ? "Only plugin.json and marketplace.json should be in this directory."
63
+ : "Only plugin.json should be in this directory.";
64
+ throw new Error(`Misplaced files/directories in ${pluginDirName}/: ${misplaced.join(", ")}. ${allowedMsg}`);
20
65
  }
21
66
  }
22
67
  catch (error) {
23
68
  if (error instanceof Error &&
24
69
  error.code === "ENOENT") {
25
- throw new Error(`Plugin manifest directory not found at ${dotWavePluginPath}`);
70
+ throw new Error(`Plugin manifest directory not found at ${pluginDirPath}`);
26
71
  }
27
72
  throw error;
28
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/tools/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAStE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UAgQvB,CAAC"}
1
+ {"version":3,"file":"agentTool.d.ts","sourceRoot":"","sources":["../../src/tools/agentTool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAStE;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,UA4QvB,CAAC"}
@@ -61,7 +61,11 @@ When using the Agent tool, you must specify a subagent_type parameter to select
61
61
 
62
62
  - When doing file search, prefer to use the ${AGENT_TOOL_NAME} tool in order to reduce context usage.
63
63
  - You should proactively use the ${AGENT_TOOL_NAME} tool with specialized agents when the task at hand matches the agent's description.
64
- - VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${AGENT_TOOL_NAME} tool with subagent_type=${EXPLORE_SUBAGENT_TYPE} instead of running search commands directly.`;
64
+ - VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the ${AGENT_TOOL_NAME} tool with subagent_type=${EXPLORE_SUBAGENT_TYPE} instead of running search commands directly.
65
+ - You can optionally run agents in the background using the run_in_background parameter. When an agent runs in the background, you will be automatically notified when it completes — do NOT sleep, poll, or proactively check on its progress. Continue with other work or respond to the user instead.
66
+ - **Foreground vs background**: Use foreground (default) when you need the agent's results before you can proceed — e.g., research agents whose findings inform your next steps. Use background when you have genuinely independent work to do in parallel.
67
+ - **Don't peek.** The tool result includes an output file path — do not Read or tail it unless the user explicitly asks for a progress check. You get a completion notification; trust it. Reading the transcript mid-flight pulls the agent's tool noise into your context, which defeats the point of backgrounding.
68
+ - **Don't race.** After launching, you know nothing about what the agent found. Never fabricate or predict agent results in any format — not as prose, summary, or structured output. The notification arrives as a user-role message in a later turn; it is never something you write yourself. If the user asks a follow-up before the notification lands, tell them the agent is still running — give status, not a guess.`;
65
69
  },
66
70
  execute: async (args, context) => {
67
71
  const subagentManager = context.subagentManager;
@@ -169,9 +173,17 @@ When using the Agent tool, you must specify a subagent_type parameter to select
169
173
  if (run_in_background) {
170
174
  const task = context.backgroundTaskManager?.getTask(result);
171
175
  const outputPath = task?.outputPath;
176
+ const backgroundMsg = [
177
+ `Agent started in background with ID: ${result}.`,
178
+ `The agent is working in the background. You will be notified automatically when it completes.`,
179
+ `Do not duplicate this agent's work — avoid working with the same files or topics it is using.`,
180
+ outputPath
181
+ ? `output_file: ${outputPath}`
182
+ : `Briefly tell the user what you launched and end your response.`,
183
+ ].join("\n");
172
184
  resolve({
173
185
  success: true,
174
- content: `Agent started in background with ID: ${result}.${outputPath ? ` Real-time output: ${outputPath}` : ""}`,
186
+ content: backgroundMsg,
175
187
  shortResult: `Agent started in background: ${result}`,
176
188
  });
177
189
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAwCtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UA+ctB,CAAC"}
1
+ {"version":3,"file":"bashTool.d.ts","sourceRoot":"","sources":["../../src/tools/bashTool.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAwCtE;;GAEG;AACH,eAAO,MAAM,QAAQ,EAAE,UAqetB,CAAC"}
@@ -122,7 +122,10 @@ Use the gh command via the Bash tool for GitHub-related tasks including working
122
122
  - Do not retry failing commands in a sleep loop — diagnose the root cause.
123
123
  - If waiting for a background task you started with \`run_in_background\`, you will be notified when it completes — do not poll.
124
124
  - If you must poll an external process, use a check command (e.g. \`gh run view\`) rather than sleeping first.
125
- - If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.`,
125
+ - If you must sleep, keep the duration short (1-5 seconds) to avoid blocking the user.
126
+
127
+ # CWD management
128
+ Try to maintain your current working directory throughout the session by using absolute paths and avoiding usage of \`cd\`. You may use \`cd\` if the User explicitly requests it. When you use \`cd\`, the shell working directory will be reset to the original working directory after the command completes.`,
126
129
  execute: async (args, context) => {
127
130
  const command = args.command;
128
131
  const runInBackground = args.run_in_background;
@@ -186,9 +189,16 @@ Use the gh command via the Bash tool for GitHub-related tasks including working
186
189
  const { id: taskId } = backgroundTaskManager.startShell(command, timeout);
187
190
  const task = backgroundTaskManager.getTask(taskId);
188
191
  const outputPath = task?.outputPath;
192
+ const backgroundMsg = [
193
+ `Command started in background with ID: ${taskId}.`,
194
+ `You will be notified automatically when it completes.`,
195
+ outputPath
196
+ ? `output_file: ${outputPath}`
197
+ : `Use ${READ_TOOL_NAME} tool with task_id="${taskId}" to read the output.`,
198
+ ].join("\n");
189
199
  return {
190
200
  success: true,
191
- content: `Command started in background with ID: ${taskId}.${outputPath ? ` Real-time output: ${outputPath}` : ` Use ${READ_TOOL_NAME} tool with task_id="${taskId}" to monitor output.`}`,
201
+ content: backgroundMsg,
192
202
  shortResult: `Background process ${taskId} started`,
193
203
  };
194
204
  }
@@ -376,14 +386,26 @@ Use the gh command via the Bash tool for GitHub-related tasks including working
376
386
  logger.error("Failed to clean up temp CWD file:", fileError);
377
387
  }
378
388
  }
379
- // If CWD changed, call the onCwdChange callback
389
+ // If CWD changed, call the onCwdChange callback and add notification
390
+ let cwdChangedNotification = "";
380
391
  if (newCwd && newCwd !== context.workdir && context.onCwdChange) {
381
- context.onCwdChange(newCwd);
392
+ const isInSafeZone = context.permissionManager?.isPathInSafeZone?.(newCwd) ?? true;
393
+ if (isInSafeZone) {
394
+ context.onCwdChange(newCwd);
395
+ }
396
+ else if (context.originalWorkdir) {
397
+ context.onCwdChange(context.originalWorkdir);
398
+ cwdChangedNotification = `Shell cwd was reset to ${context.originalWorkdir}\n`;
399
+ }
400
+ else {
401
+ context.onCwdChange(newCwd);
402
+ }
382
403
  }
383
404
  const exitCode = code ?? 0;
384
405
  const combinedOutput = outputBuffer + (errorBuffer ? "\n" + errorBuffer : "");
385
406
  // Handle large output by truncation and persistence if needed
386
- const finalOutput = combinedOutput || `Command executed with exit code: ${exitCode}`;
407
+ const finalOutput = cwdChangedNotification +
408
+ (combinedOutput || `Command executed with exit code: ${exitCode}`);
387
409
  const content = processOutput(finalOutput);
388
410
  const lines = combinedOutput.trim().split("\n");
389
411
  const shortResult = lines.length <= 3
@@ -38,6 +38,7 @@ export interface ToolContext {
38
38
  abortSignal?: AbortSignal;
39
39
  backgroundTaskManager?: import("../managers/backgroundTaskManager.js").BackgroundTaskManager;
40
40
  workdir: string;
41
+ originalWorkdir?: string;
41
42
  /** Permission mode for this tool execution */
42
43
  permissionMode?: PermissionMode;
43
44
  /** Custom permission callback */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EACV,cAAc,EACd,kBAAkB,EACnB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,qBAAqB,EA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Root":"","sources":["../../src/tools/webFetchTool.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AA+BtE,eAAO,MAAM,YAAY,EAAE,UAiK1B,CAAC"}
1
+ {"version":3,"file":"webFetchTool.d.ts","sourceRoot":"","sources":["../../src/tools/webFetchTool.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAA2B,MAAM,YAAY,CAAC;AAoGtE,eAAO,MAAM,YAAY,EAAE,UAoL1B,CAAC"}