MCPcopy Create free account
hub / github.com/CreminiAI/skillpack / handleCommand

Method handleCommand

src/runtime/agent.ts:897–943  ·  view source on GitHub ↗
(
    command: BotCommand,
    channelId: string,
  )

Source from the content-addressed store, hash-verified

895 }
896
897 async handleCommand(
898 command: BotCommand,
899 channelId: string,
900 ): Promise<CommandResult> {
901 switch (command) {
902 case "help":
903 return handleHelpCommand(this.options.rootDir);
904
905 case "new":
906 case "clear": {
907 const cs = this.channels.get(channelId);
908 if (cs) {
909 cs.session.dispose();
910 this.channels.delete(channelId);
911 }
912 const { rootDir } = this.options;
913 const sessionDir = path.resolve(rootDir, "data", "sessions", channelId);
914 if (fs.existsSync(sessionDir)) {
915 fs.rmSync(sessionDir, { recursive: true, force: true });
916 log(`[PackAgent] Cleared session dir: ${sessionDir}`);
917 }
918
919 await this.hostIpcClient.notifyChannelSessionCleared({ channelId });
920
921 return {
922 success: true,
923 message:
924 command === "new" ? "New session started." : "Session cleared.",
925 };
926 }
927
928 case "restart":
929 log("[PackAgent] Restart requested");
930 return this.options.lifecycleHandler.requestRestart(
931 getLifecycleTrigger(channelId),
932 );
933
934 case "shutdown":
935 log("[PackAgent] Shutdown requested");
936 return this.options.lifecycleHandler.requestShutdown(
937 getLifecycleTrigger(channelId),
938 );
939
940 default:
941 return { success: false, message: `Unknown command: ${command}` };
942 }
943 }
944
945 abort(channelId: string): void {
946 const cs = this.channels.get(channelId);

Callers

nothing calls this directly

Calls 7

handleHelpCommandFunction · 0.85
logFunction · 0.85
getLifecycleTriggerFunction · 0.85
disposeMethod · 0.65
requestRestartMethod · 0.65
requestShutdownMethod · 0.65

Tested by

no test coverage detected