@telemai/sdk 0.5.0 → 0.6.0

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.d.cts CHANGED
@@ -64,6 +64,7 @@ type SearchOptions = {
64
64
  autoRouting?: string;
65
65
  maxRoutingProviders?: number;
66
66
  topic?: string;
67
+ vertical?: string;
67
68
  /** Only results published on or after this date or date-time: an ISO 8601 string
68
69
  * (no time zone means UTC) or a `Date`. Results with no known date are kept.
69
70
  * Per-call only, like the two below. */
@@ -94,7 +95,7 @@ type SearchOptions = {
94
95
  };
95
96
  /** The subset of search options that may also be set as a client default.
96
97
  * `numResults`/`includeRaw`/`rerank`/`providerOverrides` are per-call intent only. */
97
- type SearchDefaults = Pick<SearchOptions, "tier" | "fields" | "providersInclude" | "providersExclude" | "includeFullContent" | "autoRouting" | "maxRoutingProviders" | "topic">;
98
+ type SearchDefaults = Pick<SearchOptions, "tier" | "fields" | "providersInclude" | "providersExclude" | "includeFullContent" | "autoRouting" | "maxRoutingProviders" | "topic" | "vertical">;
98
99
  type FetchOptions = {
99
100
  /** Fetch provider chain, in order. Defaults to `TELEM_FETCH_PROVIDERS`. */
100
101
  providers?: string[];
@@ -114,9 +115,12 @@ type FetchOptions = {
114
115
  metadata?: Json;
115
116
  };
116
117
  type TelemOptions = SearchDefaults & {
118
+ defaultVertical?: string;
117
119
  apiKey?: string;
118
120
  baseUrl?: string;
119
121
  timeoutMs?: number;
122
+ /** Retries after the first attempt: 2 by default. `monitors.create` retries for up
123
+ * to about 120 s instead, at most 60 times. A value you pass caps both. */
120
124
  maxRetries?: number;
121
125
  /** Injectable transport — embedded runtimes, edge workers, and tests. */
122
126
  fetch?: typeof globalThis.fetch;
@@ -253,8 +257,37 @@ type MonitorCreateCommonOptions = {
253
257
  metadata?: Json;
254
258
  /** An `https` URL that receives the new results. */
255
259
  webhookUrl?: string;
260
+ /** Labels of your own, to list the monitor by with `list({ tag })`: at most 10. Telem
261
+ * strips and lower-cases each one, which must then be 1 to 32 of `a-z`, `0-9`, `-` and
262
+ * `_`, starting with a letter or digit, and drops repeats. Anything else is a 422. */
263
+ tags?: string[];
264
+ /** The `Idempotency-Key` header, 1 to 255 visible ASCII characters. By default each
265
+ * call makes a new one. Pass your own to retry a create across a restart. */
266
+ idempotencyKey?: string;
256
267
  signal?: AbortSignal;
257
268
  };
269
+ /** What a monitor of a list of companies collects: the `inputs` of `monitors.create`.
270
+ * Sent as given, with the router's own field names, and checked by the router. */
271
+ type MonitorInputs = {
272
+ /** The companies, 1 to 20: rows of `company_id`, `name` and `domain`. */
273
+ companies: Json[];
274
+ /** People to watch: rows of `person_id`, `name`, `company_id` and `company`. */
275
+ roster?: Json[];
276
+ /** What to collect: the preset `"biopharma-v0"`, or a schema object. */
277
+ schema?: string | Json;
278
+ /** Items to watch from the start: rows of `entity_id`, `kind` and `name`. */
279
+ entities?: Json[];
280
+ /** Kinds of event to collect: rows with a `label`. */
281
+ categories?: Json[];
282
+ /** `"propose"`: people found on company pages are proposed, for you to confirm.
283
+ * `"auto"`: they are watched at once. */
284
+ discover?: string;
285
+ /** How many days back the first read of each company looks. */
286
+ window_days?: number;
287
+ /** Look each company up before its first read, to find its other names and pages. */
288
+ seed?: boolean;
289
+ vertical?: string;
290
+ };
258
291
  /** Options for `monitors.create`. A monitor has the agent unless `agent` is `false`,
259
292
  * and a monitor with the agent must end: then `ttl` is required. */
260
293
  type MonitorCreateOptions = MonitorCreateCommonOptions & ({
@@ -269,10 +302,21 @@ type MonitorCreateOptions = MonitorCreateCommonOptions & ({
269
302
  * against the query and keeps the ones that match. Read what it keeps with
270
303
  * `monitors.iterateChanges` or `monitors.changes`. */
271
304
  agent?: true;
272
- /** End the monitor after this long, such as `"7d"` or `"30d"` (at most `"30d"`).
273
- * Required with the agent. */
305
+ /** End the monitor after this long, such as `"7d"` or `"30d"` (at most `"30d"`, or
306
+ * `"365d"` with `inputs`). Required with the agent. */
274
307
  ttl: string;
308
+ /** Watch a list of companies: the companies, and the schema that says what to
309
+ * collect about them. Such a monitor has the agent. Read what the first read of
310
+ * each company found with `monitors.onboarding`. */
311
+ inputs?: MonitorInputs;
312
+ /** The fields every result has: `"article"` (`headline`, `publication`,
313
+ * `published_at`, `summary`, `kind`), `"person"`, `"company"` or `"listing"`. The
314
+ * agent keeps them as they are and may add more. Leave it out and the agent picks
315
+ * the fields from the query. Refused with `inputs`. */
316
+ preset?: MonitorPreset;
275
317
  });
318
+ /** The `preset` of `monitors.create`. */
319
+ type MonitorPreset = "article" | "person" | "company" | "listing";
276
320
  /** Options for `monitors.update`. Send at least one field. */
277
321
  type MonitorUpdateOptions = {
278
322
  /** `"paused"` or `"active"`. */
@@ -283,6 +327,9 @@ type MonitorUpdateOptions = {
283
327
  /** A new end, this long from now, such as `"30d"` (at most `"30d"`). It renews a monitor
284
328
  * before it ends; an ended monitor cannot be renewed. */
285
329
  ttl?: string;
330
+ /** The monitor's new tags, in place of all its tags (the rule of `create`). `[]`
331
+ * removes them all; leave it out to keep them. */
332
+ tags?: string[];
286
333
  signal?: AbortSignal;
287
334
  };
288
335
  /** Options for `monitors.poll`.
@@ -315,6 +362,8 @@ type Monitor = {
315
362
  /** Only in the answer to a create: why the monitor agent did not start, or not yet.
316
363
  * `null` when it started, and in every other answer. */
317
364
  agentNote: string | null;
365
+ /** Your labels for the monitor; empty when it has none. */
366
+ tags: string[];
318
367
  raw: Json;
319
368
  };
320
369
  /** The latest compile of an agent's plan (`AgentState.compile`). */
@@ -327,7 +376,7 @@ type AgentCompileState = {
327
376
  };
328
377
  /** The state of a monitor's agent: `monitor.agentState`. */
329
378
  type AgentState = {
330
- /** The agent engine, `"v4"` today. */
379
+ /** The agent engine: `"v4"`, or `"engine"` for a monitor created with `inputs`. */
331
380
  engine: string;
332
381
  /** Such as `compiling`, `ready`, `paused` or `failed`. */
333
382
  status: string;
@@ -414,6 +463,48 @@ type MonitorChangesOptions = {
414
463
  limit?: number;
415
464
  signal?: AbortSignal;
416
465
  };
466
+ /** The monitors of `monitors.changesAcross`: your key's own live monitors that carry
467
+ * `tag`, or the monitors of `ids`, one of the two. */
468
+ type MonitorChangesAcrossScope = {
469
+ /** Your key's own live monitors that carry this tag. One with no agent is in `skipped`. */
470
+ tag: string;
471
+ ids?: never;
472
+ } | {
473
+ /** These monitors, at most 100: any monitor with an agent in your key's project, ended
474
+ * ones too. One that is not is a 404 for the whole read. */
475
+ ids: string[];
476
+ tag?: never;
477
+ };
478
+ /** Options for `monitors.changesAcross` and `monitors.iterateChangesAcross`. */
479
+ type MonitorChangesAcrossOptions = {
480
+ /** The `nextCursor` of the page before. If you leave it out, the read starts at the
481
+ * first change. Do not send it with `since`. */
482
+ cursor?: string;
483
+ /** Read from this time on, as in `changes`. A monitor that joins later starts at the
484
+ * same time. Do not send it with `cursor`. */
485
+ since?: string | Date;
486
+ /** Only these kinds of change, as in `changes`. */
487
+ kinds?: string[];
488
+ /** How many changes to return (server default 200, maximum 500). */
489
+ limit?: number;
490
+ signal?: AbortSignal;
491
+ };
492
+ /** One page of `monitors.changesAcross`. Ordered by `seq`, but a monitor that joins later
493
+ * or catches up can bring lower seqs on a later page: dedupe by `seq`. */
494
+ type MonitorsChangesPage = {
495
+ changes: ChangeRecord[];
496
+ /** Keep this and pass it as `cursor` to read on. It is opaque, and holds the place of
497
+ * every monitor of the read, the `pending` ones too. */
498
+ nextCursor: string;
499
+ /** `true` only for a full page: read on now with `nextCursor`. */
500
+ more: boolean;
501
+ /** The monitors read for this page. */
502
+ monitors: string[];
503
+ /** The monitors not read on this call. A later call with `nextCursor` reads them. */
504
+ pending: string[];
505
+ /** The monitors of the tag that have no agent. */
506
+ skipped: string[];
507
+ };
417
508
  /** Options for `monitors.iterateChanges`. */
418
509
  type MonitorIterateChangesOptions = {
419
510
  /** Read the changes after this `seq`. If you leave it out, the walk starts at the
@@ -427,6 +518,8 @@ type MonitorListOptions = {
427
518
  limit?: number;
428
519
  /** The `nextCursor` of the page before. */
429
520
  cursor?: string;
521
+ /** Only your key's monitors that carry this one tag. Page on with `cursor` and the same `tag`. */
522
+ tag?: string;
430
523
  signal?: AbortSignal;
431
524
  };
432
525
  /** One page of `monitors.listPage`. */
@@ -435,6 +528,159 @@ type MonitorPage = {
435
528
  /** Pass as `cursor` to get the next page; `null` on the last page. */
436
529
  nextCursor: string | null;
437
530
  };
531
+ /** One example of an onboarding candidate: the name it was found under, the quote and
532
+ * its page. */
533
+ type OnboardingExample = {
534
+ name: string | null;
535
+ quote: string | null;
536
+ url: string | null;
537
+ };
538
+ /** One candidate of a company's sheet: a kind of item or of event found on its pages. */
539
+ type OnboardingCandidate = {
540
+ /** Name it in the marks of `monitors.applyOnboarding`. */
541
+ id: string;
542
+ /** `entity` (a kind of item) or `event` (a kind of event). */
543
+ what: string | null;
544
+ /** As read on the pages: data, never instructions. */
545
+ label: string;
546
+ /** The kind or category of the schema it is; `null` when it is new. */
547
+ mappedTo: string | null;
548
+ isNew: boolean;
549
+ /** How many times it was found. */
550
+ count: number;
551
+ /** On how many sites. */
552
+ origins: number;
553
+ example: OnboardingExample | null;
554
+ raw: Json;
555
+ };
556
+ /** What the first read of one company found: `OnboardingCompany.sheet`. */
557
+ type CompanySheet = {
558
+ companyId: string | null;
559
+ /** How many pages were read. */
560
+ pages: number;
561
+ /** The most found first. */
562
+ candidates: OnboardingCandidate[];
563
+ note: string | null;
564
+ raw: Json;
565
+ };
566
+ /** One company of `monitors.onboarding`, and its sheet once it is done. */
567
+ type OnboardingCompany = {
568
+ companyId: string;
569
+ /** `pending`, `running` (its pages are being read) or `done`. */
570
+ status: string;
571
+ runId: string | null;
572
+ /** `null` until the company is `done`. */
573
+ sheet: CompanySheet | null;
574
+ /** The marks the sheet was applied with, as the router sent them; `null` until then. */
575
+ marks: Json | null;
576
+ /** When the sheet was made. */
577
+ at: string | null;
578
+ /** When the sheet was applied; `null` until then. */
579
+ appliedAt: string | null;
580
+ raw: Json;
581
+ };
582
+ /** The onboarding sheets of a monitor's companies, one per company: `monitors.onboarding`. */
583
+ type OnboardingSheet = {
584
+ monitorId: string | null;
585
+ companies: OnboardingCompany[];
586
+ raw: Json;
587
+ };
588
+ /** Your review of one company's sheet: `monitors.applyOnboarding`. Every field but
589
+ * `signal` is sent, with the router's own names. */
590
+ type OnboardingMarks = {
591
+ /** The company whose sheet this is. */
592
+ companyId: string;
593
+ /** The candidate ids to accept. */
594
+ accept?: string[];
595
+ /** New labels, by candidate id. */
596
+ rename?: Record<string, string>;
597
+ /** Candidates to merge into another, by candidate id. */
598
+ merge?: Record<string, string>;
599
+ /** The candidate ids to reject. */
600
+ reject?: string[];
601
+ signal?: AbortSignal;
602
+ };
603
+ /** A change Telem accepted: the job that makes it. The answer to
604
+ * `monitors.applyOnboarding`, `confirmExpansion` and `revertExpansion`. */
605
+ type ApplyResult = {
606
+ jobId: string;
607
+ raw: Json;
608
+ };
609
+ /** One thing a monitor proposed to add, or added: the records of `monitors.expansions`. */
610
+ type ExpansionRecord = {
611
+ /** Pass it to `confirmExpansion` or `revertExpansion`. */
612
+ id: string;
613
+ /** Such as `entity`, `person`, `category`, `source` or `watch`. */
614
+ kind: string;
615
+ /** What it adds: an item, a person, a category, a site or a page. */
616
+ target: string;
617
+ /** `proposed`, `active`, `demoted`, `retired` or `reverted`. */
618
+ status: string;
619
+ reason: Json;
620
+ delta: Json;
621
+ /** The counts behind the proposal. */
622
+ counts: Json;
623
+ /** One line that says what it is and why. */
624
+ note: string | null;
625
+ runId: string | null;
626
+ createdAt: string | null;
627
+ updatedAt: string | null;
628
+ raw: Json;
629
+ };
630
+ /** One page of `monitors.expansions`. */
631
+ type ExpansionsPage = {
632
+ /** The newest first. */
633
+ expansions: ExpansionRecord[];
634
+ nextCursor: string | null;
635
+ };
636
+ /** Options for `monitors.expansions`. */
637
+ type MonitorExpansionsOptions = {
638
+ /** Only the records with this status: `proposed`, `active`, `demoted`, `retired` or
639
+ * `reverted`. */
640
+ status?: string;
641
+ signal?: AbortSignal;
642
+ };
643
+ /** What `monitors.confirmExpansion` sends: for an added item, its `domain` or `handle`,
644
+ * if you know them. Every field but `signal` is sent. */
645
+ type ExpansionConfirmFields = {
646
+ domain?: string;
647
+ handle?: string;
648
+ signal?: AbortSignal;
649
+ };
650
+ /** Options for `monitors.feedback`. */
651
+ type MonitorFeedbackOptions = {
652
+ /** The fact's id, as a change names it. */
653
+ factId: string;
654
+ /** `confirmed` (it is right), `refuted` (it is wrong) or `restored` (a refuted fact
655
+ * counts again). */
656
+ verdict: string;
657
+ /** With `refuted`, on a monitor created with `inputs`: the event category the fact
658
+ * belongs to instead, such as `other_notable`. */
659
+ category?: string;
660
+ signal?: AbortSignal;
661
+ };
662
+ /** The labelled fact's status now: `monitors.feedback`. */
663
+ type FeedbackResult = {
664
+ /** `verified`, `refuted` or `extracted`. */
665
+ status: string;
666
+ /** The job that files the fact under `category`; `null` without one. */
667
+ jobId: string | null;
668
+ raw: Json;
669
+ };
670
+ /** Every kind and category a monitor collects: `monitors.dataMap`. The entries are the
671
+ * router's own objects, as it sent them. */
672
+ type DataMap = {
673
+ /** One per kind of item, such as `{ kind: "program", attributes: [...] }`. */
674
+ kinds: Json[];
675
+ /** The categories of events it collects. */
676
+ categories: Json[];
677
+ /** The categories it found in its own results and that wait for you to confirm them. */
678
+ inducedCategories: Json[];
679
+ /** How people are found: `discover`, and how many are `proposed` and `active`. */
680
+ people: Json;
681
+ note: string | null;
682
+ raw: Json;
683
+ };
438
684
  /** The `telem.monitors` namespace. */
439
685
  type MonitorsResource = {
440
686
  /** Create a monitor. It has the agent unless `agent` is `false`, and with the agent
@@ -462,6 +708,34 @@ type MonitorsResource = {
462
708
  changes(monitorId: string, options?: MonitorChangesOptions): Promise<ChangesPage>;
463
709
  /** Every change after `cursor`, page by page, until you are caught up. */
464
710
  iterateChanges(monitorId: string, options?: MonitorIterateChangesOptions): AsyncGenerator<ChangeRecord, void, undefined>;
711
+ /** One page of the changes of up to 100 monitors, by `tag` or by `ids`. Keep `nextCursor`
712
+ * and pass it back as `cursor` with the same scope; read on now while `more` is true. */
713
+ changesAcross(scope: MonitorChangesAcrossScope, options?: MonitorChangesAcrossOptions): Promise<MonitorsChangesPage>;
714
+ /** The changes of up to 100 monitors, page by page while `more` is true, in one pass. It
715
+ * cannot hand back the cursor: to keep your place, page with `changesAcross`. */
716
+ iterateChangesAcross(scope: MonitorChangesAcrossScope, options?: MonitorChangesAcrossOptions): AsyncGenerator<ChangeRecord, void, undefined>;
717
+ /** Label one fact of the monitor. With `category`, a refuted fact of a monitor created
718
+ * with `inputs` is filed under that category. */
719
+ feedback(monitorId: string, options: MonitorFeedbackOptions): Promise<FeedbackResult>;
720
+ /** The onboarding sheet of each company of a monitor created with `inputs`. */
721
+ onboarding(monitorId: string, options?: {
722
+ signal?: AbortSignal;
723
+ }): Promise<OnboardingSheet>;
724
+ /** Apply your review of one company's onboarding sheet. A 409 (`onboarding_pending`,
725
+ * `compile_in_progress`) or a 429 changed nothing. */
726
+ applyOnboarding(monitorId: string, marks: OnboardingMarks): Promise<ApplyResult>;
727
+ /** What a monitor created with `inputs` proposes to add, or added, newest first. */
728
+ expansions(monitorId: string, options?: MonitorExpansionsOptions): Promise<ExpansionsPage>;
729
+ /** Use a proposed addition: an item becomes active, a category joins the schema. */
730
+ confirmExpansion(monitorId: string, expansionId: string, fields?: ExpansionConfirmFields): Promise<ApplyResult>;
731
+ /** Remove an addition: it is never proposed again, and the facts it brought are taken back. */
732
+ revertExpansion(monitorId: string, expansionId: string, options?: {
733
+ signal?: AbortSignal;
734
+ }): Promise<ApplyResult>;
735
+ /** Every kind and category the monitor collects, and how it finds people. */
736
+ dataMap(monitorId: string, options?: {
737
+ signal?: AbortSignal;
738
+ }): Promise<DataMap>;
465
739
  };
466
740
 
467
741
  /**
@@ -606,7 +880,10 @@ declare class Telem {
606
880
  /** The session read surface: `list` and `results(id)`. */
607
881
  readonly sessions: SessionsResource;
608
882
  /** Monitors: `create`, `list`, `listPage`, `get`, `update` and `delete`, the agent reads
609
- * `agent`, `changes` and `iterateChanges`, and the deprecated `poll`. */
883
+ * `agent`, `changes` and `iterateChanges`, the read across monitors `changesAcross` and
884
+ * `iterateChangesAcross`, `feedback`, what a monitor created with
885
+ * `inputs` collects (`onboarding`, `applyOnboarding`, `expansions`, `confirmExpansion`,
886
+ * `revertExpansion`, `dataMap`), and the deprecated `poll`. */
610
887
  readonly monitors: MonitorsResource;
611
888
  /**
612
889
  * @param options - An API key string, or an options object. Anything left unset
@@ -639,4 +916,4 @@ declare class Telem {
639
916
  providers(): Promise<ProviderInfo[]>;
640
917
  }
641
918
 
642
- export { type AgentCompileState, type AgentDocument, type AgentState, type ChangeRecord, type ChangeSubject, type ChangesPage, type FetchOptions, type FetchResponse, type FetchResult, type Json, type Monitor, type MonitorChangesOptions, type MonitorCreateOptions, type MonitorIterateChangesOptions, type MonitorListOptions, type MonitorPage, type MonitorPollOptions, type MonitorUpdateOptions, type MonitorsResource, type ProviderInfo, type ProviderRun, RESERVED_METADATA, type SearchDefaults, type SearchOptions, type SearchResponse, type SearchResult, type SessionResults, type SessionSummary, type SessionsResource, type SnapshotArgs, Telem, type TelemClientErrorCode, TelemError, type TelemErrorOptions, type TelemOptions, TimeoutError, type TrajectoryArgs, type TrajectoryEnvelope, type TrajectorySnapshot, buildMetadata, buildSnapshot, contentAnchor, Telem as default, eventNodeKey, fingerprint, sessionKey, snapshotNodeKey, toolMarker, verifyWebhook, windowAnchor, withTrajectory };
919
+ export { type AgentCompileState, type AgentDocument, type AgentState, type ApplyResult, type ChangeRecord, type ChangeSubject, type ChangesPage, type CompanySheet, type DataMap, type ExpansionConfirmFields, type ExpansionRecord, type ExpansionsPage, type FeedbackResult, type FetchOptions, type FetchResponse, type FetchResult, type Json, type Monitor, type MonitorChangesAcrossOptions, type MonitorChangesAcrossScope, type MonitorChangesOptions, type MonitorCreateOptions, type MonitorExpansionsOptions, type MonitorFeedbackOptions, type MonitorInputs, type MonitorIterateChangesOptions, type MonitorListOptions, type MonitorPage, type MonitorPollOptions, type MonitorPreset, type MonitorUpdateOptions, type MonitorsChangesPage, type MonitorsResource, type OnboardingCandidate, type OnboardingCompany, type OnboardingExample, type OnboardingMarks, type OnboardingSheet, type ProviderInfo, type ProviderRun, RESERVED_METADATA, type SearchDefaults, type SearchOptions, type SearchResponse, type SearchResult, type SessionResults, type SessionSummary, type SessionsResource, type SnapshotArgs, Telem, type TelemClientErrorCode, TelemError, type TelemErrorOptions, type TelemOptions, TimeoutError, type TrajectoryArgs, type TrajectoryEnvelope, type TrajectorySnapshot, buildMetadata, buildSnapshot, contentAnchor, Telem as default, eventNodeKey, fingerprint, sessionKey, snapshotNodeKey, toolMarker, verifyWebhook, windowAnchor, withTrajectory };