commandkit 1.0.0-dev.20250611125312 → 1.0.0-dev.20250611155146

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 (97) hide show
  1. package/ai.cjs +21 -0
  2. package/ai.d.ts +1 -0
  3. package/dist/{CommandKit-C0W3U6jh.js → CommandKit-BqZBlSaB.js} +16 -4
  4. package/dist/CommandKit-BqZBlSaB.js.map +1 -0
  5. package/dist/{CommandKit-BkMUDbou.d.ts → CommandKit-g7NqIdUD.d.ts} +26 -9
  6. package/dist/CommandKit.d.ts +1 -1
  7. package/dist/CommandKit.js +1 -1
  8. package/dist/{EventWorkerContext-DoFZMT8u.d.ts → EventWorkerContext-BcXmutAi.d.ts} +2 -2
  9. package/dist/analytics/analytics-engine.d.ts +1 -1
  10. package/dist/analytics/analytics-engine.js +1 -1
  11. package/dist/analytics/analytics-provider.d.ts +1 -1
  12. package/dist/analytics/utils.js +1 -1
  13. package/dist/app/commands/AppCommandRunner.d.ts +2 -2
  14. package/dist/app/commands/AppCommandRunner.js +1 -1
  15. package/dist/app/commands/Context.d.ts +1 -1
  16. package/dist/app/commands/Context.js +1 -1
  17. package/dist/app/events/EventWorkerContext.d.ts +2 -2
  18. package/dist/app/handlers/AppCommandHandler.d.ts +2 -2
  19. package/dist/app/handlers/AppCommandHandler.js +1 -1
  20. package/dist/app/handlers/AppEventsHandler.d.ts +1 -1
  21. package/dist/app/handlers/AppEventsHandler.js +1 -1
  22. package/dist/app/index.d.ts +2 -2
  23. package/dist/app/index.js +1 -1
  24. package/dist/app/register/CommandRegistrar.d.ts +1 -1
  25. package/dist/app/register/CommandRegistrar.js +1 -1
  26. package/dist/{build-CWrpkal-.js → build-B-Ae1hqg.js} +2 -2
  27. package/dist/{build-CWrpkal-.js.map → build-B-Ae1hqg.js.map} +1 -1
  28. package/dist/cli/build.d.ts +1 -1
  29. package/dist/cli/build.js +2 -2
  30. package/dist/cli/common.d.ts +3 -3
  31. package/dist/cli/development.js +2 -2
  32. package/dist/cli/information.js +1 -1
  33. package/dist/cli/init.js +2 -2
  34. package/dist/cli/production.js +2 -2
  35. package/dist/components/index.js +1 -1
  36. package/dist/components/v1/button/Button.js +1 -1
  37. package/dist/components/v1/button/ButtonKit.js +1 -1
  38. package/dist/components/v1/modal/Modal.js +1 -1
  39. package/dist/components/v1/modal/ModalKit.js +1 -1
  40. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +1 -1
  41. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +1 -1
  42. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +1 -1
  43. package/dist/components/v1/select-menu/SelectMenu.js +1 -1
  44. package/dist/components/v1/select-menu/StringSelectMenuKit.js +1 -1
  45. package/dist/components/v1/select-menu/UserSelectMenuKit.js +1 -1
  46. package/dist/config/config.d.ts +4 -4
  47. package/dist/config/config.js +1 -1
  48. package/dist/config/default.d.ts +3 -3
  49. package/dist/config/default.js +1 -1
  50. package/dist/config/loader.d.ts +3 -3
  51. package/dist/config/loader.js +1 -1
  52. package/dist/config/types.d.ts +2 -2
  53. package/dist/config/utils.d.ts +3 -3
  54. package/dist/{config-aCpqqs1C.d.ts → config-CGECBFwj.d.ts} +3 -3
  55. package/dist/context/async-context.d.ts +1 -1
  56. package/dist/context/async-context.js +1 -1
  57. package/dist/context/environment.d.ts +1 -1
  58. package/dist/context/environment.js +1 -1
  59. package/dist/events/CommandKitEventsChannel.d.ts +1 -1
  60. package/dist/{feature-flags-CLZLGnAs.js → feature-flags-CvHcOB7L.js} +2 -2
  61. package/dist/{feature-flags-CLZLGnAs.js.map → feature-flags-CvHcOB7L.js.map} +1 -1
  62. package/dist/flags/FlagProvider.d.ts +1 -1
  63. package/dist/flags/feature-flags.d.ts +1 -1
  64. package/dist/flags/feature-flags.js +2 -2
  65. package/dist/flags/store.d.ts +1 -1
  66. package/dist/index.d.ts +6 -6
  67. package/dist/index.js +4 -4
  68. package/dist/{init-_FwacDcI.js → init-BQgLOfl_.js} +2 -2
  69. package/dist/{init-_FwacDcI.js.map → init-BQgLOfl_.js.map} +1 -1
  70. package/dist/logger/DefaultLogger.js +1 -1
  71. package/dist/logger/Logger.js +1 -1
  72. package/dist/plugins/CompilerPlugin.d.ts +1 -1
  73. package/dist/plugins/PluginCommon.d.ts +1 -1
  74. package/dist/plugins/RuntimePlugin.d.ts +1 -1
  75. package/dist/plugins/index.d.ts +1 -1
  76. package/dist/plugins/index.js +1 -1
  77. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.d.ts +1 -1
  78. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
  79. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.d.ts +1 -1
  80. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.d.ts +1 -1
  81. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +1 -1
  82. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.d.ts +1 -1
  83. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +1 -1
  84. package/dist/plugins/plugin-runtime/runtime.d.ts +1 -1
  85. package/dist/plugins/types.d.ts +1 -1
  86. package/dist/{types-DwmPE0nY.d.ts → types-uBjT82V4.d.ts} +2 -2
  87. package/dist/types.d.ts +1 -1
  88. package/dist/utils/colors.d.ts +2 -2
  89. package/dist/utils/dev-hooks.d.ts +1 -1
  90. package/dist/utils/dev-hooks.js +1 -1
  91. package/dist/utils/utilities.js +1 -1
  92. package/dist/{utils-DS6OiGvg.d.ts → utils-Bz_BoOnV.d.ts} +2 -2
  93. package/dist/{version-IoXx-oYe.js → version-AMyvJ7I3.js} +2 -2
  94. package/dist/{version-IoXx-oYe.js.map → version-AMyvJ7I3.js.map} +1 -1
  95. package/dist/version.js +1 -1
  96. package/package.json +10 -3
  97. package/dist/CommandKit-C0W3U6jh.js.map +0 -1
