@telemai/sdk 0.3.0 → 0.3.2
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/README.md +1 -1
- package/dist/index.cjs +13 -4
- package/dist/index.d.cts +18 -3
- package/dist/index.d.ts +18 -3
- package/dist/index.js +13 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -204,7 +204,7 @@ A monitor runs a query on a schedule. Poll it to get the results that are new si
|
|
|
204
204
|
your last poll. `poll` returns a `SearchResponse`:
|
|
205
205
|
|
|
206
206
|
```ts
|
|
207
|
-
const monitor = await telem.monitors.create("Nvidia files a new 8-K with the SEC", { frequency: "1h" })
|
|
207
|
+
const monitor = await telem.monitors.create("Nvidia files a new 8-K with the SEC", { frequency: "1h", ttl: "7d" })
|
|
208
208
|
const response = await telem.monitors.poll(monitor.id)
|
|
209
209
|
await telem.monitors.update(monitor.id, { status: "paused" })
|
|
210
210
|
await telem.monitors.delete(monitor.id)
|
package/dist/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ var TimeoutError = class extends TelemError {
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
// src/version.ts
|
|
63
|
-
var VERSION = "0.3.
|
|
63
|
+
var VERSION = "0.3.2";
|
|
64
64
|
|
|
65
65
|
// src/config.ts
|
|
66
66
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -588,6 +588,7 @@ function searchBlock(defaults, options) {
|
|
|
588
588
|
if (topic !== void 0) block.topic = topic;
|
|
589
589
|
if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
|
|
590
590
|
if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
|
|
591
|
+
if (options.includeDomains !== void 0) block.include_domains = options.includeDomains;
|
|
591
592
|
return block;
|
|
592
593
|
}
|
|
593
594
|
function isoDate(value) {
|
|
@@ -707,6 +708,7 @@ function monitorFrom(body) {
|
|
|
707
708
|
sessionId: String(data.session_id ?? ""),
|
|
708
709
|
createdAt: data.created_at ?? "",
|
|
709
710
|
lastPolledAt: data.last_polled_at ?? null,
|
|
711
|
+
expiresAt: data.expires_at ?? null,
|
|
710
712
|
webhookUrl: data.webhook_url ?? null,
|
|
711
713
|
webhookSecret: data.webhook_secret ?? null,
|
|
712
714
|
raw: data
|
|
@@ -719,10 +721,17 @@ function createMonitors(config) {
|
|
|
719
721
|
};
|
|
720
722
|
return {
|
|
721
723
|
/** Create a monitor. Telem runs `query` on the schedule. */
|
|
722
|
-
async create(query, options) {
|
|
723
|
-
const
|
|
724
|
+
async create(query, options = {}) {
|
|
725
|
+
const monitorOptions = {};
|
|
726
|
+
if (options.frequency !== void 0) monitorOptions.frequency = options.frequency;
|
|
727
|
+
if (options.includeDomains !== void 0) {
|
|
728
|
+
monitorOptions.include_domains = options.includeDomains;
|
|
729
|
+
}
|
|
730
|
+
if (options.search !== void 0) monitorOptions.search = searchBlock({}, options.search);
|
|
731
|
+
const body = { query, options: monitorOptions };
|
|
724
732
|
if (options.metadata !== void 0) body.metadata = options.metadata;
|
|
725
733
|
if (options.webhookUrl !== void 0) body.webhook_url = options.webhookUrl;
|
|
734
|
+
if (options.ttl !== void 0) body.ttl = options.ttl;
|
|
726
735
|
const data = await request(config, "POST", "/v1/monitors", body, options.signal, "rate_limit");
|
|
727
736
|
return monitorFrom(data);
|
|
728
737
|
},
|
|
@@ -745,7 +754,7 @@ function createMonitors(config) {
|
|
|
745
754
|
const route = path(monitorId);
|
|
746
755
|
return monitorFrom(await request(config, "PATCH", route, body, options.signal));
|
|
747
756
|
},
|
|
748
|
-
/** Get the results that are new since the last poll
|
|
757
|
+
/** Get the results that are new since the last poll. */
|
|
749
758
|
async poll(monitorId, options = {}) {
|
|
750
759
|
const body = {};
|
|
751
760
|
if (options.session !== void 0) body.session_id = options.session;
|
package/dist/index.d.cts
CHANGED
|
@@ -72,6 +72,9 @@ type SearchOptions = {
|
|
|
72
72
|
* includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
|
|
73
73
|
* string to include the whole day. */
|
|
74
74
|
publishedBefore?: string | Date;
|
|
75
|
+
/** Only results from these domains: at most 20 hostnames such as `"linkedin.com"`.
|
|
76
|
+
* A subdomain such as `"uk.linkedin.com"` matches its domain. Per-call only. */
|
|
77
|
+
includeDomains?: string[];
|
|
75
78
|
/** Opt this request into the server's rerank stage. It is the only path where
|
|
76
79
|
* `context`, the reasoning on the last assistant entry of the lineage history
|
|
77
80
|
* (that entry only), and `goal` change result ORDER (in that precedence) —
|
|
@@ -222,14 +225,24 @@ type SessionsResource = {
|
|
|
222
225
|
list(): Promise<SessionSummary[]>;
|
|
223
226
|
results(sessionId: string): Promise<SessionResults>;
|
|
224
227
|
};
|
|
228
|
+
/** The search options a monitor can run on its schedule (`MonitorCreateOptions.search`). */
|
|
229
|
+
type MonitorSearchOptions = Pick<SearchOptions, "tier" | "numResults">;
|
|
225
230
|
/** Options for `monitors.create`. */
|
|
226
231
|
type MonitorCreateOptions = {
|
|
227
|
-
/** `"1h"`, `"6h"`, `"1d"` or `"7d"`. */
|
|
228
|
-
frequency
|
|
232
|
+
/** `"1h"`, `"6h"`, `"12h"`, `"1d"` or `"7d"`. If you leave it out, the monitor runs once a day. */
|
|
233
|
+
frequency?: string;
|
|
234
|
+
/** Also run a web search for the query on the schedule, with these options. `{}`
|
|
235
|
+
* uses the defaults. Client search defaults do not apply. */
|
|
236
|
+
search?: MonitorSearchOptions;
|
|
237
|
+
/** Only results from these sites and their subdomains, such as `["sec.gov"]`,
|
|
238
|
+
* from every source of the monitor. */
|
|
239
|
+
includeDomains?: string[];
|
|
229
240
|
/** Request metadata (query lineage keys), sent as given. */
|
|
230
241
|
metadata?: Json;
|
|
231
242
|
/** An `https` URL that receives the new results. */
|
|
232
243
|
webhookUrl?: string;
|
|
244
|
+
/** Delete the monitor after this long, such as `"12h"` or `"7d"` (at most `"30d"`). Without it, the monitor never expires. */
|
|
245
|
+
ttl?: string;
|
|
233
246
|
signal?: AbortSignal;
|
|
234
247
|
};
|
|
235
248
|
/** Options for `monitors.update`. Send at least one field. */
|
|
@@ -259,6 +272,8 @@ type Monitor = {
|
|
|
259
272
|
sessionId: string;
|
|
260
273
|
createdAt: string;
|
|
261
274
|
lastPolledAt: string | null;
|
|
275
|
+
/** When Telem deletes the monitor; `null`: never. */
|
|
276
|
+
expiresAt: string | null;
|
|
262
277
|
webhookUrl: string | null;
|
|
263
278
|
/** Signs the webhook deliveries. Only in the response that set `webhookUrl`. */
|
|
264
279
|
webhookSecret: string | null;
|
|
@@ -266,7 +281,7 @@ type Monitor = {
|
|
|
266
281
|
};
|
|
267
282
|
/** The `telem.monitors` namespace. */
|
|
268
283
|
type MonitorsResource = {
|
|
269
|
-
create(query: string, options
|
|
284
|
+
create(query: string, options?: MonitorCreateOptions): Promise<Monitor>;
|
|
270
285
|
list(options?: {
|
|
271
286
|
limit?: number;
|
|
272
287
|
signal?: AbortSignal;
|
package/dist/index.d.ts
CHANGED
|
@@ -72,6 +72,9 @@ type SearchOptions = {
|
|
|
72
72
|
* includes that whole day. A `Date` is an exact instant; pass a "YYYY-MM-DD"
|
|
73
73
|
* string to include the whole day. */
|
|
74
74
|
publishedBefore?: string | Date;
|
|
75
|
+
/** Only results from these domains: at most 20 hostnames such as `"linkedin.com"`.
|
|
76
|
+
* A subdomain such as `"uk.linkedin.com"` matches its domain. Per-call only. */
|
|
77
|
+
includeDomains?: string[];
|
|
75
78
|
/** Opt this request into the server's rerank stage. It is the only path where
|
|
76
79
|
* `context`, the reasoning on the last assistant entry of the lineage history
|
|
77
80
|
* (that entry only), and `goal` change result ORDER (in that precedence) —
|
|
@@ -222,14 +225,24 @@ type SessionsResource = {
|
|
|
222
225
|
list(): Promise<SessionSummary[]>;
|
|
223
226
|
results(sessionId: string): Promise<SessionResults>;
|
|
224
227
|
};
|
|
228
|
+
/** The search options a monitor can run on its schedule (`MonitorCreateOptions.search`). */
|
|
229
|
+
type MonitorSearchOptions = Pick<SearchOptions, "tier" | "numResults">;
|
|
225
230
|
/** Options for `monitors.create`. */
|
|
226
231
|
type MonitorCreateOptions = {
|
|
227
|
-
/** `"1h"`, `"6h"`, `"1d"` or `"7d"`. */
|
|
228
|
-
frequency
|
|
232
|
+
/** `"1h"`, `"6h"`, `"12h"`, `"1d"` or `"7d"`. If you leave it out, the monitor runs once a day. */
|
|
233
|
+
frequency?: string;
|
|
234
|
+
/** Also run a web search for the query on the schedule, with these options. `{}`
|
|
235
|
+
* uses the defaults. Client search defaults do not apply. */
|
|
236
|
+
search?: MonitorSearchOptions;
|
|
237
|
+
/** Only results from these sites and their subdomains, such as `["sec.gov"]`,
|
|
238
|
+
* from every source of the monitor. */
|
|
239
|
+
includeDomains?: string[];
|
|
229
240
|
/** Request metadata (query lineage keys), sent as given. */
|
|
230
241
|
metadata?: Json;
|
|
231
242
|
/** An `https` URL that receives the new results. */
|
|
232
243
|
webhookUrl?: string;
|
|
244
|
+
/** Delete the monitor after this long, such as `"12h"` or `"7d"` (at most `"30d"`). Without it, the monitor never expires. */
|
|
245
|
+
ttl?: string;
|
|
233
246
|
signal?: AbortSignal;
|
|
234
247
|
};
|
|
235
248
|
/** Options for `monitors.update`. Send at least one field. */
|
|
@@ -259,6 +272,8 @@ type Monitor = {
|
|
|
259
272
|
sessionId: string;
|
|
260
273
|
createdAt: string;
|
|
261
274
|
lastPolledAt: string | null;
|
|
275
|
+
/** When Telem deletes the monitor; `null`: never. */
|
|
276
|
+
expiresAt: string | null;
|
|
262
277
|
webhookUrl: string | null;
|
|
263
278
|
/** Signs the webhook deliveries. Only in the response that set `webhookUrl`. */
|
|
264
279
|
webhookSecret: string | null;
|
|
@@ -266,7 +281,7 @@ type Monitor = {
|
|
|
266
281
|
};
|
|
267
282
|
/** The `telem.monitors` namespace. */
|
|
268
283
|
type MonitorsResource = {
|
|
269
|
-
create(query: string, options
|
|
284
|
+
create(query: string, options?: MonitorCreateOptions): Promise<Monitor>;
|
|
270
285
|
list(options?: {
|
|
271
286
|
limit?: number;
|
|
272
287
|
signal?: AbortSignal;
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from "./chunk-DKTEG7EY.js";
|
|
23
23
|
|
|
24
24
|
// src/version.ts
|
|
25
|
-
var VERSION = "0.3.
|
|
25
|
+
var VERSION = "0.3.2";
|
|
26
26
|
|
|
27
27
|
// src/config.ts
|
|
28
28
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -221,6 +221,7 @@ function searchBlock(defaults, options) {
|
|
|
221
221
|
if (topic !== void 0) block.topic = topic;
|
|
222
222
|
if (options.publishedAfter !== void 0) block.published_after = isoDate(options.publishedAfter);
|
|
223
223
|
if (options.publishedBefore !== void 0) block.published_before = isoDate(options.publishedBefore);
|
|
224
|
+
if (options.includeDomains !== void 0) block.include_domains = options.includeDomains;
|
|
224
225
|
return block;
|
|
225
226
|
}
|
|
226
227
|
function isoDate(value) {
|
|
@@ -340,6 +341,7 @@ function monitorFrom(body) {
|
|
|
340
341
|
sessionId: String(data.session_id ?? ""),
|
|
341
342
|
createdAt: data.created_at ?? "",
|
|
342
343
|
lastPolledAt: data.last_polled_at ?? null,
|
|
344
|
+
expiresAt: data.expires_at ?? null,
|
|
343
345
|
webhookUrl: data.webhook_url ?? null,
|
|
344
346
|
webhookSecret: data.webhook_secret ?? null,
|
|
345
347
|
raw: data
|
|
@@ -352,10 +354,17 @@ function createMonitors(config) {
|
|
|
352
354
|
};
|
|
353
355
|
return {
|
|
354
356
|
/** Create a monitor. Telem runs `query` on the schedule. */
|
|
355
|
-
async create(query, options) {
|
|
356
|
-
const
|
|
357
|
+
async create(query, options = {}) {
|
|
358
|
+
const monitorOptions = {};
|
|
359
|
+
if (options.frequency !== void 0) monitorOptions.frequency = options.frequency;
|
|
360
|
+
if (options.includeDomains !== void 0) {
|
|
361
|
+
monitorOptions.include_domains = options.includeDomains;
|
|
362
|
+
}
|
|
363
|
+
if (options.search !== void 0) monitorOptions.search = searchBlock({}, options.search);
|
|
364
|
+
const body = { query, options: monitorOptions };
|
|
357
365
|
if (options.metadata !== void 0) body.metadata = options.metadata;
|
|
358
366
|
if (options.webhookUrl !== void 0) body.webhook_url = options.webhookUrl;
|
|
367
|
+
if (options.ttl !== void 0) body.ttl = options.ttl;
|
|
359
368
|
const data = await request(config, "POST", "/v1/monitors", body, options.signal, "rate_limit");
|
|
360
369
|
return monitorFrom(data);
|
|
361
370
|
},
|
|
@@ -378,7 +387,7 @@ function createMonitors(config) {
|
|
|
378
387
|
const route = path(monitorId);
|
|
379
388
|
return monitorFrom(await request(config, "PATCH", route, body, options.signal));
|
|
380
389
|
},
|
|
381
|
-
/** Get the results that are new since the last poll
|
|
390
|
+
/** Get the results that are new since the last poll. */
|
|
382
391
|
async poll(monitorId, options = {}) {
|
|
383
392
|
const body = {};
|
|
384
393
|
if (options.session !== void 0) body.session_id = options.session;
|