@friendlyrobot/discord-pi-agent 0.1.1 → 0.1.2
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.
- package/dist/index.js +6 -1
- package/dist/types.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -168,11 +168,13 @@ class AgentService {
|
|
|
168
168
|
getStatus() {
|
|
169
169
|
const session = this.requireSession();
|
|
170
170
|
const model = session.model ? `${session.model.provider}/${session.model.id}` : "(no model selected)";
|
|
171
|
+
const contextUsage = session.getContextUsage();
|
|
171
172
|
return {
|
|
172
173
|
sessionId: session.sessionId,
|
|
173
174
|
sessionFile: session.sessionFile,
|
|
174
175
|
model,
|
|
175
|
-
streaming: session.isStreaming
|
|
176
|
+
streaming: session.isStreaming,
|
|
177
|
+
contextUsage
|
|
176
178
|
};
|
|
177
179
|
}
|
|
178
180
|
async shutdown() {
|
|
@@ -326,6 +328,8 @@ async function handleCommand(input, agentService, promptQueue) {
|
|
|
326
328
|
if (trimmed === "!status") {
|
|
327
329
|
const agentStatus = agentService.getStatus();
|
|
328
330
|
const queueStatus = promptQueue.getSnapshot();
|
|
331
|
+
const contextUsage = agentStatus.contextUsage;
|
|
332
|
+
const contextLine = contextUsage ? contextUsage.tokens === null || contextUsage.percent === null ? `context: ?/${contextUsage.contextWindow}` : `context: ${contextUsage.tokens}/${contextUsage.contextWindow} (${Math.round(contextUsage.percent)}%)` : "context: (unavailable)";
|
|
329
333
|
return {
|
|
330
334
|
handled: true,
|
|
331
335
|
response: [
|
|
@@ -333,6 +337,7 @@ async function handleCommand(input, agentService, promptQueue) {
|
|
|
333
337
|
`session-id: ${agentStatus.sessionId}`,
|
|
334
338
|
`session-file: ${agentStatus.sessionFile ?? "(none)"}`,
|
|
335
339
|
`streaming: ${agentStatus.streaming}`,
|
|
340
|
+
contextLine,
|
|
336
341
|
`queue-pending: ${queueStatus.pending}`,
|
|
337
342
|
`queue-busy: ${queueStatus.busy}`
|
|
338
343
|
].join(`
|
package/dist/types.d.ts
CHANGED
|
@@ -22,11 +22,17 @@ export type ResolvedDiscordPiBridgeConfig = {
|
|
|
22
22
|
startupMessage: string | false;
|
|
23
23
|
shutdownOnSignals: boolean;
|
|
24
24
|
};
|
|
25
|
+
export type ContextUsageStatus = {
|
|
26
|
+
tokens: number | null;
|
|
27
|
+
contextWindow: number;
|
|
28
|
+
percent: number | null;
|
|
29
|
+
};
|
|
25
30
|
export type AgentStatus = {
|
|
26
31
|
sessionId: string;
|
|
27
32
|
sessionFile: string | undefined;
|
|
28
33
|
model: string;
|
|
29
34
|
streaming: boolean;
|
|
35
|
+
contextUsage: ContextUsageStatus | undefined;
|
|
30
36
|
};
|
|
31
37
|
export type DiscordPiBridge = {
|
|
32
38
|
client: Client;
|