agent-planner-mcp 1.5.1 → 1.5.3
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/package.json +1 -1
- package/src/tools/bdi/beliefs.js +19 -3
package/package.json
CHANGED
package/src/tools/bdi/beliefs.js
CHANGED
|
@@ -463,8 +463,10 @@ async function listPlansHandler(args, apiClient) {
|
|
|
463
463
|
const q = filter.query.toLowerCase();
|
|
464
464
|
plans = plans.filter((p) => (p.title || '').toLowerCase().includes(q));
|
|
465
465
|
}
|
|
466
|
-
plans = plans.slice(0, filter.limit || 50);
|
|
467
466
|
|
|
467
|
+
// Summarize the FULL filtered set BEFORE paginating — otherwise `total` and
|
|
468
|
+
// the status counts only reflect the truncated page, making an agent think
|
|
469
|
+
// it has seen every plan when it hasn't.
|
|
468
470
|
const summary = plans.reduce(
|
|
469
471
|
(acc, p) => {
|
|
470
472
|
acc[p.status] = (acc[p.status] || 0) + 1;
|
|
@@ -474,10 +476,15 @@ async function listPlansHandler(args, apiClient) {
|
|
|
474
476
|
{ total: 0 },
|
|
475
477
|
);
|
|
476
478
|
|
|
479
|
+
const limit = filter.limit || 50;
|
|
480
|
+
const page = plans.slice(0, limit);
|
|
481
|
+
summary.returned = page.length;
|
|
482
|
+
summary.truncated = plans.length > page.length; // true → raise `filter.limit` to see the rest
|
|
483
|
+
|
|
477
484
|
return formatResponse({
|
|
478
485
|
as_of: asOf(),
|
|
479
486
|
summary,
|
|
480
|
-
plans:
|
|
487
|
+
plans: page.map((p) => ({
|
|
481
488
|
id: p.id,
|
|
482
489
|
title: p.title,
|
|
483
490
|
status: p.status,
|
|
@@ -537,7 +544,16 @@ async function searchHandler(args, apiClient) {
|
|
|
537
544
|
result = await apiClient.search.searchPlan(scope_id, query);
|
|
538
545
|
} else {
|
|
539
546
|
const global = await apiClient.search.globalSearch(query);
|
|
540
|
-
|
|
547
|
+
// The backend returns `results` as a GROUPED object
|
|
548
|
+
// ({ plans, nodes, comments, logs }), not a flat array — so the old
|
|
549
|
+
// `Array.isArray(results) ? … : []` always fell to [] and global search
|
|
550
|
+
// returned nothing. Flatten both shapes.
|
|
551
|
+
const r = global?.results;
|
|
552
|
+
const all = Array.isArray(r)
|
|
553
|
+
? r
|
|
554
|
+
: r && typeof r === 'object'
|
|
555
|
+
? [...(r.plans || []), ...(r.nodes || []), ...(r.comments || []), ...(r.logs || [])]
|
|
556
|
+
: [];
|
|
541
557
|
const matchScope = (r) => {
|
|
542
558
|
if (scope === 'global') return true;
|
|
543
559
|
if (scope === 'plans') return r.type === 'plan';
|