MCPcopy Create free account
hub / github.com/ConardLi/easy-agent / handleCommand

Method handleCommand

step/step8.js:84–115  ·  view source on GitHub ↗
(command)

Source from the content-addressed store, hash-verified

82 }
83
84 async *handleCommand(command) {
85 if (command === "/clear") {
86 this.messages = [];
87 yield { type: "messages_updated", messages: [] };
88 yield { type: "command", kind: "info", message: "Conversation cleared." };
89 return { handled: true };
90 }
91
92 if (command === "/cost") {
93 yield {
94 type: "command",
95 kind: "info",
96 message: `Input=${this.totalUsage.input_tokens}, Output=${this.totalUsage.output_tokens}`,
97 };
98 return { handled: true };
99 }
100
101 if (command.startsWith("/model ")) {
102 const nextModel = command.slice("/model ".length).trim();
103 this.sessionModelOverride = nextModel || null;
104 yield { type: "command", kind: "info", message: `Active model: ${this.getActiveModel()}` };
105 return { handled: true };
106 }
107
108 if (command === "/help") {
109 yield { type: "command", kind: "info", message: "Commands: /help /clear /cost /model <name>" };
110 return { handled: true };
111 }
112
113 yield { type: "command", kind: "error", message: `Unknown command: ${command}` };
114 return { handled: true };
115 }
116}

Callers 1

submitMessageMethod · 0.95

Calls 1

getActiveModelMethod · 0.95

Tested by

no test coverage detected