thepopebot 1.2.75-beta.12 → 1.2.75-beta.13

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/lib/ai/index.js CHANGED
@@ -385,7 +385,7 @@ async function autoTitle(threadId, firstMessage) {
385
385
 
386
386
  const model = await createModel({ maxTokens: 250 });
387
387
  const response = await model.withStructuredOutput(z.object({ title: z.string() })).invoke([
388
- ['system', 'Generate a descriptive (8-12 word) title for this chat based on the user\'s first message.'],
388
+ ['system', 'Title this chat in 2-5 words. Name the subject matter only. Never start with "User". Never describe what the user is doing — just the topic. Always produce a title, even for vague messages — infer the likely topic.'],
389
389
  ['human', firstMessage],
390
390
  ]);
391
391
  if (response.title.trim()) {
package/lib/chat/api.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { auth } from '../auth/index.js';
2
2
  import { chatStream } from '../ai/index.js';
3
3
  import { v4 as uuidv4 } from 'uuid';
4
+ import { getConfig } from '../config.js';
4
5
 
5
6
  /**
6
7
  * POST handler for /stream/chat — streaming chat with session auth.
@@ -114,11 +115,26 @@ export async function POST(request) {
114
115
  toolCallId: chunk.toolCallId,
115
116
  toolName: chunk.toolName,
116
117
  });
118
+ // Enrich coding_agent input with active agent identity from config
119
+ let input = chunk.args;
120
+ if (chunk.toolName === 'coding_agent') {
121
+ const agent = getConfig('CODING_AGENT') || 'claude-code';
122
+ const providerKeys = {
123
+ 'claude-code': 'CODING_AGENT_CLAUDE_CODE_BACKEND',
124
+ 'pi-coding-agent': 'CODING_AGENT_PI_PROVIDER',
125
+ 'gemini-cli': 'CODING_AGENT_GEMINI_CLI_PROVIDER',
126
+ 'codex-cli': 'CODING_AGENT_CODEX_CLI_PROVIDER',
127
+ 'opencode': 'CODING_AGENT_OPENCODE_PROVIDER',
128
+ 'kimi-cli': 'CODING_AGENT_KIMI_CLI_PROVIDER',
129
+ };
130
+ const backendApi = getConfig(providerKeys[agent]) || 'anthropic';
131
+ input = { ...chunk.args, codingAgent: agent, backendApi };
132
+ }
117
133
  writer.write({
118
134
  type: 'tool-input-available',
119
135
  toolCallId: chunk.toolCallId,
120
136
  toolName: chunk.toolName,
121
- input: chunk.args,
137
+ input,
122
138
  });
123
139
 
124
140
  } else if (chunk.type === 'tool-result') {
@@ -150,12 +150,19 @@ function ToolCall({ part, className }) {
150
150
  /* @__PURE__ */ jsx(WrenchIcon, { size: 14, className: "text-muted-foreground shrink-0 mt-0.5" }),
151
151
  /* @__PURE__ */ jsx("span", { className: "flex flex-col min-w-0 flex-1", children: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
152
152
  /* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: displayName }),
153
- isDone && (() => {
153
+ (() => {
154
154
  try {
155
- const o = typeof part.output === "string" ? JSON.parse(part.output) : part.output;
156
- const meta = Array.isArray(o) ? o.find((e) => e.type === "meta") : o;
157
- if (meta?.codingAgent || meta?.backendApi) {
158
- return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: [meta.codingAgent, meta.backendApi].filter(Boolean).join(" \xB7 ") });
155
+ const agent = part.input?.codingAgent;
156
+ const backend = part.input?.backendApi;
157
+ if (agent || backend) {
158
+ return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: [agent, backend].filter(Boolean).join(" \xB7 ") });
159
+ }
160
+ if (isDone) {
161
+ const o = typeof part.output === "string" ? JSON.parse(part.output) : part.output;
162
+ const meta = Array.isArray(o) ? o.find((e) => e.type === "meta") : o;
163
+ if (meta?.codingAgent || meta?.backendApi) {
164
+ return /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: [meta.codingAgent, meta.backendApi].filter(Boolean).join(" \xB7 ") });
165
+ }
159
166
  }
160
167
  } catch {
161
168
  }
@@ -154,17 +154,29 @@ function ToolCall({ part, className }) {
154
154
  <span className="flex flex-col min-w-0 flex-1">
155
155
  <span className="flex items-center gap-2">
156
156
  <span className="font-medium text-foreground">{displayName}</span>
157
- {isDone && (() => {
157
+ {(() => {
158
158
  try {
159
- const o = typeof part.output === 'string' ? JSON.parse(part.output) : part.output;
160
- const meta = Array.isArray(o) ? o.find(e => e.type === 'meta') : o;
161
- if (meta?.codingAgent || meta?.backendApi) {
159
+ // Read from input (available immediately) or output meta (historical chats)
160
+ const agent = part.input?.codingAgent;
161
+ const backend = part.input?.backendApi;
162
+ if (agent || backend) {
162
163
  return (
163
164
  <span className="text-xs text-muted-foreground">
164
- {[meta.codingAgent, meta.backendApi].filter(Boolean).join(' · ')}
165
+ {[agent, backend].filter(Boolean).join(' · ')}
165
166
  </span>
166
167
  );
167
168
  }
169
+ if (isDone) {
170
+ const o = typeof part.output === 'string' ? JSON.parse(part.output) : part.output;
171
+ const meta = Array.isArray(o) ? o.find(e => e.type === 'meta') : o;
172
+ if (meta?.codingAgent || meta?.backendApi) {
173
+ return (
174
+ <span className="text-xs text-muted-foreground">
175
+ {[meta.codingAgent, meta.backendApi].filter(Boolean).join(' · ')}
176
+ </span>
177
+ );
178
+ }
179
+ }
168
180
  } catch {}
169
181
  return null;
170
182
  })()}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thepopebot",
3
- "version": "1.2.75-beta.12",
3
+ "version": "1.2.75-beta.13",
4
4
  "type": "module",
5
5
  "description": "Create autonomous AI agents with a two-layer architecture: Next.js Event Handler + Docker Agent.",
6
6
  "bin": {