@triplef/agent 1.0.1 → 1.0.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.
@@ -309,7 +309,97 @@ function composeSnippetKeys(preset) {
309
309
  return { requiredKeys, optionalKeys };
310
310
  }
311
311
 
312
- // src/schemas/constants/url-trust.constants.ts
312
+ // src/schemas/helpers/url-trust/is-absolute-http-url.helper.ts
313
+ function isAbsoluteHttpUrl(value) {
314
+ try {
315
+ const protocol = new URL(value).protocol;
316
+ return protocol === "http:" || protocol === "https:";
317
+ } catch {
318
+ return false;
319
+ }
320
+ }
321
+
322
+ // src/schemas/helpers/url-trust/safe-media-url.helper.ts
323
+ var LOCAL_STORAGE_URL_PATTERN = /^\/api\/v1\/storage\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+\/[A-Za-z0-9]+$/;
324
+ function safeMediaUrl(message = "must be a safe media URL") {
325
+ const text = typeof message === "string" ? message : message.message;
326
+ return z.string().refine((value) => LOCAL_STORAGE_URL_PATTERN.test(value) || isAbsoluteHttpUrl(value), { message: text });
327
+ }
328
+
329
+ // src/schemas/helpers/url-trust/safe-media-url-or-empty.helper.ts
330
+ function safeMediaUrlOrEmpty(message = "must be a safe media URL") {
331
+ return safeMediaUrl(message).optional().or(z.literal(""));
332
+ }
333
+ function safeVideoUrl(message = "must be a safe video URL") {
334
+ const text = typeof message === "string" ? message : message.message;
335
+ return z.string().refine(isAbsoluteHttpUrl, { message: text });
336
+ }
337
+
338
+ // src/schemas/response/video-gallery-item-json.schema.ts
339
+ var videoGalleryItemSchema = z.object(
340
+ {
341
+ videoUrl: safeVideoUrl({
342
+ message: "videoGalleryItems.videoUrl must be a valid URL"
343
+ }),
344
+ title: z.string().min(1, {
345
+ message: "videoGalleryItems.title must not be empty"
346
+ }),
347
+ caption: z.string().min(1, {
348
+ message: "videoGalleryItems.caption must not be empty"
349
+ }),
350
+ duration: z.string().optional(),
351
+ channel: z.string().optional(),
352
+ date: z.string().optional(),
353
+ views: z.number().int().min(0).optional(),
354
+ thumbnailUrl: safeMediaUrlOrEmpty({
355
+ message: "videoGalleryItems.thumbnailUrl must be a valid URL"
356
+ }),
357
+ description: z.string().optional()
358
+ },
359
+ { message: "videoGalleryItems entries must be objects with videoUrl" }
360
+ );
361
+ function heroVideoHasTitle(data) {
362
+ return !data.heroVideoUrl?.trim() || Boolean(data.heroVideoTitle?.trim());
363
+ }
364
+ var HERO_VIDEO_TITLE_ISSUE = {
365
+ message: "heroVideoTitle must not be empty when heroVideoUrl is set",
366
+ path: ["heroVideoTitle"]
367
+ };
368
+ var RESPONSE_LAYOUTS = ["classic", "editorial", "split", "mosaic"];
369
+ var responseLayoutSchema = z.enum(RESPONSE_LAYOUTS);
370
+
371
+ // src/prompts/snippets/helpers/compose-snippet-schema.helper.ts
372
+ function composeSnippetSchema(preset) {
373
+ const shape = Object.assign(
374
+ { layout: responseLayoutSchema },
375
+ ...preset.snippets.map((snippet) => snippet.fields)
376
+ );
377
+ return z.object(shape).refine(heroVideoHasTitle, HERO_VIDEO_TITLE_ISSUE);
378
+ }
379
+ var authorMetaSnippet = {
380
+ fields: {
381
+ author: z.string().optional(),
382
+ publishDate: z.string().optional(),
383
+ readTime: z.string().optional()
384
+ },
385
+ instruction: `SNIPPET article metadata (client meta pills above the response):
386
+ - Needs: attribution from the retrieved sources.
387
+ - author: the author or publication name when the sources name one.
388
+ - publishDate: an ISO date string or human-readable date when known.
389
+ - readTime: leave empty \u2014 the server computes read time automatically.`
390
+ };
391
+ var bodyExtensiveSnippet = {
392
+ fields: {
393
+ sectionTitle: z.string().optional(),
394
+ sectionContent: z.string().optional()
395
+ },
396
+ instruction: `SNIPPET body \u2014 EXTENSIVE (client body paragraphs):
397
+ - Needs: the full detail the retrieved results offer.
398
+ - sectionContent: the main body text as one plain-text string of 4-8 paragraphs: context, quotes, reactions, and background. This is the article's core \u2014 write it in full.
399
+ - sectionTitle: a heading for the main body section; omit only when the article needs none.`
400
+ };
401
+
402
+ // src/schemas/constants/url-trust.constant.ts
313
403
  var BLOCKED_URL_HOSTS = /* @__PURE__ */ new Set([
314
404
  // Google thumbnail / static asset proxies
315
405
  "encrypted-tbn0.gstatic.com",
@@ -391,100 +481,15 @@ function isTrustedUrl(url, options = {}) {
391
481
  return true;
392
482
  }
393
483
 
394
- // src/schemas/helpers/url-trust/url-schema.helper.ts
484
+ // src/schemas/helpers/url-trust/safe-url.helper.ts
395
485
  function safeUrl(message = "must be a safe URL") {
396
486
  const text = typeof message === "string" ? message : message.message;
397
487
  return z.string().url({ message: "must be a valid URL" }).refine((value) => isTrustedUrl(value, { allowPrivate: false }), {
398
488
  message: text
399
489
  });
400
490
  }
401
- var LOCAL_STORAGE_URL_PATTERN = /^\/api\/v1\/storage\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+\/[A-Za-z0-9]+$/;
402
- function isAbsoluteHttpUrl(value) {
403
- try {
404
- const protocol = new URL(value).protocol;
405
- return protocol === "http:" || protocol === "https:";
406
- } catch {
407
- return false;
408
- }
409
- }
410
- function safeVideoUrl(message = "must be a safe video URL") {
411
- const text = typeof message === "string" ? message : message.message;
412
- return z.string().refine(isAbsoluteHttpUrl, { message: text });
413
- }
414
- function safeVideoUrlOrEmpty(message = "must be a safe video URL") {
415
- return safeVideoUrl(message).optional().or(z.literal(""));
416
- }
417
- function safeMediaUrl(message = "must be a safe media URL") {
418
- const text = typeof message === "string" ? message : message.message;
419
- return z.string().refine((value) => LOCAL_STORAGE_URL_PATTERN.test(value) || isAbsoluteHttpUrl(value), { message: text });
420
- }
421
- function safeMediaUrlOrEmpty(message = "must be a safe media URL") {
422
- return safeMediaUrl(message).optional().or(z.literal(""));
423
- }
424
-
425
- // src/schemas/response/video-gallery-item-json.schema.ts
426
- var videoGalleryItemSchema = z.object(
427
- {
428
- videoUrl: safeVideoUrl({
429
- message: "videoGalleryItems.videoUrl must be a valid URL"
430
- }),
431
- title: z.string().min(1, {
432
- message: "videoGalleryItems.title must not be empty"
433
- }),
434
- caption: z.string().min(1, {
435
- message: "videoGalleryItems.caption must not be empty"
436
- }),
437
- duration: z.string().optional(),
438
- channel: z.string().optional(),
439
- date: z.string().optional(),
440
- views: z.number().int().min(0).optional(),
441
- thumbnailUrl: safeMediaUrlOrEmpty({
442
- message: "videoGalleryItems.thumbnailUrl must be a valid URL"
443
- }),
444
- description: z.string().optional()
445
- },
446
- { message: "videoGalleryItems entries must be objects with videoUrl" }
447
- );
448
- function heroVideoHasTitle(data) {
449
- return !data.heroVideoUrl?.trim() || Boolean(data.heroVideoTitle?.trim());
450
- }
451
- var HERO_VIDEO_TITLE_ISSUE = {
452
- message: "heroVideoTitle must not be empty when heroVideoUrl is set",
453
- path: ["heroVideoTitle"]
454
- };
455
- var RESPONSE_LAYOUTS = ["classic", "editorial", "split", "mosaic"];
456
- var responseLayoutSchema = z.enum(RESPONSE_LAYOUTS);
457
491
 
458
- // src/prompts/snippets/helpers/compose-snippet-schema.helper.ts
459
- function composeSnippetSchema(preset) {
460
- const shape = Object.assign(
461
- { layout: responseLayoutSchema },
462
- ...preset.snippets.map((snippet) => snippet.fields)
463
- );
464
- return z.object(shape).refine(heroVideoHasTitle, HERO_VIDEO_TITLE_ISSUE);
465
- }
466
- var authorMetaSnippet = {
467
- fields: {
468
- author: z.string().optional(),
469
- publishDate: z.string().optional(),
470
- readTime: z.string().optional()
471
- },
472
- instruction: `SNIPPET article metadata (client meta pills above the response):
473
- - Needs: attribution from the retrieved sources.
474
- - author: the author or publication name when the sources name one.
475
- - publishDate: an ISO date string or human-readable date when known.
476
- - readTime: leave empty \u2014 the server computes read time automatically.`
477
- };
478
- var bodyExtensiveSnippet = {
479
- fields: {
480
- sectionTitle: z.string().optional(),
481
- sectionContent: z.string().optional()
482
- },
483
- instruction: `SNIPPET body \u2014 EXTENSIVE (client body paragraphs):
484
- - Needs: the full detail the retrieved results offer.
485
- - sectionContent: the main body text as one plain-text string of 4-8 paragraphs: context, quotes, reactions, and background. This is the article's core \u2014 write it in full.
486
- - sectionTitle: a heading for the main body section; omit only when the article needs none.`
487
- };
492
+ // src/schemas/response/card-json.schema.ts
488
493
  var cardSchema = z.object(
489
494
  {
490
495
  url: safeUrl({ message: "cards entries must have a valid url" }),
@@ -553,6 +558,11 @@ var headerArticleSnippet = {
553
558
  - title: a concise, descriptive headline. REQUIRED, non-empty.
554
559
  - subtitle: an optional one-line summary; omit when it adds nothing.`
555
560
  };
561
+ function safeVideoUrlOrEmpty(message = "must be a safe video URL") {
562
+ return safeVideoUrl(message).optional().or(z.literal(""));
563
+ }
564
+
565
+ // src/prompts/snippets/hero-media.snippet.ts
556
566
  var heroMediaSnippet = {
557
567
  fields: {
558
568
  heroImageUrl: safeMediaUrlOrEmpty(),
@@ -1147,7 +1157,7 @@ function localizedQuerySuffix(lang) {
1147
1157
  }
1148
1158
  }
1149
1159
 
1150
- // src/prompts/harness/execute/execute-language.helper.ts
1160
+ // src/prompts/harness/execute/helpers/execute-language.helper.ts
1151
1161
  function buildExecuteLanguageInstruction(language, options) {
1152
1162
  if (!language) return "";
1153
1163
  const langSuffix = options?.queryLanguageName ? localizedQuerySuffix(language) : "";
@@ -1156,6 +1166,16 @@ function buildExecuteLanguageInstruction(language, options) {
1156
1166
  return `Detected user language: ${language}${suffix}. Use this language in all search queries and pass it to tools that accept a language/locale parameter (e.g. search_lang, hl, gl) when available. EXCEPTION: do NOT pass a language/locale to *ImageSearch tools \u2014 images are visual and language-agnostic, so a locale parameter only narrows results; omit it unless the user explicitly asked for images of a specific language.${videoSuffix}`;
1157
1167
  }
1158
1168
 
1169
+ // src/prompts/harness/execute/helpers/stockmarket-note.helper.ts
1170
+ function buildStockmarketNote(template) {
1171
+ if (template !== "stockmarketitem" && template !== "stockmarketlist") {
1172
+ return "";
1173
+ }
1174
+ return `
1175
+ STOCK MARKET: the client chart renders ONLY from the series streamed by eodhdHistory (and eodhdIntraday for the volume profile). You MUST call eodhdHistory for every instrument so the chart is not empty \u2014 do not skip it because you think the quote or narrative is enough.
1176
+ WEB SEARCH: issue SEVERAL *WebSearch queries in parallel, each with a distinct angle (latest company news, earnings/guidance, partners/suppliers/customers, sector outlook) \u2014 one generic query is not enough for a market answer.`;
1177
+ }
1178
+
1159
1179
  // src/prompts/harness/execute/image-execute.prompt.ts
1160
1180
  var IMAGE_TASK_QUERY_GUIDANCE = `QUERY CRAFTING (image task) \u2014 phrase each tool query for its endpoint; never copy one query across tools:
1161
1181
  - Identify the subject first: read the visible signals (on-screen text, logos, watermarks, characters, outfits, UI elements) and use the filenames in the image inventory as hints. Filenames are hints, never verbatim queries.
@@ -1197,16 +1217,6 @@ Author each input yourself: derive standalone queries from the attached image(s)
1197
1217
  Call ONLY the missing tools.`;
1198
1218
  }
1199
1219
 
1200
- // src/prompts/harness/execute/stockmarket-note.helper.ts
1201
- function buildStockmarketNote(template) {
1202
- if (template !== "stockmarketitem" && template !== "stockmarketlist") {
1203
- return "";
1204
- }
1205
- return `
1206
- STOCK MARKET: the client chart renders ONLY from the series streamed by eodhdHistory (and eodhdIntraday for the volume profile). You MUST call eodhdHistory for every instrument so the chart is not empty \u2014 do not skip it because you think the quote or narrative is enough.
1207
- WEB SEARCH: issue SEVERAL *WebSearch queries in parallel, each with a distinct angle (latest company news, earnings/guidance, partners/suppliers/customers, sector outlook) \u2014 one generic query is not enough for a market answer.`;
1208
- }
1209
-
1210
1220
  // src/prompts/harness/helpers/format-current-timestamp.helper.ts
1211
1221
  function formatCurrentTimestamp() {
1212
1222
  return (/* @__PURE__ */ new Date()).toLocaleString("en-US", {
@@ -1284,7 +1294,7 @@ FINAL REMINDER:
1284
1294
  - Every query names its subject explicitly; never pass the user message verbatim as a query.`;
1285
1295
  }
1286
1296
 
1287
- // src/schemas/helpers/tools/tool-registry.constants.ts
1297
+ // src/schemas/helpers/tools/tool-registry.constant.ts
1288
1298
  var VARIANT_NAMES = ["grayscale", "denoised", "sharpened", "clahe"];
1289
1299
  var TOOL_DESCRIPTIONS = {
1290
1300
  brightDataWebSearch: "Search the web using Bright Data SERP API (Google). Returns organic results with titles, snippets, and links. Supports an optional recency window (day/week/month/year) for fresh results.",
@@ -2095,6 +2105,17 @@ ${TEXT_BASE_INSTRUCTIONS}
2095
2105
  - Keep it short: one to three compact paragraphs, no report structure, no headings unless the answer genuinely needs them.
2096
2106
  - Close with exactly one short follow-up offer in the user's language: you can look up the latest news, write an in-depth article, or put together an evaluation/review of the subject (e.g. "Magst du aktuelle News, einen ausf\xFChrlichen Artikel oder eine Bewertung dazu?").
2097
2107
  - Do NOT produce the article, news piece, or evaluation now \u2014 the offer is only an offer.`;
2108
+ var TEXT_OPINION_INSTRUCTIONS = `MODE: TEXT \u2014 OPINION
2109
+
2110
+ Goal: Give your own honest judgment on a subject the way a knowledgeable human answers a friend's "what do you think?" \u2014 using streaming text.
2111
+
2112
+ ${TEXT_BASE_INSTRUCTIONS}
2113
+ - Lead with a direct first-person verdict ("Yes \u2014 give it a shot", "I'd hold off for now"), then the reasoning behind it. Take a position: never hide behind neutral report language ("critics say\u2026", "opinions are mixed\u2026") as a substitute for your own judgment \u2014 evidence supports your take, it does not replace it.
2114
+ - When tool results are present, treat them as grounding: prefer them over stale training knowledge, weigh the sourced reception and reports openly, and let them shape your verdict. When nothing was retrieved, answer from your own knowledge and note when the subject may have moved on since.
2115
+ - Keep it conversational and compact: prose with light Markdown at most \u2014 no headline or title block, no report sections, no score box, no pros/cons artifacts of a review piece.
2116
+ - Your COGNITION blocks (when present as system messages) are your accumulated model of this user: use them silently to tailor the verdict to their tastes and situation \u2014 they are derived working context, never the user's words, so never quote them verbatim as if the user stated them.
2117
+ - Close with exactly one short follow-up offer in the user's language: you can put together a full structured evaluation/review with pros and cons (e.g. "Want the full breakdown as a proper review?").
2118
+ - Do NOT produce the structured evaluation now \u2014 the offer is only an offer.`;
2098
2119
 
2099
2120
  // src/prompts/instructions/videolist.instruction.ts
2100
2121
  var VIDEOLIST_INSTRUCTIONS = `MODE: VIDEOLIST
@@ -2157,7 +2178,7 @@ var TEMPLATE_VARIANTS = {
2157
2178
  videolist: ["default"],
2158
2179
  stockmarketitem: ["default"],
2159
2180
  stockmarketlist: ["default"],
2160
- text: ["default", "coding", "familiarity"]
2181
+ text: ["default", "coding", "familiarity", "opinion"]
2161
2182
  };
2162
2183
  var VARIANT_INSTRUCTIONS = {
2163
2184
  // describe
@@ -2187,7 +2208,8 @@ var VARIANT_INSTRUCTIONS = {
2187
2208
  // text
2188
2209
  "text:default": TEXT_INSTRUCTIONS,
2189
2210
  "text:coding": TEXT_CODING_INSTRUCTIONS,
2190
- "text:familiarity": TEXT_FAMILIARITY_INSTRUCTIONS
2211
+ "text:familiarity": TEXT_FAMILIARITY_INSTRUCTIONS,
2212
+ "text:opinion": TEXT_OPINION_INSTRUCTIONS
2191
2213
  };
2192
2214
  function resolveVariantInstructions(template, variantId = DEFAULT_VARIANT_ID) {
2193
2215
  const instructions = VARIANT_INSTRUCTIONS[`${template}:${variantId}`] ?? VARIANT_INSTRUCTIONS[`${template}:${DEFAULT_VARIANT_ID}`] ?? "";
@@ -2233,14 +2255,16 @@ var TEMPLATE_RULES = `TEMPLATE RULES
2233
2255
  - summary: for recapping prior conversation or a provided topic without new images. No tools unless the user explicitly asks for external facts.
2234
2256
  When the user asks for external facts, online research, images, or videos with a summary, include the enabled *WebSearch tool and every enabled *ImageSearch and *VideoSearch tool (same media behavior as article).
2235
2257
  Only set imageCount or videoCount when the user explicitly requests a specific number; otherwise omit them and the system will use configured defaults.
2236
- - evaluation: for critiquing, reviewing, assessing, or weighing pros and cons of something from the conversation.
2258
+ - evaluation: for commissioned critiques, reviews, assessments, or pros/cons weigh-ups of something from the conversation \u2014 the structured editorial review piece.
2259
+ A request phrased as a question seeking YOUR opinion or recommendation ("do you think\u2026?", "should I\u2026?", "is it worth it?", "what's your take?") is NOT an evaluation \u2014 classify it as template "text", variant "opinion" (see OPINION QUESTION RULES).
2237
2260
  The evaluation template ALWAYS includes every enabled *ImageSearch and *VideoSearch tool (same media behavior as article) \u2014 every evaluation renders hero and gallery media of its subject.
2238
2261
  Include the enabled *WebSearch tool when the user asks for external facts, online research, or the subject needs grounding beyond the conversation.
2239
2262
  Only set imageCount or videoCount when the user explicitly requests a specific number; otherwise omit them and the system will use configured defaults.
2240
2263
  - product: for specific product lookups with purchase intent \u2014 prices, shop offers, deals, where to buy. Tool selection per the PRODUCT TEMPLATE RULES above.
2241
2264
  - shoplist: for repeated purchase questions about a product already covered by a full product overview \u2014 prices again, other shops, availability. Tool selection per the SHOPLIST TEMPLATE RULES above.
2242
2265
  - text: catch-all for chat, coding, creative writing. Tools only when external data needed.
2243
- Familiarity questions ("do you know X?", "have you heard of X?") use the "familiarity" variant \u2014 see FAMILIARITY QUESTION RULES.`;
2266
+ Familiarity questions ("do you know X?", "have you heard of X?") use the "familiarity" variant \u2014 see FAMILIARITY QUESTION RULES.
2267
+ Opinion and recommendation questions ("do you think\u2026?", "should I\u2026?", "would you recommend\u2026?") use the "opinion" variant \u2014 see OPINION QUESTION RULES.`;
2244
2268
  var MEDIA_REQUEST_RULES = `MEDIA REQUEST RULES
2245
2269
  - When the user asks for media (images, videos, screenshots, photos, graphics) about a topic, this is NOT a clarification \u2014 classify it with the appropriate media tools.
2246
2270
  - If the user wants ONLY images or ONLY videos (no accompanying article), choose "imagelist" or "videolist" respectively.
@@ -2288,6 +2312,9 @@ Use these examples to resolve "news" vs "article":
2288
2312
  - User: "latest music videos from Billie Eilish" \u2192 template: "videolist", tools: [serperVideoSearch]
2289
2313
  - User: "how does NTE compare to Wuthering Waves?" \u2192 template: "evaluation", tools: [serperWebSearch, serperImageSearch, serperVideoSearch]
2290
2314
  - User: "iPhone 16 Pro vs Pixel 9 Pro \u2014 which camera is better?" \u2192 template: "evaluation", tools: [serperWebSearch, serperImageSearch, serperVideoSearch]
2315
+ - User: "write me a full review of NTE with pros and cons" \u2192 template: "evaluation", tools: [serperWebSearch, serperImageSearch, serperVideoSearch]
2316
+ - User: "do you think I should try NTE?" \u2192 template: "text", prompt: "opinion", tools: [serperWebSearch]
2317
+ - User: "would you recommend the Gothic remake to a newcomer?" \u2192 template: "text", prompt: "opinion", tools: [serperWebSearch]
2291
2318
 
2292
2319
  Follow-up media requests (user adds images/videos/news to established topic):
2293
2320
  - User: "show me images" (after discussing a game) \u2192 template: "article", tools: [serperWebSearch, serperImageSearch, serperVideoSearch]
@@ -2314,9 +2341,8 @@ var FOLLOW_UP_RULES = `FOLLOW-UP / REFINEMENT RULES
2314
2341
  \u2192 If the user also asks for external facts, online research, images, or videos, include the enabled *WebSearch tool and every enabled *ImageSearch and *VideoSearch tool.
2315
2342
  \u2192 Otherwise, do NOT invoke a *WebSearch or other tools unless external facts are explicitly requested.
2316
2343
  - If the user asks for an evaluation, critique, review, pros/cons, or judgment about items from the prior conversation:
2317
- \u2192 Choose template "evaluation".
2318
- \u2192 Always include every enabled *ImageSearch and *VideoSearch tool.
2319
- \u2192 Also include the enabled *WebSearch tool when the user asks for external facts or online research.
2344
+ \u2192 For a commissioned structured review piece: choose template "evaluation", include every enabled *ImageSearch and *VideoSearch tool, and also the enabled *WebSearch tool when the user asks for external facts or online research.
2345
+ \u2192 When the user instead asks for YOUR take, opinion, or a personal recommendation ("do you think I should\u2026?", "is it still worth it?", "your honest opinion?"): choose template "text", prompt "opinion" per the OPINION QUESTION RULES \u2014 no media tools.
2320
2346
  - Examples:
2321
2347
  Prior: article about "Gothic remake". User: "now show me images" \u2192 article, tools: [serperWebSearch, serperImageSearch]
2322
2348
  Prior: article about "Gothic remake". User: "add videos too" \u2192 article, tools: [serperWebSearch, serperImageSearch, serperVideoSearch]
@@ -2327,7 +2353,7 @@ var FOLLOW_UP_RULES = `FOLLOW-UP / REFINEMENT RULES
2327
2353
  Prior: article about "Gothic remake". User: "evaluate this game" \u2192 evaluation, tools: [serperImageSearch, serperVideoSearch].
2328
2354
  Prior: product overview for "Sony WH-1000XM5" ([Template: product]). User: "where else can I buy it?" \u2192 shoplist, tools: [serperWebSearch, serperShoppingSearch, serperImageSearch].
2329
2355
  Prior: product overview for "Samsung 990 Pro 2TB" ([Template: product]). User: "gibt es das auch woanders g\xFCnstiger?" (German \u2014 is it cheaper anywhere else?) \u2192 shoplist, tools: [serperWebSearch, serperShoppingSearch, serperImageSearch].
2330
- Prior: product overview for "Sony WH-1000XM5" ([Template: product]). User: "is it still worth it?" \u2192 evaluation, tools: [serperImageSearch, serperVideoSearch].
2356
+ Prior: product overview for "Sony WH-1000XM5" ([Template: product]). User: "is it still worth it?" \u2192 text:opinion (your verdict asked, not a new review piece), tools: [serperWebSearch].
2331
2357
  - If the user provides corrections (e.g. "I wanted images"), add the missing tools to the existing set.
2332
2358
  - Do NOT downgrade template to text just because the user is clarifying.
2333
2359
  - If the latest message alone seems vague ("show me"), check prior turns for context.
@@ -2339,7 +2365,7 @@ When template is article, news, or text and the user query involves:
2339
2365
  - factual research, data, statistics: include the enabled *WebSearch tool
2340
2366
  - specific named entities (games, movies, books, people): include the enabled *WebSearch tool
2341
2367
  - current events, news, announcements: include the enabled *WebSearch tool + newsSearch
2342
- - personal opinion, creative writing, brainstorming: exclude *WebSearch tools
2368
+ - personal opinion, creative writing, brainstorming: exclude *WebSearch tools \u2014 EXCEPT opinion questions about recent, niche, or living subjects (see OPINION QUESTION RULES), which include the enabled *WebSearch tool for grounding
2343
2369
  - coding help: exclude the *WebSearch tool unless user asks about a specific library/framework version`;
2344
2370
  var CLARIFICATION_RULES = `CLARIFICATION RULES
2345
2371
  If the user request is ambiguous, incomplete, or could refer to multiple
@@ -2630,7 +2656,8 @@ var VARIANT_SELECTION_RULES = `PROMPT SELECTION RULES
2630
2656
  - default for product: use when the user asks about a specific product they want to buy, compare prices, find where to buy something, or look up best deals.
2631
2657
  - default for shoplist: use for follow-up shopping questions about a product the conversation already covered with a full product overview \u2014 the user keeps asking about the same product (prices again, other shops, availability) and needs a compact purchase list, not another deep-dive.
2632
2658
  - coding: use for text when the user asks for code help or technical implementation.
2633
- - familiarity: use for text when the user asks whether you know or have heard of something (see FAMILIARITY QUESTION RULES).`;
2659
+ - familiarity: use for text when the user asks whether you know or have heard of something (see FAMILIARITY QUESTION RULES).
2660
+ - opinion: use for text when the user asks for YOUR personal judgment, take, opinion, or recommendation on a subject (see OPINION QUESTION RULES).`;
2634
2661
  var FAMILIARITY_QUESTION_RULES = `FAMILIARITY QUESTION RULES
2635
2662
  - Questions asking whether you know or have heard of something are familiarity questions only when the subject is public world knowledge and the user is not referring to their history with you (see MEMORY RULES).
2636
2663
  - Familiarity questions MUST use template "text" with prompt variant "familiarity" \u2014 NEVER "article", "news", or "evaluation". The user is opening a conversation about the subject, not commissioning a report.
@@ -2638,6 +2665,13 @@ var FAMILIARITY_QUESTION_RULES = `FAMILIARITY QUESTION RULES
2638
2665
  - Example: "kennst du dich mit NTE aus?" \u2192 template: "text", prompt: "familiarity", tools: [serperWebSearch]
2639
2666
  - Example: "have you heard of the new Dune movie?" \u2192 template: "text", prompt: "familiarity", tools: [serperWebSearch]
2640
2667
  - Example: "do you know the Pythagorean theorem?" \u2192 template: "text", prompt: "familiarity", tools: []`;
2668
+ var OPINION_QUESTION_RULES = `OPINION QUESTION RULES
2669
+ - Questions asking for YOUR personal judgment, take, opinion, or recommendation \u2014 "do you think X is any good?", "should I try X?", "would you recommend X?", "what's your take on X?", "is X worth it?" \u2014 are opinion questions: the user wants your conversational verdict, not a structured review document.
2670
+ - Opinion questions MUST use template "text" with prompt variant "opinion" \u2014 NEVER "article", "news", or "evaluation". The evaluation template renders an editorial review piece (headline, score panel, galleries) \u2014 that shape is only for explicit review commissions ("evaluate X", "write a review of X with pros and cons").
2671
+ - Include the enabled *WebSearch tool whenever the subject is niche, recent, a living topic, or a specific named entity \u2014 a grounded verdict needs the current reception and facts. This overrides the "personal opinion: exclude *WebSearch" line in TOPIC-BASED TOOL SELECTION for living subjects. Omit tools only for timeless, purely conceptual subjects.
2672
+ - Example: "do you think i should try aion 2?" \u2192 template: "text", prompt: "opinion", tools: [serperWebSearch]
2673
+ - Example: "would you recommend the new Dune movie to a casual viewer?" \u2192 template: "text", prompt: "opinion", tools: [serperWebSearch]
2674
+ - Example: "what do you think of stoicism?" (timeless concept) \u2192 template: "text", prompt: "opinion", tools: []`;
2641
2675
 
2642
2676
  // src/prompts/harness/intent-selection.prompt.ts
2643
2677
  function buildIntentSelectionPrompt(toolNames, language) {
@@ -2675,6 +2709,8 @@ ${MEMORY_RULES}
2675
2709
 
2676
2710
  ${FAMILIARITY_QUESTION_RULES}
2677
2711
 
2712
+ ${OPINION_QUESTION_RULES}
2713
+
2678
2714
  ${PRODUCT_TEMPLATE_RULES}
2679
2715
 
2680
2716
  ${SHOPLIST_TEMPLATE_RULES}
@@ -3749,11 +3785,19 @@ var ExtractionSchema = z.object({
3749
3785
  });
3750
3786
 
3751
3787
  // src/prompts/memory/vectorize-prompt.constant.ts
3752
- function buildExtractionPrompt(vocabulary = {}) {
3788
+ var USER_SOURCE_VOICE_RULES = `SOURCE VOICE: this extraction source is the USER's own message \u2014 statements in it are the user's voice and may be attributed to the user.`;
3789
+ var ASSISTANT_SOURCE_VOICE_RULES = `SOURCE VOICE (absolute): this extraction source is the ASSISTANT's own generated answer \u2014 a flattened digest of its titles, verdicts, and findings \u2014 NOT the user's words.
3790
+ - First-person statements, verdicts, scores, recommendations, and "my take" phrasing are the ASSISTANT's voice. NEVER attribute them to the user: no fact of the form "the user thinks / describes / wants / would / decided \u2026" may be drawn from this source.
3791
+ - The assistant's opinions, judgments, verdicts, and recommendations are NOT durable objective facts \u2014 never extract them. When the source only conveys the assistant's opinion, return an empty facts array (tags may still label the topic).
3792
+ - Extract only objective, checkable world facts the answer asserts, with the subject ENTITY as the hub \u2014 never "user" as the subject of assistant-voice content.
3793
+ - Statements about reception or coverage keep their true source ("available coverage of X notes \u2026"), never "the user";`;
3794
+ function buildExtractionPrompt(vocabulary = {}, role = "user") {
3795
+ const sourceVoiceRules = role === "assistant" ? ASSISTANT_SOURCE_VOICE_RULES : USER_SOURCE_VOICE_RULES;
3753
3796
  return buildStructuredPrompt(ExtractionSchema, {
3754
3797
  before: "OUTPUT FORMAT \u2014 output ONLY valid JSON matching this exact schema:",
3755
3798
  after: `
3756
3799
  YOUR TASK \u2014 decide what is worth remembering:
3800
+ ${sourceVoiceRules}
3757
3801
  - ROUTING BOUNDARY (absolute): this extraction feeds the memory partition \u2014 the OBJECTIVE fact store ONLY. Extract only objective, external-world facts and events: factual records, project details, decisions, states, possessions, contacts, relationships between people. You MUST NOT extract subjective user data \u2014 no preferences, likes/dislikes, interests, wants, behavioral traits, or internal states ("the user likes\u2026", "the user is interested in\u2026", "the user prefers\u2026"). All user profile and persona data is deferred to the cognition tier; when the turn reveals ONLY subjective user data, return an empty facts array.
3758
3802
  - A fact is durable, objective information that remains useful in a later, unrelated conversation: decisions, contact details, project facts, technical constraints, events (e.g. "Sam's phone number is 555-1234", "The user is building a vector memory feature", "The payments service migrated to PostgreSQL in November").
3759
3803
  - Be sensitive to the user's data: capture anything durable and objective the turn reveals \u2014 a decision, a constraint, a project detail, a person or subject they care about \u2014 even when it is phrased casually or buried in a longer message. Noticing and storing durable factual data is expected; do not wait for an explicit "remember".
@@ -3841,4 +3885,4 @@ Compose the response from the snippets below. Include every snippet you can subs
3841
3885
  ${parts.join("\n\n")}`;
3842
3886
  }
3843
3887
 
3844
- export { COMMONMARK_FORMAT, COMPARE_INSTRUCTIONS, COMPARE_VISUAL_INSTRUCTIONS, CONVICTION_INSTRUCTIONS, DEFAULT_VARIANT_ID, DESCRIBE_CONCISE_INSTRUCTIONS, DESCRIBE_DETAILED_INSTRUCTIONS, DESCRIBE_INSTRUCTIONS, ENCYCLOPEDIA_INGEST_TRIAGE_INSTRUCTIONS, FINAL_REMINDER, FRICTION_INSTRUCTIONS, HISTORY_URLS_RULES, IMAGELIST_INSTRUCTIONS, IMAGE_TASK_RULE, INTERNATIONAL_COVERAGE_INSTRUCTIONS, ITEM_SHAPES, JSON_RULES, MEDIA_COUNTS, MEDIA_RULES, MEMORY_CLUSTER_INSTRUCTIONS, MEMORY_CONSOLIDATE_INSTRUCTIONS, MEMORY_PROFILE_INSTRUCTIONS, MEMORY_WRITE_INSTRUCTIONS, MERGE_MEDIA_RULES, MERGE_TOPIC_RULE, MULTIMODAL_POLICY, NOISE_RULES, OCR_INSTRUCTIONS, OCR_VERBATIM_INSTRUCTIONS, PRECEDENCE_RULES, PRODUCT_INSTRUCTIONS, RESEARCH_FRICTION_QUERY_INSTRUCTIONS, RESEARCH_TRIAGE_INSTRUCTIONS, RESPONSE_LAYOUTS, SECURITY_RULES, SHOPLIST_INSTRUCTIONS, SNIPPET_TEMPLATE_PRESETS, SOURCE_TRUTH_RULES, SOURCE_VOICE_RULES, STOCKMARKET_ITEM_INSTRUCTIONS, STOCKMARKET_LIST_INSTRUCTIONS, SUMMARY_INSTRUCTIONS, TAXONOMY_RECONCILE_INSTRUCTIONS, TEMPLATE_VARIANTS, TEXT_CODING_INSTRUCTIONS, TEXT_FAMILIARITY_INSTRUCTIONS, TEXT_INSTRUCTIONS, TOOL_RESULTS_RULES, VIDEOLIST_INSTRUCTIONS, articlePreset, assessmentListsSnippet, authorMetaSnippet, bodyBriefSnippet, bodyExtensiveSnippet, buildBaseSystemPrompt, buildClarificationTranslationSystemPrompt, buildClarificationTranslationUserPrompt, buildClassifyTranscript, buildClusterSummaryPrompt, buildCognitionProfileSection, buildConsolidatePrompt, buildContentSystemPrompt, buildContextSummarySection, buildConvictionSynthesisPrompt, buildCorrectionPrompt, buildDescribePdfPagePrompt, buildEncyclopediaClassifyPrompt, buildEncyclopediaIngestTriagePrompt, buildEnrichPrompt, buildExecuteLanguageInstruction, buildExtractionCorrectionPrompt, buildExtractionPrompt, buildFrictionPrompt, buildImageExecutePrompt, buildIntentCorrectionPrompt, buildIntentSelectionPrompt, buildLanguageRule, buildLayoutInstruction, buildLocalizationRule, buildMemoryProbeSection, buildMemoryProfilePrompt, buildMemoryWritePrompt, buildMergeDirective, buildMissingToolsPrompt, buildOutputContract, buildResearchFrictionQueryPrompt, buildResearchTriagePrompt, buildSnippetInstruction, buildSourcePolicyPrompt, buildStockmarketNote, buildStructuredJsonPrompt, buildStructuredPrompt, buildSynopsisProbeSection, buildTaxonomyPairPrompt, buildTaxonomyReconcileSystemPrompt, buildToolExecutePrompt, buildVocabularySection, bylineDatelineSnippet, cardsSnippet, comparisonSchema, comparisonSnippet, composeSnippetKeys, composeSnippetSchema, conclusionSnippet, evaluationPreset, formatCurrentTimestamp, formatProvenanceLine, formatToolAvailabilityCatalog, formatVariantCatalog, gallerySnippet, getSnippetTemplateKeys, getSnippetTemplateSchema, headerArticleSnippet, headerNewsSnippet, heroMediaSnippet, internationalCoverageSnippet, introductionSnippet, isSnippetTemplate, keyFindingsSnippet, languageCorrectionPrompt, leadSnippet, mergePreset, mergedEvaluationsSnippet, newsKeyFindingsSnippet, newsPreset, quoteSnippet, reasoningSnippet, relatedStoriesSnippet, resolveLanguageName, resolveVariantInstructions, responseLayoutSchema, sourcesSnippet, subjectSchema, subjectsSnippet, summarySnippet, verdictSpineSnippet, videoGallerySnippet };
3888
+ export { COMMONMARK_FORMAT, COMPARE_INSTRUCTIONS, COMPARE_VISUAL_INSTRUCTIONS, CONVICTION_INSTRUCTIONS, DEFAULT_VARIANT_ID, DESCRIBE_CONCISE_INSTRUCTIONS, DESCRIBE_DETAILED_INSTRUCTIONS, DESCRIBE_INSTRUCTIONS, ENCYCLOPEDIA_INGEST_TRIAGE_INSTRUCTIONS, FINAL_REMINDER, FRICTION_INSTRUCTIONS, HISTORY_URLS_RULES, IMAGELIST_INSTRUCTIONS, IMAGE_TASK_RULE, INTERNATIONAL_COVERAGE_INSTRUCTIONS, ITEM_SHAPES, JSON_RULES, MEDIA_COUNTS, MEDIA_RULES, MEMORY_CLUSTER_INSTRUCTIONS, MEMORY_CONSOLIDATE_INSTRUCTIONS, MEMORY_PROFILE_INSTRUCTIONS, MEMORY_WRITE_INSTRUCTIONS, MERGE_MEDIA_RULES, MERGE_TOPIC_RULE, MULTIMODAL_POLICY, NOISE_RULES, OCR_INSTRUCTIONS, OCR_VERBATIM_INSTRUCTIONS, PRECEDENCE_RULES, PRODUCT_INSTRUCTIONS, RESEARCH_FRICTION_QUERY_INSTRUCTIONS, RESEARCH_TRIAGE_INSTRUCTIONS, RESPONSE_LAYOUTS, SECURITY_RULES, SHOPLIST_INSTRUCTIONS, SNIPPET_TEMPLATE_PRESETS, SOURCE_TRUTH_RULES, SOURCE_VOICE_RULES, STOCKMARKET_ITEM_INSTRUCTIONS, STOCKMARKET_LIST_INSTRUCTIONS, SUMMARY_INSTRUCTIONS, TAXONOMY_RECONCILE_INSTRUCTIONS, TEMPLATE_VARIANTS, TEXT_CODING_INSTRUCTIONS, TEXT_FAMILIARITY_INSTRUCTIONS, TEXT_INSTRUCTIONS, TEXT_OPINION_INSTRUCTIONS, TOOL_RESULTS_RULES, VIDEOLIST_INSTRUCTIONS, articlePreset, assessmentListsSnippet, authorMetaSnippet, bodyBriefSnippet, bodyExtensiveSnippet, buildBaseSystemPrompt, buildClarificationTranslationSystemPrompt, buildClarificationTranslationUserPrompt, buildClassifyTranscript, buildClusterSummaryPrompt, buildCognitionProfileSection, buildConsolidatePrompt, buildContentSystemPrompt, buildContextSummarySection, buildConvictionSynthesisPrompt, buildCorrectionPrompt, buildDescribePdfPagePrompt, buildEncyclopediaClassifyPrompt, buildEncyclopediaIngestTriagePrompt, buildEnrichPrompt, buildExecuteLanguageInstruction, buildExtractionCorrectionPrompt, buildExtractionPrompt, buildFrictionPrompt, buildImageExecutePrompt, buildIntentCorrectionPrompt, buildIntentSelectionPrompt, buildLanguageRule, buildLayoutInstruction, buildLocalizationRule, buildMemoryProbeSection, buildMemoryProfilePrompt, buildMemoryWritePrompt, buildMergeDirective, buildMissingToolsPrompt, buildOutputContract, buildResearchFrictionQueryPrompt, buildResearchTriagePrompt, buildSnippetInstruction, buildSourcePolicyPrompt, buildStockmarketNote, buildStructuredJsonPrompt, buildStructuredPrompt, buildSynopsisProbeSection, buildTaxonomyPairPrompt, buildTaxonomyReconcileSystemPrompt, buildToolExecutePrompt, buildVocabularySection, bylineDatelineSnippet, cardsSnippet, comparisonSchema, comparisonSnippet, composeSnippetKeys, composeSnippetSchema, conclusionSnippet, evaluationPreset, formatCurrentTimestamp, formatProvenanceLine, formatToolAvailabilityCatalog, formatVariantCatalog, gallerySnippet, getSnippetTemplateKeys, getSnippetTemplateSchema, headerArticleSnippet, headerNewsSnippet, heroMediaSnippet, internationalCoverageSnippet, introductionSnippet, isSnippetTemplate, keyFindingsSnippet, languageCorrectionPrompt, leadSnippet, mergePreset, mergedEvaluationsSnippet, newsKeyFindingsSnippet, newsPreset, quoteSnippet, reasoningSnippet, relatedStoriesSnippet, resolveLanguageName, resolveVariantInstructions, responseLayoutSchema, sourcesSnippet, subjectSchema, subjectsSnippet, summarySnippet, verdictSpineSnippet, videoGallerySnippet };