telem-sdk 0.2.2__tar.gz → 0.3.0__tar.gz

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.
Files changed (34) hide show
  1. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/PKG-INFO +21 -1
  2. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/README.md +20 -0
  3. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/__init__.py +24 -1
  4. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_base.py +85 -6
  5. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_normalize.py +1 -0
  6. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_skills/telem-search/SKILL.md +8 -7
  7. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_skills/telem-search/scripts/search.py +2 -0
  8. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_version.py +1 -1
  9. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/async_client.py +23 -5
  10. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/client.py +23 -5
  11. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/config.py +171 -37
  12. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/errors.py +17 -1
  13. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/hermes.py +20 -4
  14. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/models.py +127 -2
  15. telem_sdk-0.3.0/telem/resources/monitors.py +475 -0
  16. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/resources/sessions.py +11 -4
  17. telem_sdk-0.2.2/telem/resources/monitors.py +0 -270
  18. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/LICENSE +0 -0
  19. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/pyproject.toml +0 -0
  20. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_config_files.py +0 -0
  21. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/_version_advisory.py +0 -0
  22. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/install_skill.py +0 -0
  23. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/__init__.py +0 -0
  24. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_hermes_render.py +0 -0
  25. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_hermes_state.py +0 -0
  26. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_langchain_trajectory.py +0 -0
  27. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_openai_trajectory.py +0 -0
  28. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_tools.py +0 -0
  29. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_trajectory_v5.py +0 -0
  30. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/_update_advisory.py +0 -0
  31. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/langchain.py +0 -0
  32. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/integrations/openai.py +0 -0
  33. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/py.typed +0 -0
  34. {telem_sdk-0.2.2 → telem_sdk-0.3.0}/telem/resources/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: telem-sdk
3
- Version: 0.2.2
3
+ Version: 0.3.0
4
4
  Summary: Python SDK for the Telem search orchestration API.
5
5
  License-Expression: Apache-2.0
6
6
  License-File: LICENSE
@@ -62,6 +62,9 @@ environment, then — for credentials only — `~/.telem/credentials.json`, then
62
62
  | Provider allow-list | `default_providers_include` | `TELEM_PROVIDERS_INCLUDE` (csv) | the deployment's set |
63
63
  | Provider deny-list | `default_providers_exclude` | `TELEM_PROVIDERS_EXCLUDE` (csv) | unset |
64
64
  | Full page content | `default_include_full_content` | `TELEM_FULL_CONTENT` (`1` only) | off |
65
+ | Fetch providers | none (`fetch(providers=…)`) | `TELEM_FETCH_PROVIDERS` (csv) | the server's chain |
66
+ | Fetch tier | none (`fetch(tier=…)`) | `TELEM_FETCH_TIER` | the server's |
67
+ | Skip the fetch cache | none (`fetch(no_cache=…)`) | `TELEM_FETCH_NO_CACHE` (`1` only) | off |
65
68
 
66
69
  When an API key is set, requests carry an `Authorization: Bearer <key>` header. Anonymous
67
70
  access works for most endpoints locally; `sessions.list` requires a token.
@@ -87,6 +90,12 @@ the Telem plugins, where it survives as a
87
90
  **deprecated alias of the provider allow-list**, ranked below `TELEM_PROVIDERS_INCLUDE`
88
91
  and below both config files. Export `TELEM_PROVIDERS_INCLUDE` everywhere.
89
92
 
93
+ The three fetch defaults have no constructor argument: each resolves as **`fetch`
94
+ argument → env var → unset**, with the same csv and `1`-only rules, and `TELEM_FETCH_TIER`
95
+ is trimmed and lowercased. `no_cache=False` in a call overrides `TELEM_FETCH_NO_CACHE=1`.
96
+ To use the fetch keys in the Telem config files as well, pass
97
+ `**telem.resolve_fetch_options(project_root=...).fetch_kwargs` to `fetch`.
98
+
90
99
  `num_results`, `include_raw` and `provider_overrides` are deliberately call-level only:
91
100
  per-call intent, an audit knob and a surgical escape hatch respectively.
