@friendlyrobot/discord-pi-agent 0.1.0 → 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/README.md CHANGED
@@ -11,10 +11,10 @@ Reusable Discord DM bridge for persistent pi agent sessions.
11
11
  - exposes built-in session commands
12
12
 
13
13
  ## Built-in commands
14
- - `/help`
15
- - `/status`
16
- - `/compact`
17
- - `/reset-session`
14
+ - `!help`
15
+ - `!status`
16
+ - `!compact`
17
+ - `!reset-session`
18
18
 
19
19
  Any other DM text is sent to the persistent agent session.
20
20
 
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() {
@@ -306,26 +308,28 @@ import {
306
308
  // src/commands.ts
307
309
  async function handleCommand(input, agentService, promptQueue) {
308
310
  const trimmed = input.trim();
309
- if (!trimmed.startsWith("/")) {
311
+ if (!trimmed.startsWith("!")) {
310
312
  return { handled: false };
311
313
  }
312
- if (trimmed === "/help") {
314
+ if (trimmed === "!help") {
313
315
  return {
314
316
  handled: true,
315
317
  response: [
316
318
  "Commands:",
317
- "/help - show this message",
318
- "/status - show current session status",
319
- "/compact - compact the persistent session",
320
- "/reset-session - start a fresh persistent session",
319
+ "!help - show this message",
320
+ "!status - show current session status",
321
+ "!compact - compact the persistent session",
322
+ "!reset-session - start a fresh persistent session",
321
323
  "Any other DM text goes to the persistent agent session."
322
324
  ].join(`
323
325
  `)
324
326
  };
325
327
  }
326
- if (trimmed === "/status") {
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,13 +337,14 @@ 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(`
339
344
  `)
340
345
  };
341
346
  }
342
- if (trimmed === "/compact") {
347
+ if (trimmed === "!compact") {
343
348
  return {
344
349
  handled: true,
345
350
  response: await promptQueue.enqueue(async () => {
@@ -347,7 +352,7 @@ async function handleCommand(input, agentService, promptQueue) {
347
352
  })
348
353
  };
349
354
  }
350
- if (trimmed === "/reset-session") {
355
+ if (trimmed === "!reset-session") {
351
356
  return {
352
357
  handled: true,
353
358
  response: await promptQueue.enqueue(async () => {
@@ -357,7 +362,7 @@ async function handleCommand(input, agentService, promptQueue) {
357
362
  }
358
363
  return {
359
364
  handled: true,
360
- response: `Unknown command: ${trimmed}. Try /help.`
365
+ response: `Unknown command: ${trimmed}. Try !help.`
361
366
  };
362
367
  }
363
368
 
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",