@friendlyrobot/discord-pi-agent 0.7.3 → 0.7.5

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.
@@ -24,9 +24,9 @@ export declare class AgentService {
24
24
  private requireSession;
25
25
  private applyConfiguredThinkingLevel;
26
26
  private applyConfiguredThinkingLevelForSession;
27
- listModels(): Promise<string>;
28
- switchModel(provider: string, modelId: string): Promise<string>;
29
- getCurrentModelDisplay(): string;
27
+ listModels(session?: AgentSession | null): Promise<string>;
28
+ switchModel(provider: string, modelId: string, session?: AgentSession | null): Promise<string>;
29
+ getCurrentModelDisplay(session?: AgentSession | null): string;
30
30
  getThinkingLevel(): {
31
31
  current: ThinkingLevel;
32
32
  available: ThinkingLevel[];
package/dist/index.js CHANGED
@@ -100,9 +100,11 @@ async function collectReply(session, prompt, options = {}) {
100
100
  let eventCount = 0;
101
101
  let toolCount = 0;
102
102
  let sawAgentEnd = false;
103
+ const model = session.model ? `${session.model.provider}/${session.model.id}` : "none";
103
104
  logger3.debug({
104
105
  logPrefix,
105
106
  promptLength: prompt.length,
107
+ model,
106
108
  prompt
107
109
  }, "prompt start");
108
110
  const unsubscribe = session.subscribe((event) => {
@@ -133,6 +135,7 @@ async function collectReply(session, prompt, options = {}) {
133
135
  sawAgentEnd = true;
134
136
  logger3.debug({
135
137
  messageCount: event.messages.length,
138
+ model,
136
139
  logPrefix
137
140
  }, "agent end");
138
141
  }
@@ -152,6 +155,7 @@ async function collectReply(session, prompt, options = {}) {
152
155
  streamedTextLength: streamedText.trim().length,
153
156
  fallbackTextLength: fallbackText.trim().length,
154
157
  errorMessage,
158
+ model,
155
159
  logPrefix
156
160
  }, "prompt done");
157
161
  if (errorMessage) {
@@ -161,6 +165,7 @@ async function collectReply(session, prompt, options = {}) {
161
165
  const transformed = await transformMarkdownTablesToCodeBlocks(finalText);
162
166
  logger3.debug({
163
167
  logPrefix,
168
+ model,
164
169
  finalTextLength: finalText.length,
165
170
  transformedTextLength: transformed.length,
166
171
  transformed: transformed !== finalText
@@ -401,10 +406,10 @@ class AgentService {
401
406
  }
402
407
  }
403
408
  }
404
- async listModels() {
409
+ async listModels(session) {
410
+ const effectiveSession = session ?? this.session;
405
411
  const availableModels = await this.modelRegistry.getAvailable();
406
- const session = this.session;
407
- const currentDisplay = session?.model ? `${session.model.provider}/${session.model.id}` : null;
412
+ const currentDisplay = effectiveSession?.model ? `${effectiveSession.model.provider}/${effectiveSession.model.id}` : null;
408
413
  const lines = availableModels.map((model) => {
409
414
  const display = `${model.provider}/${model.id}`;
410
415
  const marker = currentDisplay === display ? " (current)" : "";
@@ -418,8 +423,8 @@ Usage: !model <provider/modelId> to switch.`
418
423
  ].join(`
419
424
  `);
420
425
  }
421
- async switchModel(provider, modelId) {
422
- const session = this.requireSession();
426
+ async switchModel(provider, modelId, session) {
427
+ const effectiveSession = session ?? this.requireSession();
423
428
  const model = this.modelRegistry.find(provider, modelId);
424
429
  if (!model) {
425
430
  const availableModels = await this.modelRegistry.getAvailable();
@@ -431,20 +436,20 @@ Models from "${provider}": ${matches.join(", ")}` : `
431
436
  Use !model to see all available models.`;
432
437
  return `Model not found: ${provider}/${modelId}.${hint}`;
433
438
  }
434
- if (isSameModel(session.model, model)) {
439
+ if (isSameModel(effectiveSession.model, model)) {
435
440
  return `Already using ${provider}/${modelId}.`;
436
441
  }
437
- await session.setModel(model);
438
- await this.applyConfiguredThinkingLevelForSession(session);
439
- const thinkingInfo = session.supportsThinking() ? ` (thinking: ${session.thinkingLevel})` : "";
442
+ await effectiveSession.setModel(model);
443
+ await this.applyConfiguredThinkingLevelForSession(effectiveSession);
444
+ const thinkingInfo = effectiveSession.supportsThinking() ? ` (thinking: ${effectiveSession.thinkingLevel})` : "";
440
445
  return `Switched to ${provider}/${modelId}${thinkingInfo}.`;
441
446
  }
442
- getCurrentModelDisplay() {
443
- const session = this.session;
444
- if (!session?.model) {
447
+ getCurrentModelDisplay(session) {
448
+ const effectiveSession = session ?? this.session;
449
+ if (!effectiveSession?.model) {
445
450
  return "(no model selected)";
446
451
  }
447
- return `${session.model.provider}/${session.model.id}`;
452
+ return `${effectiveSession.model.provider}/${effectiveSession.model.id}`;
448
453
  }
449
454
  getThinkingLevel() {
450
455
  const session = this.requireSession();
@@ -740,8 +745,8 @@ async function handleCommand(input, ctx) {
740
745
  }
741
746
  const parts = trimmed.split(" ");
742
747
  if (parts.length === 1) {
743
- const current = agentService.getCurrentModelDisplay();
744
- const modelList = await agentService.listModels();
748
+ const current = agentService.getCurrentModelDisplay(effectiveSession);
749
+ const modelList = await agentService.listModels(effectiveSession);
745
750
  return {
746
751
  handled: true,
747
752
  response: `Current model: ${current}
@@ -763,7 +768,7 @@ Use !model without args to see available models.`
763
768
  const modelId = arg.substring(slashIndex + 1);
764
769
  return {
765
770
  handled: true,
766
- response: await agentService.switchModel(provider, modelId)
771
+ response: await agentService.switchModel(provider, modelId, effectiveSession)
767
772
  };
768
773
  }
769
774
  if (trimmed === "!compact") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@friendlyrobot/discord-pi-agent",
3
- "version": "0.7.3",
3
+ "version": "0.7.5",
4
4
  "description": "Reusable Discord gateway bridge for persistent pi agent sessions",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -35,8 +35,8 @@
35
35
  "typecheck": "tsgo --noEmit -p tsconfig.json"
36
36
  },
37
37
  "dependencies": {
38
- "@mariozechner/pi-ai": "^0.73.0",
39
- "@mariozechner/pi-coding-agent": "^0.73.0",
38
+ "@mariozechner/pi-ai": "^0.73.1",
39
+ "@mariozechner/pi-coding-agent": "^0.73.1",
40
40
  "discord.js": "^14.26.4",
41
41
  "dotenv": "^17.4.2",
42
42
  "marked": "^18.0.3",
@@ -45,8 +45,8 @@
45
45
  "prettier": "^3.8.3"
46
46
  },
47
47
  "devDependencies": {
48
- "@types/node": "^25.6.0",
49
- "@typescript/native-preview": "^7.0.0-dev.20260506.1",
48
+ "@types/node": "^25.6.2",
49
+ "@typescript/native-preview": "^7.0.0-dev.20260507.1",
50
50
  "@vitest/ui": "^4.1.5",
51
51
  "vitest": "^4.1.5"
52
52
  }