92
101
 
@@ -178,10 +187,21 @@ your last poll. `poll` returns a `SearchResponse`:
178
187
  ```python
179
188
  monitor = client.monitors.create("Nvidia files a new 8-K with the SEC", frequency="1h", ttl="7d")
180
189
  response = client.monitors.poll(monitor.id)
190
+ for change in client.monitors.iter_changes(monitor.id):
191
+ print(change.seq, change.kind, change.subject.name)
181
192
  client.monitors.update(monitor.id, status="paused")
182
193
  client.monitors.delete(monitor.id)
183
194
  ```
184
195
 
196
+ A monitor has an agent unless you create it with `agent=False`. The agent checks every
197
+ result against the query and keeps the ones that match. `iter_changes` reads what it
198
+ kept, oldest first, until you are caught up, and then stops. Keep the `seq` of the last
199
+ change you handled and pass it as `cursor` next time: no change comes twice, and none
200
+ is skipped. `changes` returns one page (`next_cursor`, `watermark`) and takes
201
+ `cursor`, `since`, `kinds` and `limit`. `agent` returns the agent itself, and
202
+ `monitor.agent_state` shows it on the monitor. With `AsyncTelem`, read `iter_changes`
203
+ with `async for`.
204
+
185
205
  `client.monitors` also has `get` and `list`. See [Monitors](https://docs.telem.ai/resources/monitors/)
186
206
  for the fields and the errors.
187
207
 
@@ -42,6 +42,9 @@ environment, then — for credentials only — `~/.telem/credentials.json`, then
42
42
  | Provider allow-list | `default_providers_include` | `TELEM_PROVIDERS_INCLUDE` (csv) | the deployment's set |
43
43
  | Provider deny-list | `default_providers_exclude` | `TELEM_PROVIDERS_EXCLUDE` (csv) | unset |
44
44
  | Full page content | `default_include_full_content` | `TELEM_FULL_CONTENT` (`1` only) | off |
45
+ | Fetch providers | none (`fetch(providers=…)`) | `TELEM_FETCH_PROVIDERS` (csv) | the server's chain |
46
+ | Fetch tier | none (`fetch(tier=…)`) | `TELEM_FETCH_TIER` | the server's |
47
+ | Skip the fetch cache | none (`fetch(no_cache=…)`) | `TELEM_FETCH_NO_CACHE` (`1` only) | off |
45
48
 
46
49
  When an API key is set, requests carry an `Authorization: Bearer <key>` header. Anonymous
47
50
  access works for most endpoints locally; `sessions.list` requires a token.
@@ -67,6 +70,12 @@ the Telem plugins, where it survives as a
67
70
  **deprecated alias of the provider allow-list**, ranked below `TELEM_PROVIDERS_INCLUDE`
68
71
  and below both config files. Export `TELEM_PROVIDERS_INCLUDE` everywhere.
69
72
 
73
+ The three fetch defaults have no constructor argument: each resolves as **`fetch`
74
+ argument → env var → unset**, with the same csv and `1`-only rules, and `TELEM_FETCH_TIER`
75
+ is trimmed and lowercased. `no_cache=False` in a call overrides `TELEM_FETCH_NO_CACHE=1`.
76
+ To use the fetch keys in the Telem config files as well, pass
77
+ `**telem.resolve_fetch_options(project_root=...).fetch_kwargs` to `fetch`.
78
+
70
79
  `num_results`, `include_raw` and `provider_overrides` are deliberately call-level only:
71
80
  per-call intent, an audit knob and a surgical escape hatch respectively.
72
81
 
@@ -158,10 +167,21 @@ your last poll. `poll` returns a `SearchResponse`:
158
167
  ```python
159
168
  monitor = client.monitors.create("Nvidia files a new 8-K with the SEC", frequency="1h", ttl="7d")
160
169
  response = client.monitors.poll(monitor.id)
170
+ for change in client.monitors.iter_changes(monitor.id):
171
+ print(change.seq, change.kind, change.subject.name)
161
172
  client.monitors.update(monitor.id, status="paused")
162
173
  client.monitors.delete(monitor.id)
163
174
  ```
164
175
 
176
+ A monitor has an agent unless you create it with `agent=False`. The agent checks every
177
+ result against the query and keeps the ones that match. `iter_changes` reads what it
178
+ kept, oldest first, until you are caught up, and then stops. Keep the `seq` of the last
179
+ change you handled and pass it as `cursor` next time: no change comes twice, and none
180
+ is skipped. `changes` returns one page (`next_cursor`, `watermark`) and takes
181
+ `cursor`, `since`, `kinds` and `limit`. `agent` returns the agent itself, and
182
+ `monitor.agent_state` shows it on the monitor. With `AsyncTelem`, read `iter_changes`
183
+ with `async for`.
184
+
165
185
  `client.monitors` also has `get` and `list`. See [Monitors](https://docs.telem.ai/resources/monitors/)
166
186
  for the fields and the errors.
167
187
 
@@ -2,7 +2,12 @@
2
2
 
3
3
  from telem.async_client import AsyncTelem
4
4
  from telem.client import Telem
5
- from telem.config import SearchOptionsResolution, resolve_search_options
5
+ from telem.config import (
6
+ FetchOptionsResolution,
7
+ SearchOptionsResolution,
8
+ resolve_fetch_options,
9
+ resolve_search_options,
10
+ )
6
11
  from telem.errors import (
7
12
  APIStatusError,
8
13
  AuthError,
@@ -11,11 +16,19 @@ from telem.errors import (
11
16
  TelemConnectionError,
12
17
  TelemError,
13
18
  TelemServerVersionError,
19
+ TelemTimeoutError,
14
20
  )
15
21
  from telem.models import (
22
+ AgentCompileState,
23
+ AgentDocument,
24
+ AgentState,
25
+ ChangeRecord,
26
+ ChangesPage,
27
+ ChangeSubject,
16
28
  FetchResponse,
17
29
  FetchResult,
18
30
  Monitor,
31
+ MonitorPage,
19
32
  ProviderInfo,
20
33
  ProviderRun,
21
34
  SearchResponse,
@@ -41,6 +54,13 @@ __all__ = [
41
54
  "SessionHistory",
42
55
  "SessionResults",
43
56
  "Monitor",
57
+ "MonitorPage",
58
+ "AgentState",
59
+ "AgentCompileState",
60
+ "AgentDocument",
61
+ "ChangesPage",
62
+ "ChangeRecord",
63
+ "ChangeSubject",
44
64
  "verify_webhook",
45
65
  "TelemError",
46
66
  "AuthError",
@@ -49,7 +69,10 @@ __all__ = [
49
69
  "APIStatusError",
50
70
  "TelemServerVersionError",
51
71
  "TelemConnectionError",
72
+ "TelemTimeoutError",
52
73
  # The unified config — read explicitly, never by the client itself.
53
74
  "resolve_search_options",
54
75
  "SearchOptionsResolution",
76
+ "resolve_fetch_options",
77
+ "FetchOptionsResolution",
55
78
  ]
@@ -11,12 +11,18 @@ import os
11
11
  from collections.abc import Sequence
12
12
  from datetime import date, datetime
13
13
  from typing import Any
14
+ from urllib.parse import quote
14
15
 
15
16
  import httpx
16
17
 
17
- from telem._config_files import read_credentials
18
+ from telem._config_files import TELEM_OPTIONS, option_from_env, read_credentials
18
19
  from telem._version import __version__
19
- from telem.errors import TelemConnectionError, TelemServerVersionError, raise_for_status
20
+ from telem.errors import (
21
+ TelemConnectionError,
22
+ TelemServerVersionError,
23
+ TelemTimeoutError,
24
+ raise_for_status,
25
+ )
20
26
 
21
27
  #: The hosted deployment. A default rather than a requirement: an ordinary user
22
28
  #: should not have to know where Telem runs, and `TELEM_BASE_URL` or the
@@ -47,11 +53,41 @@ def _csv_env(name: str) -> list[str] | None:
47
53
  return [item for item in items if item] or None
48
54
 
49
55
 
56
+ def path_segment(value: str) -> str:
57
+ """Encode a caller-supplied id as ONE path segment, so ``../`` cannot change the route."""
58
+ # quote() leaves dots alone, and httpx collapses a bare ``..`` segment.
59
+ if value in (".", ".."):
60
+ raise ValueError(f"invalid id: {value!r}")
61
+ return quote(value, safe="")
62
+
63
+
64
+ def _providers_refusal(include: list[str], include_from_call: bool, exclude_from_call: bool) -> str:
65
+ """The message for an ``include`` that ``exclude`` empties: where each list was set."""
66
+
67
+ def where(half: str, from_call: bool) -> str:
68
+ return f"the {half} argument" if from_call else f"default_{half} or TELEM_{half.upper()}"
69
+
70
+ names = ", ".join(include)
71
+ return (
72
+ f"providers_exclude removes every provider in providers_include ({names}), so no "
73
+ f"provider is left and no search was sent. Remove {names} from providers_include "
74
+ f"(set by {where('providers_include', include_from_call)}) or from providers_exclude "
75
+ f"(set by {where('providers_exclude', exclude_from_call)})."
76
+ )
77
+
78
+
50
79
  def _flag_env(name: str) -> bool | None:
51
80
  """Parse a boolean env var: exactly ``"1"`` means True, anything else is unset."""
52
81
  return True if os.environ.get(name) == "1" else None
53
82
 
54
83
 
84
+ def _fetch_env(key: str) -> Any | None:
85
+ """Read one fetch key from its ``TELEM_FETCH_*`` var with the shared option table's
86
+ parsing (``nameList`` as CSV, ``name`` trimmed, ``flag`` on with exactly ``"1"``)."""
87
+ spec = next(spec for spec in TELEM_OPTIONS if spec.key == key)
88
+ return option_from_env(spec, os.environ)
89
+
90
+
55
91
  def _int_env(name: str) -> int | None:
56
92
  """Parse an integer env var, or ``None`` when it is unset or not an integer."""
57
93
  try:
@@ -88,13 +124,17 @@ class BaseClient:
88
124
  # This is the SDK's ONE config file. Repo-local `.telem/telem.json` options stay
89
125
  # unread here on purpose: a library must not let a checked-out
90
126
  # repository steer an arbitrary program's spend.
127
+ if api_key is not None and not api_key.strip():
128
+ raise ValueError("api_key is empty")
91
129
  resolved_key = api_key or os.environ.get("TELEM_API_KEY") or None
92
130
  resolved_base = base_url or os.environ.get("TELEM_BASE_URL") or None
93
131
  if resolved_key is None or resolved_base is None:
94
132
  credentials = read_credentials(os.environ)
95
133
  resolved_key = resolved_key or credentials.get("apiKey")
96
134
  resolved_base = resolved_base or credentials.get("baseUrl")
97
- self.api_key = resolved_key
135
+ # Stripped: ``$(cat keyfile)`` leaves a trailing newline, which httpx rejects
136
+ # as an illegal header value.
137
+ self.api_key = resolved_key.strip() if resolved_key else resolved_key
98
138
  self.base_url = (resolved_base or _DEFAULT_BASE_URL).rstrip("/")
99
139
  self.timeout = timeout
100
140
  self.user_agent = user_agent or _DEFAULT_USER_AGENT
@@ -136,6 +176,13 @@ class BaseClient:
136
176
  if default_topic is not None
137
177
  else ((os.environ.get("TELEM_TOPIC") or "").strip() or None)
138
178
  )
179
+ # Fetch defaults: env var only, else unset; a ``fetch()`` argument wins per key.
180
+ # The tier is lowercased, as the agent plugins send it. The config files stay
181
+ # unread here too: ``resolve_fetch_options()`` is the opt-in for them.
182
+ fetch_tier = _fetch_env("fetchTier")
183
+ self.default_fetch_providers = _fetch_env("fetchProviders")
184
+ self.default_fetch_tier = fetch_tier.lower() if fetch_tier is not None else None
185
+ self.default_fetch_no_cache = _fetch_env("fetchNoCache")
139
186
 
140
187
  def _headers(self) -> dict[str, str]:
141
188
  """Build the default request headers, adding Bearer auth only when an api_key is set."""
@@ -181,7 +228,8 @@ class BaseClient:
181
228
  never carries both.
182
229
  2. When both provider halves resolve, ``include`` fully determines the set: the
183
230
  excluded names are subtracted client-side and ``exclude`` is not sent. An include
184
- emptied by that subtraction is still sent, as ``[]``.
231
+ emptied by that subtraction raises ``ValueError`` before anything is sent: no
232
+ provider is left, and the deployment's default set could hold an excluded one.
185
233
 
186
234
  Returns:
187
235
  The ``search`` block, containing exactly the options that are set (``{}`` when
@@ -205,7 +253,14 @@ class BaseClient:
205
253
  )
206
254
  if include is not None and exclude is not None:
207
255
  excluded = set(exclude)
208
- include = [name for name in include if name not in excluded]
256
+ kept = [name for name in include if name not in excluded]
257
+ if include and not kept:
258
+ raise ValueError(
259
+ _providers_refusal(
260
+ include, providers_include is not None, providers_exclude is not None
261
+ )
262
+ )
263
+ include = kept
209
264
  exclude = None
210
265
 
211
266
  if include_full_content is None:
@@ -352,6 +407,8 @@ class BaseClient:
352
407
  inline_content: bool | None = None,
353
408
  inline_max_chars: int | None = None,
354
409
  content_format: str | None = None,
410
+ tier: str | None = None,
411
+ no_cache: bool | None = None,
355
412
  session: str | None = None,
356
413
  metadata: dict[str, Any] | None = None,
357
414
  ) -> dict[str, Any]:
@@ -381,6 +438,13 @@ class BaseClient:
381
438
  "urls": url_list,
382
439
  "metadata": dict(metadata) if metadata else {},
383
440
  }
441
+ # A call argument wins; ``None`` falls back to the ``TELEM_FETCH_*`` default.
442
+ if providers is None and self.default_fetch_providers is not None:
443
+ providers = list(self.default_fetch_providers)
444
+ if tier is None:
445
+ tier = self.default_fetch_tier
446
+ if no_cache is None:
447
+ no_cache = self.default_fetch_no_cache
384
448
  options: dict[str, Any] = {}
385
449
  if providers is not None:
386
450
  options["providers"] = providers
@@ -390,6 +454,10 @@ class BaseClient:
390
454
  options["inline_max_chars"] = inline_max_chars
391
455
  if content_format is not None:
392
456
  options["content_format"] = content_format
457
+ if tier is not None:
458
+ options["tier"] = tier
459
+ if no_cache is not None:
460
+ options["no_cache"] = no_cache
393
461
  if options:
394
462
  body["options"] = options
395
463
  if session is not None:
@@ -398,8 +466,11 @@ class BaseClient:
398
466
 
399
467
  def _connection_error(self, path: str, exc: Exception) -> TelemConnectionError:
400
468
  """Wrap a transport-level failure (no HTTP response was produced) for ``path``."""
469
+ # A LocalProtocolError is a fault in the request we built, and its text can quote
470
+ # a header value (the Authorization key), so its text is never echoed.
471
+ detail = "" if isinstance(exc, httpx.LocalProtocolError) else f": {exc}"
401
472
  return TelemConnectionError(
402
- f"could not reach {self._url(path)}: {type(exc).__name__}: {exc}"
473
+ f"could not reach {self._url(path)}: {type(exc).__name__}{detail}"
403
474
  )
404
475
 
405
476
  @staticmethod
@@ -443,6 +514,14 @@ class BaseClient:
443
514
  raise_for_status(status_code, body)
444
515
  return body
445
516
 
517
+ def _timeout_error(self, path: str, exc: Exception) -> TelemTimeoutError:
518
+ """Wrap a timeout for ``path``: the server may have got the request, so it is not
519
+ "could not reach"."""
520
+ return TelemTimeoutError(
521
+ f"request to {self._url(path)} timed out after {self.timeout} s: "
522
+ f"{type(exc).__name__}: {exc}"
523
+ )
524
+
446
525
  @classmethod
447
526
  def _result(cls, response: httpx.Response) -> Any:
448
527
  """Parse an httpx response into JSON (falling back to text) and apply error mapping.
@@ -93,6 +93,7 @@ def _provider_run(run: Any) -> ProviderRun:
93
93
  verticals=envelope.get("verticals"),
94
94
  usage=envelope.get("usage"),
95
95
  warnings=envelope.get("warnings", []),
96
+ same_story=envelope.get("same_story"),
96
97
  )
97
98
 
98
99
 
@@ -77,17 +77,18 @@ opencode and pi plugins apply, in this order:
77
77
  1. A request may carry `tier` **or** `fields`, never both — the more specific level
78
78
  wins; on a tie, `fields`.
79
79
  2. When **both** `providersInclude` and `providersExclude` resolve, the exclusion is
80
- subtracted from the include and only `providersInclude` is sent: the server rejects
81
- a request naming the same provider in both halves, and an include already replaces
82
- the deployment's default set. If the subtraction empties the include, both halves
83
- are dropped and the deployment's default providers run — a config can never resolve
84
- to an empty provider set, which would fail every search. `providersExclude` on its
85
- own is forwarded verbatim.
80
+ subtracted from the include and only `providersInclude` is sent: exclude wins, and
81
+ an include already replaces the deployment's default set. If the subtraction
82
+ empties the include, no provider is left: the search is refused before anything is
83
+ sent (`options.refusal`, raised by `search_kwargs`), and the message says where
84
+ each list was set. The default providers never run instead, because they could
85
+ include the one you excluded. `providersExclude` on its own is forwarded verbatim.
86
86
  3. `providerOverrides` applies only alongside the resolved `providersInclude` and only
87
87
  to providers named there — anything else is dropped rather than sent, because the
88
88
  server rejects an override naming a provider the request did not select.
89
89
 
90
- Each rule that drops something says so in `options.warnings`.
90
+ Each rule that drops something says so in `options.warnings`; a refused search says so
91
+ in `options.refusal`.
91
92
 
92
93
  The **client itself never reads these files** — a library must not let a checked-out
93
94
  repository steer an arbitrary program's spend. It does read
@@ -151,6 +151,8 @@ def main() -> None:
151
151
  )
152
152
  except TelemError as exc:
153
153
  sys.exit(f"telem search failed: {exc.message}")
154
+ except ValueError as exc: # refused before sending, e.g. the config leaves no provider
155
+ sys.exit(f"telem search failed: {exc}")
154
156
  except httpx.HTTPError as exc:
155
157
  sys.exit(f"telem search failed: could not reach the Telem backend ({exc})")
156
158
 
@@ -13,4 +13,4 @@ one-line change; if you are editing a version string anywhere else, something ha
13
13
  regressed back to the shape that caused that.
14
14
  """
15
15
 
16
- __version__ = "0.2.2"
16
+ __version__ = "0.3.0"
@@ -45,7 +45,8 @@ class AsyncTelem(BaseClient):
45
45
  Args:
46
46
  api_key: Bearer token. Falls back to the ``TELEM_API_KEY`` env var, then to
47
47
  ``~/.telem/credentials.json`` (the file the guided installer writes;
48
- ``TELEM_CONFIG_DIR`` relocates the directory), then anonymous.
48
+ ``TELEM_CONFIG_DIR`` relocates the directory), then anonymous. An empty
49
+ ``api_key`` raises ``ValueError``.
49
50
  base_url: API base URL. Falls back to ``TELEM_BASE_URL``, then to the same
50
51
  credentials file, then the hosted deployment at router.telem.ai.
51
52
  timeout: Request timeout in seconds.
@@ -85,7 +86,9 @@ class AsyncTelem(BaseClient):
85
86
  """Issue a GET request and return the parsed body (raising typed errors on failure)."""
86
87
  try:
87
88
  response = await self._client.get(self._url(path), params=params)
88
- except (httpx.TimeoutException, httpx.TransportError) as exc:
89
+ except httpx.TimeoutException as exc:
90
+ raise self._timeout_error(path, exc) from exc
91
+ except httpx.TransportError as exc:
89
92
  raise self._connection_error(path, exc) from exc
90
93
  return self._result(response)
91
94
 
@@ -93,7 +96,9 @@ class AsyncTelem(BaseClient):
93
96
  """Issue a POST request and return the parsed body (raising typed errors on failure)."""
94
97
  try:
95
98
  response = await self._client.post(self._url(path), json=json)
96
- except (httpx.TimeoutException, httpx.TransportError) as exc:
99
+ except httpx.TimeoutException as exc:
100
+ raise self._timeout_error(path, exc) from exc
101
+ except httpx.TransportError as exc:
97
102
  raise self._connection_error(path, exc) from exc
98
103
  return self._result(response)
99
104
 
@@ -101,7 +106,9 @@ class AsyncTelem(BaseClient):
101
106
  """Issue a PATCH/DELETE request and return the parsed body (typed errors on failure)."""
102
107
  try:
103
108
  response = await self._client.request(method, self._url(path), json=json)
104
- except (httpx.TimeoutException, httpx.TransportError) as exc:
109
+ except httpx.TimeoutException as exc:
110
+ raise self._timeout_error(path, exc) from exc
111
+ except httpx.TransportError as exc:
105
112
  raise self._connection_error(path, exc) from exc
106
113
  return self._result(response)
107
114
 
@@ -202,6 +209,8 @@ class AsyncTelem(BaseClient):
202
209
  inline_content: bool | None = None,
203
210
  inline_max_chars: int | None = None,
204
211
  content_format: str | None = None,
212
+ tier: str | None = None,
213
+ no_cache: bool | None = None,
205
214
  session: str | None = None,
206
215
  metadata: dict[str, Any] | None = None,
207
216
  ) -> FetchResponse:
@@ -214,10 +223,17 @@ class AsyncTelem(BaseClient):
214
223
 
215
224
  Args:
216
225
  urls: The http(s) URLs to read (the server caps the batch size).
217
- providers: Fetch provider chain override (e.g. ``["tavily"]``).
226
+ providers: Fetch provider chain override (e.g. ``["tavily"]``). Defaults to
227
+ ``TELEM_FETCH_PROVIDERS``.
218
228
  inline_content: Whether to inline page content in the response.
219
229
  inline_max_chars: Max inlined characters per page.
220
230
  content_format: Requested content format (e.g. ``"markdown"``).
231
+ tier: Fetch tier: ``"minimalist"``, ``"default"``, ``"extended"`` or ``"max"``
232
+ (sent as given; the server rejects an unknown one). Defaults to
233
+ ``TELEM_FETCH_TIER``, lowercased.
234
+ no_cache: ``True`` reads every page live and skips the shared fetch cache.
235
+ Defaults to ``TELEM_FETCH_NO_CACHE`` (on with exactly ``"1"``); ``False``
236
+ overrides it.
221
237
  session: Optional session id to continue an existing session.
222
238
  metadata: Additional request metadata.
223
239
 
@@ -231,6 +247,8 @@ class AsyncTelem(BaseClient):
231
247
  inline_content=inline_content,