package/ai.cjs ADDED
@@ -0,0 +1,21 @@
1
+ const {
2
+ AiContext,
3
+ AiPlugin,
4
+ configureAI,
5
+ createSystemPrompt,
6
+ createTool,
7
+ getAIConfig,
8
+ useAIContext,
9
+ ai,
10
+ } = require('@commandkit/ai');
11
+
12
+ module.exports = {
13
+ AiContext,
14
+ AiPlugin,
15
+ configureAI,
16
+ createSystemPrompt,
17
+ createTool,
18
+ getAIConfig,
19
+ useAIContext,
20
+ ai,
21
+ };
package/ai.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from '@commandkit/ai';
@@ -1383,12 +1383,21 @@ var CommandKitPluginRuntime = class {
1383
1383
  }
1384
1384
  /**
1385
1385
  * Checks if there are no plugins registered in this runtime.
1386
+ * @param pluginName The name of the plugin to check.
1386
1387
  * @returns Boolean indicating whether the runtime is empty.
1387
1388
  */
1388
1389
  getPlugin(pluginName) {
1389
1390
  return this.plugins.get(pluginName) ?? null;
1390
1391
  }
1391
1392
  /**
1393
+ * Fetches the given plugin
1394
+ * @param plugin The plugin to be fetched.
1395
+ */
1396
+ get(plugin) {
1397
+ const p = this.plugins.find((p$1) => p$1 instanceof plugin) ?? null;
1398
+ return p;
1399
+ }
1400
+ /**
1392
1401
  * Soft registers a plugin in the runtime.
1393
1402
  * @param plugin The plugin to be registered.
1394
1403
  */
@@ -2465,7 +2474,7 @@ var AppCommandRunner = class {
2465
2474
  * @param prepared - The prepared command execution data
2466
2475
  * @param source - The source interaction or message that triggered the command
2467
2476
  */
2468
- async runCommand(prepared, source) {
2477
+ async runCommand(prepared, source, options) {
2469
2478
  const { commandkit: commandkit$1 } = this.handler;
2470
2479
  const executionMode = this.getExecutionMode(source);
2471
2480
  let runCommand = null;
@@ -2474,6 +2483,7 @@ var AppCommandRunner = class {
2474
2483
  env.variables.set("commandHandlerType", "app");
2475
2484
  env.variables.set("currentCommandName", prepared.command.command.name);
2476
2485
  env.variables.set("execHandlerKind", executionMode);
2486
+ env.variables.set("customHandler", (options === null || options === void 0 ? void 0 : options.handler) ?? null);
2477
2487
  const ctx = new MiddlewareContext(commandkit$1, {
2478
2488
  command: prepared.command,
2479
2489
  environment: env,
@@ -2502,9 +2512,10 @@ var AppCommandRunner = class {
2502
2512
  }
2503
2513
  }
2504
2514
  });
2515
+ let result;
2505
2516
  if (!ctx.cancelled) {
2506
2517
  const targetData = prepared.command.data;
2507
- const fn = targetData[executionMode];
2518
+ const fn = targetData[(options === null || options === void 0 ? void 0 : options.handler) || executionMode];
2508
2519
  if (!fn) Logger.warn(`Command ${prepared.command.command.name} has no handler for ${executionMode}`);
2509
2520
  const analytics = commandkit$1.analytics;
2510
2521
  if (fn) try {
@@ -2551,7 +2562,7 @@ var AppCommandRunner = class {
2551
2562
  const res = await commandkit$1.plugins.execute(async (ctx$1, plugin) => {
2552
2563
  return plugin.executeCommand(ctx$1, env, source, prepared, executeCommand);
2553
2564
  });
2554
- if (!res) await executeCommand();
2565
+ if (!res) result = await executeCommand();
2555
2566
  } catch (e) {
2556
2567
  if (require_error_codes.isErrorType(e, require_error_codes.CommandKitErrorCodes.ExitMiddleware)) middlewaresCanceled = true;
2557
2568
  if (!require_error_codes.isErrorType(e, [require_error_codes.CommandKitErrorCodes.ForwardedCommand, require_error_codes.CommandKitErrorCodes.ExitMiddleware])) Logger.error(e);
@@ -2568,6 +2579,7 @@ var AppCommandRunner = class {
2568
2579
  }
2569
2580
  }
2570
2581
  });
2582
+ return result;
2571
2583
  }
2572
2584
  /**
2573
2585
  * @private
@@ -4112,4 +4124,4 @@ Object.defineProperty(exports, 'useEnvironment', {
4112
4124
  return useEnvironment;
4113
4125
  }
4114
4126
  });
4115
- //# sourceMappingURL=CommandKit-C0W3U6jh.js.map
4127
+ //# sourceMappingURL=CommandKit-BqZBlSaB.js.map