Skip to content

Commit b8c7ddb

Browse files
authored
fix: Strip leading whitespace from search-actors text output (#760)
fix: Adjust indentation in pricing info output for consistency
1 parent 1ede15d commit b8c7ddb

3 files changed

Lines changed: 26 additions & 22 deletions

File tree

src/tools/default/search_actors.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,26 @@ export const defaultSearchActors: ToolEntry = Object.freeze({
5454
`,
5555
};
5656

57-
const instructions = dedent`
57+
// Build header and footer with separate `dedent` calls and concatenate around
58+
// `actorCardText` — Actor cards may contain tab-indented lines (pay-per-event
59+
// pricing) that would corrupt `dedent`'s indent detection if interpolated into
60+
// the surrounding template.
61+
const header = dedent`
5862
# Search results:
5963
- **Search query:** ${parsed.keywords}
6064
- **Number of Actors found:** ${actors.length}
6165
6266
# Actors:
63-
64-
${actorCardText}
65-
67+
`;
68+
const footer = dedent`
6669
If you need more detailed information about any of these Actors, including their input
6770
schemas and usage instructions, use the ${HelperTools.ACTOR_GET_DETAILS} tool with the
6871
specific Actor name.
6972
IMPORTANT: You MUST always do a second search with broader, more generic keywords
7073
(e.g., just the platform name like "TikTok" instead of "TikTok posts") to make sure
7174
you haven't missed a better Actor.
7275
`;
73-
return buildMCPResponse({ texts: [instructions], structuredContent });
76+
const texts = [`${header}\n\n${actorCardText}\n\n${footer}`];
77+
return buildMCPResponse({ texts, structuredContent });
7478
},
7579
} as const);

src/utils/pricing_info.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ function formatPayPerEventComplete(
268268

269269
const eventLines = Object.values(pricingPerEvent.actorChargeEvents).map((event) => {
270270
const detail = formatCompleteEventDetail(event);
271-
return `\t- **${event.eventTitle}**: ${event.eventDescription ?? ''} (${detail})`;
271+
return ` - **${event.eventTitle}**: ${event.eventDescription ?? ''} (${detail})`;
272272
});
273273

274274
return `This Actor is paid per event:\n${eventLines.join('\n')}`;
@@ -414,8 +414,8 @@ function formatPayPerEventSimplified(
414414
}
415415

416416
const detail = typeof price === 'number' ? `$${price} per event` : 'No price info';
417-
if (omitDescriptions) return `\t- **${event.eventTitle}**: ${detail}`;
418-
return `\t- **${event.eventTitle}**: ${event.eventDescription ?? ''} (${detail})`;
417+
if (omitDescriptions) return ` - **${event.eventTitle}**: ${detail}`;
418+
return ` - **${event.eventTitle}**: ${event.eventDescription ?? ''} (${detail})`;
419419
});
420420

421421
const body = `This Actor is paid per event:\n${eventLines.join('\n')}`;

tests/unit/utils.pricing_info.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,17 +226,17 @@ describe('pricingInfoToString (complete mode)', () => {
226226
const out = pricingInfoToString(multiTierPayPerEvent);
227227
expect(out).toBe(
228228
'This Actor is paid per event:\n'
229-
+ '\t- **Scraped place**: A Google Maps place scraped '
229+
+ ' - **Scraped place**: A Google Maps place scraped '
230230
+ '(FREE: $0.004, BRONZE: $0.004, SILVER: $0.003, '
231231
+ 'GOLD: $0.0021, PLATINUM: $0.00126, DIAMOND: $0.00076 per event)\n'
232-
+ '\t- **Actor start**: Initial fee for starting the Actor ($0.00005 per event)',
232+
+ ' - **Actor start**: Initial fee for starting the Actor ($0.00005 per event)',
233233
);
234234
});
235235

236236
it('E4: single-tier event renders as flat (no tier label)', () => {
237237
expect(pricingInfoToString(singleTierPayPerEvent)).toBe(
238238
'This Actor is paid per event:\n'
239-
+ '\t- **Scraped place**: A Google Maps place scraped ($0.004 per event)',
239+
+ ' - **Scraped place**: A Google Maps place scraped ($0.004 per event)',
240240
);
241241
});
242242

@@ -420,16 +420,16 @@ describe('pricingInfoToSimplifiedString (simplified mode)', () => {
420420
it('E2: user on GOLD — one price per event, pricingNote appended', () => {
421421
expect(pricingInfoToSimplifiedString(multiTierPayPerEvent, 'GOLD')).toBe(
422422
`This Actor is paid per event:\n`
423-
+ `\t- **Scraped place**: A Google Maps place scraped ($0.0021 per event)\n`
424-
+ `\t- **Actor start**: Initial fee for starting the Actor ($0.00005 per event)\n${
423+
+ ` - **Scraped place**: A Google Maps place scraped ($0.0021 per event)\n`
424+
+ ` - **Actor start**: Initial fee for starting the Actor ($0.00005 per event)\n${
425425
NOTE_GOLD}`,
426426
);
427427
});
428428

429429
it('E4: single-tier actor — flat price, no pricingNote', () => {
430430
expect(pricingInfoToSimplifiedString(singleTierPayPerEvent, 'GOLD')).toBe(
431431
'This Actor is paid per event:\n'
432-
+ '\t- **Scraped place**: A Google Maps place scraped ($0.004 per event)',
432+
+ ' - **Scraped place**: A Google Maps place scraped ($0.004 per event)',
433433
);
434434
});
435435

@@ -469,20 +469,20 @@ describe('pricingInfoToSimplifiedString (simplified mode)', () => {
469469
it('omits pricingNote text when PAY_PER_EVENT events resolve to different tiers', () => {
470470
expect(pricingInfoToSimplifiedString(mixedTierPayPerEvent, 'GOLD')).toBe(
471471
'This Actor is paid per event:\n'
472-
+ '\t- **A**: ($0.005 per event)\n'
473-
+ '\t- **B**: ($0.02 per event)',
472+
+ ' - **A**: ($0.005 per event)\n'
473+
+ ' - **B**: ($0.02 per event)',
474474
);
475475
});
476476

477477
it('omits event descriptions in text when PAY_PER_EVENT has more than 5 events', () => {
478478
expect(pricingInfoToSimplifiedString(longPayPerEvent, 'FREE')).toBe(
479479
'This Actor is paid per event:\n'
480-
+ '\t- **Result**: $0.0037 per event\n'
481-
+ '\t- **Add-on: Date filter**: $0.0013 per event\n'
482-
+ '\t- **Add-on: Popularity filter**: $0.0013 per event\n'
483-
+ '\t- **Add-on: Follower / Following**: $0.004 per event\n'
484-
+ '\t- **Add-on: Search video sorting**: $0.0013 per event\n'
485-
+ `\t- **Actor start**: $0.001 per event\n${EVENT_DESCRIPTIONS_OMITTED_NOTE}`,
480+
+ ' - **Result**: $0.0037 per event\n'
481+
+ ' - **Add-on: Date filter**: $0.0013 per event\n'
482+
+ ' - **Add-on: Popularity filter**: $0.0013 per event\n'
483+
+ ' - **Add-on: Follower / Following**: $0.004 per event\n'
484+
+ ' - **Add-on: Search video sorting**: $0.0013 per event\n'
485+
+ ` - **Actor start**: $0.001 per event\n${EVENT_DESCRIPTIONS_OMITTED_NOTE}`,
486486
);
487487
});
488488
});

0 commit comments

Comments
 (0)