232
248
  inline_max_chars=inline_max_chars,
233
249
  content_format=content_format,
250
+ tier=tier,
251
+ no_cache=no_cache,
234
252
  session=session,
235
253
  metadata=metadata,
236
254
  )
@@ -45,7 +45,8 @@ class Telem(BaseClient):
45
45
  Args:
46
46
  api_key: Bearer token. Falls back to the ``TELEM_API_KEY`` env var, then to
47
47
  ``~/.telem/credentials.json`` (the file the guided installer writes;
48
- ``TELEM_CONFIG_DIR`` relocates the directory), then anonymous.
48
+ ``TELEM_CONFIG_DIR`` relocates the directory), then anonymous. An empty
49
+ ``api_key`` raises ``ValueError``.
49
50
  base_url: API base URL. Falls back to ``TELEM_BASE_URL``, then to the same
50
51
  credentials file, then the hosted deployment at router.telem.ai.
51
52
  timeout: Request timeout in seconds.
@@ -85,7 +86,9 @@ class Telem(BaseClient):
85
86
  """Issue a GET request and return the parsed body (raising typed errors on failure)."""
86
87
  try:
87
88
  response = self._client.get(self._url(path), params=params)
88
- except (httpx.TimeoutException, httpx.TransportError) as exc:
89
+ except httpx.TimeoutException as exc:
90
+ raise self._timeout_error(path, exc) from exc
91
+ except httpx.TransportError as exc:
89
92
  raise self._connection_error(path, exc) from exc
