@telemai/sdk 0.2.3 → 0.2.4

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/index.cjs CHANGED
@@ -59,7 +59,7 @@ var TimeoutError = class extends TelemError {
59
59
  };
60
60
 
61
61
  // src/version.ts
62
- var VERSION = "0.2.3";
62
+ var VERSION = "0.2.4";
63
63
 
64
64
  // src/config.ts
65
65
  var DEFAULT_BASE_URL = "https://router.telem.ai";
@@ -599,8 +599,13 @@ function searchBlock(defaults, options) {
599
599
  if (maxRoutingProviders !== void 0) block.max_routing_providers = maxRoutingProviders;
600
600
  const topic = options.topic ?? defaults.topic;
601
601
  if (topic !== void 0) block.topic = topic;
602
+ if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
603
+ if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
602
604
  return block;
603
605
  }
606
+ function isoDate(value) {
607
+ return typeof value === "string" ? value : value.toISOString();
608
+ }
604
609
  function userInput(query) {
605
610
  if (typeof query === "string") {
606
611
  if (query === "") throw invalidRequest("search() requires a non-empty query");
package/dist/index.d.cts CHANGED
@@ -64,6 +64,14 @@ type SearchOptions = {
64
64
  autoRouting?: string;
65
65
  maxRoutingProviders?: number;
66
66
  topic?: string;
67
+ /** Only results published on or after this date or date-time: an ISO 8601 string
68
+ * (no time zone means UTC) or a `Date`. Results with no known date are kept.
69
+ * Per-call only, like the two below. */
70
+ publishedAfter?: string | Date;
71
+ /** Only results published before this date or date-time. A date with no time
72
+ * includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
73
+ * string to include the whole day. */
74
+ publishedBefore?: string | Date;
67
75
  /** Opt this request into the server's rerank stage. It is the only path where
68
76
  * `context`, the reasoning on the last assistant entry of the lineage history
69
77
  * (that entry only), and `goal` change result ORDER (in that precedence) —
package/dist/index.d.ts CHANGED
@@ -64,6 +64,14 @@ type SearchOptions = {
64
64
  autoRouting?: string;
65
65
  maxRoutingProviders?: number;
66
66
  topic?: string;
67
+ /** Only results published on or after this date or date-time: an ISO 8601 string
68
+ * (no time zone means UTC) or a `Date`. Results with no known date are kept.
69
+ * Per-call only, like the two below. */
70
+ publishedAfter?: string | Date;
71
+ /** Only results published before this date or date-time. A date with no time
72
+ * includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
73
+ * string to include the whole day. */
74
+ publishedBefore?: string | Date;
67
75
  /** Opt this request into the server's rerank stage. It is the only path where
68
76
  * `context`, the reasoning on the last assistant entry of the lineage history
69
77
  * (that entry only), and `goal` change result ORDER (in that precedence) —
package/dist/index.js CHANGED
@@ -22,7 +22,7 @@ import {
22
22
  } from "./chunk-RYY4S5LP.js";
23
23
 
24
24
  // src/version.ts
25
- var VERSION = "0.2.3";
25
+ var VERSION = "0.2.4";
26
26
 
27
27
  // src/config.ts
28
28
  var DEFAULT_BASE_URL = "https://router.telem.ai";
@@ -234,8 +234,13 @@ function searchBlock(defaults, options) {
234
234
  if (maxRoutingProviders !== void 0) block.max_routing_providers = maxRoutingProviders;
235
235
  const topic = options.topic ?? defaults.topic;
236
236
  if (topic !== void 0) block.topic = topic;
237
+ if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
238
+ if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
237
239
  return block;
238
240
  }
241
+ function isoDate(value) {
242
+ return typeof value === "string" ? value : value.toISOString();
243
+ }
239
244
  function userInput(query) {
240
245
  if (typeof query === "string") {
241
246
  if (query === "") throw invalidRequest("search() requires a non-empty query");
@@ -452,7 +452,10 @@ async function turnAnchor(messages, windowId) {
452
452
  return await contentAnchor(String(messages.length), windowId, text);
453
453
  }
454
454
  function compact(response) {
455
- return response.results.slice(0, RESULT_CAP).map(({ provider, title, url, summary }) => ({ provider, title, url, summary }));
455
+ return response.results.slice(0, RESULT_CAP).map(({ provider, title, url, summary, publishDate }) => {
456
+ const published = publishDate?.trim();
457
+ return published ? { provider, title, url, summary, published } : { provider, title, url, summary };
458
+ });
456
459
  }
457
460
  function page(response) {
458
461
  const first = response.results[0];
@@ -477,6 +480,14 @@ var SEARCH_SCHEMA = (0, import_ai.jsonSchema)({
477
480
  topic: {
478
481
  type: "string",
479
482
  description: "Optional. Set it only when the answer must come from one site: linkedin, reddit, or x (twitter is also accepted). Leave it unset otherwise."
483
+ },
484
+ published_after: {
485
+ type: "string",
486
+ description: "Optional. Only return results published on or after this date or date-time, in ISO 8601 (for example 2026-10-01 or 2026-10-01T09:00:00Z). A value with no time zone is read as UTC. Results with no known publication date are kept. Set it only when the task needs sources from a time period; leave it unset otherwise."
487
+ },
488
+ published_before: {
489
+ type: "string",
490
+ description: "Optional. Only return results published before this date or date-time, in ISO 8601. A value with no time zone is read as UTC, and a date with no time includes that whole day. Results with no known publication date are kept. Set it only when the task needs sources from a time period; leave it unset otherwise."
480
491
  }
481
492
  },
482
493
  required: ["query"],
@@ -567,7 +578,14 @@ function createTelemVercelAgent(options) {
567
578
  const opts = { ...searchOptions ?? {}, signal: signalFor(execution, searchOptions?.signal) };
568
579
  const { envelope, plan } = await lineage(execution, {
569
580
  name: SEARCH_TOOL,
570
- input: { query, goal: opts.goal, context: opts.context, topic: opts.topic }
581
+ input: {
582
+ query,
583
+ goal: opts.goal,
584
+ context: opts.context,
585
+ topic: opts.topic,
586
+ published_after: opts.publishedAfter,
587
+ published_before: opts.publishedBefore
588
+ }
571
589
  });
572
590
  const response = await state.sendWithOmissionRetry(
573
591
  plan,
@@ -624,12 +642,18 @@ function createTelemVercelAgent(options) {
624
642
  }
625
643
  const tools = {
626
644
  telem_search: {
627
- description: "Search the public web. One query per call; returns the top results with provider, title, url and summary. Use telem_fetch to read a page in full.",
645
+ description: "Search the public web. One query per call; returns the top results with provider, title, url, summary and, when known, publication date. Use telem_fetch to read a page in full.",
628
646
  inputSchema: SEARCH_SCHEMA,
629
647
  execute: async (input, execution) => {
630
648
  const topic = input.topic?.trim() || void 0;
649
+ const publishedAfter = input.published_after?.trim() || void 0;
650
+ const publishedBefore = input.published_before?.trim() || void 0;
631
651
  return renderSearch(
632
- await search(input.query, { goal: input.goal, context: input.context, topic }, execution)
652
+ await search(
653
+ input.query,
654
+ { goal: input.goal, context: input.context, topic, publishedAfter, publishedBefore },
655
+ execution
656
+ )
633
657
  );
634
658
  }
635
659
  },
@@ -142,17 +142,21 @@ type TelemVercelSearchInput = {
142
142
  goal?: string;
143
143
  context?: string;
144
144
  topic?: string;
145
+ published_after?: string;
146
+ published_before?: string;
145
147
  };
146
148
  type TelemVercelFetchInput = {
147
149
  url: string;
148
150
  goal?: string;
149
151
  };
150
- /** The default `render.search`: the top results, compact. */
152
+ /** The default `render.search`: the top results, compact. `published` is there only
153
+ * when the result has a publication date. */
151
154
  type TelemVercelSearchOutput = Array<{
152
155
  provider: string;
153
156
  title: string;
154
157
  url: string;
155
158
  summary: string | null;
159
+ published?: string;
156
160
  }>;
157
161
  /** The default `render.fetch`: one page's status, error and text. */
158
162
  type TelemVercelFetchOutput = {
@@ -142,17 +142,21 @@ type TelemVercelSearchInput = {
142
142
  goal?: string;
143
143
  context?: string;
144
144
  topic?: string;
145
+ published_after?: string;
146
+ published_before?: string;
145
147
  };
146
148
  type TelemVercelFetchInput = {
147
149
  url: string;
148
150
  goal?: string;
149
151
  };
150
- /** The default `render.search`: the top results, compact. */
152
+ /** The default `render.search`: the top results, compact. `published` is there only
153
+ * when the result has a publication date. */
151
154
  type TelemVercelSearchOutput = Array<{
152
155
  provider: string;
153
156
  title: string;
154
157
  url: string;
155
158
  summary: string | null;
159
+ published?: string;
156
160
  }>;
157
161
  /** The default `render.fetch`: one page's status, error and text. */
158
162
  type TelemVercelFetchOutput = {
@@ -290,7 +290,10 @@ async function turnAnchor(messages, windowId) {
290
290
  return await contentAnchor(String(messages.length), windowId, text);
291
291
  }
292
292
  function compact(response) {
293
- return response.results.slice(0, RESULT_CAP).map(({ provider, title, url, summary }) => ({ provider, title, url, summary }));
293
+ return response.results.slice(0, RESULT_CAP).map(({ provider, title, url, summary, publishDate }) => {
294
+ const published = publishDate?.trim();
295
+ return published ? { provider, title, url, summary, published } : { provider, title, url, summary };
296
+ });
294
297
  }
295
298
  function page(response) {
296
299
  const first = response.results[0];
@@ -315,6 +318,14 @@ var SEARCH_SCHEMA = jsonSchema({
315
318
  topic: {
316
319
  type: "string",
317
320
  description: "Optional. Set it only when the answer must come from one site: linkedin, reddit, or x (twitter is also accepted). Leave it unset otherwise."
321
+ },
322
+ published_after: {
323
+ type: "string",
324
+ description: "Optional. Only return results published on or after this date or date-time, in ISO 8601 (for example 2026-10-01 or 2026-10-01T09:00:00Z). A value with no time zone is read as UTC. Results with no known publication date are kept. Set it only when the task needs sources from a time period; leave it unset otherwise."
325
+ },
326
+ published_before: {
327
+ type: "string",
328
+ description: "Optional. Only return results published before this date or date-time, in ISO 8601. A value with no time zone is read as UTC, and a date with no time includes that whole day. Results with no known publication date are kept. Set it only when the task needs sources from a time period; leave it unset otherwise."
318
329
  }
319
330
  },
320
331
  required: ["query"],
@@ -405,7 +416,14 @@ function createTelemVercelAgent(options) {
405
416
  const opts = { ...searchOptions ?? {}, signal: signalFor(execution, searchOptions?.signal) };
406
417
  const { envelope, plan } = await lineage(execution, {
407
418
  name: SEARCH_TOOL,
408
- input: { query, goal: opts.goal, context: opts.context, topic: opts.topic }
419
+ input: {
420
+ query,
421
+ goal: opts.goal,
422
+ context: opts.context,
423
+ topic: opts.topic,
424
+ published_after: opts.publishedAfter,
425
+ published_before: opts.publishedBefore
426
+ }
409
427
  });
410
428
  const response = await state.sendWithOmissionRetry(
411
429
  plan,
@@ -462,12 +480,18 @@ function createTelemVercelAgent(options) {
462
480
  }
463
481
  const tools = {
464
482
  telem_search: {
465
- description: "Search the public web. One query per call; returns the top results with provider, title, url and summary. Use telem_fetch to read a page in full.",
483
+ description: "Search the public web. One query per call; returns the top results with provider, title, url, summary and, when known, publication date. Use telem_fetch to read a page in full.",
466
484
  inputSchema: SEARCH_SCHEMA,
467
485
  execute: async (input, execution) => {
468
486
  const topic = input.topic?.trim() || void 0;
487
+ const publishedAfter = input.published_after?.trim() || void 0;
488
+ const publishedBefore = input.published_before?.trim() || void 0;
469
489
  return renderSearch(
470
- await search(input.query, { goal: input.goal, context: input.context, topic }, execution)
490
+ await search(
491
+ input.query,
492
+ { goal: input.goal, context: input.context, topic, publishedAfter, publishedBefore },
493
+ execution
494
+ )
471
495
  );
472
496
  }
473
497
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telemai/sdk",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Telem web search and fetch for JavaScript and TypeScript.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",