orquesta-cli 0.2.39 → 0.2.40

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.
@@ -14,5 +14,6 @@ export declare class PlanningLLM {
14
14
  generateTODOList(userRequest: string, contextMessages?: Message[]): Promise<PlanningResult>;
15
15
  generateTODOListWithDocsDecision(userRequest: string, contextMessages?: Message[]): Promise<PlanningWithDocsResult>;
16
16
  }
17
+ export declare function extractLeakedToolCallName(text: string): string | null;
17
18
  export default PlanningLLM;
18
19
  //# sourceMappingURL=index.d.ts.map
@@ -195,6 +195,14 @@ Choose one of your 3 tools now.`,
195
195
  lastError = new Error('Planning LLM returned empty response.');
196
196
  continue;
197
197
  }
198
+ const leakedTool = extractLeakedToolCallName(responseText);
199
+ if (leakedTool) {
200
+ logger.warn('respond_to_user response is a leaked tool-call JSON', { leakedTool });
201
+ lastError = new Error(`You attempted to call '${leakedTool}', which is an Execution LLM tool. ` +
202
+ `As the PLANNING LLM you must use create_todos for action requests ` +
203
+ `(the Execution LLM will run '${leakedTool}' for you) or respond_to_user with plain prose.`);
204
+ continue;
205
+ }
198
206
  return {
199
207
  todos: [],
200
208
  complexity: 'simple',
@@ -254,5 +262,54 @@ Choose one of your 3 tools now.`,
254
262
  };
255
263
  }
256
264
  }
265
+ const PLANNING_TOOL_NAMES = new Set(['ask_to_user', 'create_todos', 'respond_to_user']);
266
+ export function extractLeakedToolCallName(text) {
267
+ for (let start = text.indexOf('{'); start !== -1; start = text.indexOf('{', start + 1)) {
268
+ const end = findBalancedObjectEnd(text, start);
269
+ if (end === -1)
270
+ continue;
271
+ let parsed;
272
+ try {
273
+ parsed = JSON.parse(text.slice(start, end + 1));
274
+ }
275
+ catch {
276
+ continue;
277
+ }
278
+ if (parsed && typeof parsed === 'object') {
279
+ const tool = parsed.tool;
280
+ if (typeof tool === 'string' && tool && !PLANNING_TOOL_NAMES.has(tool))
281
+ return tool;
282
+ start = end;
283
+ }
284
+ }
285
+ return null;
286
+ }
287
+ function findBalancedObjectEnd(s, start) {
288
+ let depth = 0;
289
+ let inString = false;
290
+ let escaped = false;
291
+ for (let i = start; i < s.length; i++) {
292
+ const c = s[i];
293
+ if (inString) {
294
+ if (escaped)
295
+ escaped = false;
296
+ else if (c === '\\')
297
+ escaped = true;
298
+ else if (c === '"')
299
+ inString = false;
300
+ continue;
301
+ }
302
+ if (c === '"')
303
+ inString = true;
304
+ else if (c === '{')
305
+ depth++;
306
+ else if (c === '}') {
307
+ depth--;
308
+ if (depth === 0)
309
+ return i;
310
+ }
311
+ }
312
+ return -1;
313
+ }
257
314
  export default PlanningLLM;
258
315
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orquesta-cli",
3
- "version": "0.2.39",
3
+ "version": "0.2.40",
4
4
  "description": "Orquesta CLI - AI-powered coding assistant with team collaboration",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",