90
93
  return self._result(response)
91
94
 
@@ -93,7 +96,9 @@ class Telem(BaseClient):
93
96
  """Issue a POST request and return the parsed body (raising typed errors on failure)."""
94
97
  try:
95
98
  response = self._client.post(self._url(path), json=json)
96
- except (httpx.TimeoutException, httpx.TransportError) as exc:
99
+ except httpx.TimeoutException as exc:
100
+ raise self._timeout_error(path, exc) from exc
101
+ except httpx.TransportError as exc:
97
102
  raise self._connection_error(path, exc) from exc
98
103
  return self._result(response)
99
104
 
@@ -101,7 +106,9 @@ class Telem(BaseClient):
101
106
  """Issue a PATCH/DELETE request and return the parsed body (typed errors on failure)."""
102
107
  try:
103
108
  response = self._client.request(method, self._url(path), json=json)
104
- except (httpx.TimeoutException, httpx.TransportError) as exc:
109
+ except httpx.TimeoutException as exc:
110
+ raise self._timeout_error(path, exc) from exc
111
+ except httpx.TransportError as exc:
105
112
  raise self._connection_error(path, exc) from exc
106
113
  return self._result(response)
107
114
 
@@ -202,6 +209,8 @@ class Telem(BaseClient):
202
209
  inline_content: bool | None = None,
