clementine-agent 1.18.114 → 1.18.116
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/agent/run-agent.js +23 -1
- package/package.json +1 -1
package/dist/agent/run-agent.js
CHANGED
|
@@ -128,6 +128,28 @@ function buildRunAgentEnv() {
|
|
|
128
128
|
return env;
|
|
129
129
|
}
|
|
130
130
|
const logger = pino({ name: 'clementine.run-agent' });
|
|
131
|
+
/**
|
|
132
|
+
* Map a sessionKey to the CLEMENTINE_INTERACTION_SOURCE value the MCP
|
|
133
|
+
* subprocess will read. Mirrors `inferInteractionSource` in assistant.ts
|
|
134
|
+
* (kept inline here to avoid a circular import — assistant.ts already
|
|
135
|
+
* imports from this module). Owner-DM-only admin tools like
|
|
136
|
+
* refresh_tool_inventory / allow_tool / env_set check for exactly
|
|
137
|
+
* 'owner-dm', so the previous hardcoded 'interactive' value broke them
|
|
138
|
+
* for every chat session routed through runAgent.
|
|
139
|
+
*/
|
|
140
|
+
function interactionSourceForSession(sessionKey, source) {
|
|
141
|
+
if (source === 'cron' || source === 'heartbeat')
|
|
142
|
+
return 'autonomous';
|
|
143
|
+
if (!sessionKey)
|
|
144
|
+
return 'autonomous';
|
|
145
|
+
if (sessionKey.startsWith('discord:member'))
|
|
146
|
+
return 'member-channel';
|
|
147
|
+
if (sessionKey.startsWith('discord:channel:'))
|
|
148
|
+
return 'owner-channel';
|
|
149
|
+
if (sessionKey.includes(':'))
|
|
150
|
+
return 'owner-dm';
|
|
151
|
+
return 'autonomous';
|
|
152
|
+
}
|
|
131
153
|
// Last-resort fallbacks for callers that pass NO maxBudgetUsd. The
|
|
132
154
|
// production callers (`runAgent` from gateway/router, runAgentCron,
|
|
133
155
|
// runAgentHeartbeat) read `BUDGET.*` from src/config.ts — which is
|
|
@@ -229,7 +251,7 @@ export async function runAgent(prompt, opts) {
|
|
|
229
251
|
...subprocessEnv,
|
|
230
252
|
CLEMENTINE_HOME: BASE_DIR,
|
|
231
253
|
...(opts.profile?.slug ? { CLEMENTINE_TEAM_AGENT: opts.profile.slug } : {}),
|
|
232
|
-
CLEMENTINE_INTERACTION_SOURCE:
|
|
254
|
+
CLEMENTINE_INTERACTION_SOURCE: interactionSourceForSession(opts.sessionKey, source),
|
|
233
255
|
},
|
|
234
256
|
},
|
|
235
257
|
...(opts.extraMcpServers ?? {}),
|