203
210
  inline_max_chars: int | None = None,
204
211
  content_format: str | None = None,
212
+ tier: str | None = None,
213
+ no_cache: bool | None = None,
205
214
  session: str | None = None,
206
215
  metadata: dict[str, Any] | None = None,
207
216
  ) -> FetchResponse:
@@ -214,10 +223,17 @@ class Telem(BaseClient):
214
223
 
215
224
  Args:
216
225
  urls: The http(s) URLs to read (the server caps the batch size).
217
- providers: Fetch provider chain override (e.g. ``["tavily"]``).
226
+ providers: Fetch provider chain override (e.g. ``["tavily"]``). Defaults to
227
+ ``TELEM_FETCH_PROVIDERS``.
218
228
  inline_content: Whether to inline page content in the response.
219
229
  inline_max_chars: Max inlined characters per page.
220
230
  content_format: Requested content format (e.g. ``"markdown"``).
231
+ tier: Fetch tier: ``"minimalist"``, ``"default"``, ``"extended"`` or ``"max"``
232
+ (sent as given; the server rejects an unknown one). Defaults to
233
+ ``TELEM_FETCH_TIER``, lowercased.
234
+ no_cache: ``True`` reads every page live and skips the shared fetch cache.
235
+ Defaults to ``TELEM_FETCH_NO_CACHE`` (on with exactly ``"1"``); ``False``
236
+ overrides it.
221
237
  session: Optional session id to continue an existing session.
222
238
  metadata: Additional request metadata.
223
239
 
@@ -231,6 +247,8 @@ class Telem(BaseClient):
231
247
  inline_content=inline_content,
232
248
  inline_max_chars=inline_max_chars,
233
249
  content_format=content_format,
250
+ tier=tier,
251
+ no_cache=no_cache,
234
252
  session=session,
235
253
  metadata=metadata,
236
254
  )