@telemai/sdk 0.2.2 → 0.2.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.
- package/README.md +8 -8
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/vercel/index.d.cts +2 -2
- package/dist/vercel/index.d.ts +2 -2
- package/package.json +11 -7
package/README.md
CHANGED
|
@@ -42,7 +42,7 @@ See [Authentication](https://docs.telem.ai/authentication/) for the full rules.
|
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
44
|
|
|
45
|
-
const telem = new Telem
|
|
45
|
+
const telem = new Telem // environment, then ~/.telem/credentials.json
|
|
46
46
|
const telem = new Telem("tlm_...") // just a key
|
|
47
47
|
const telem = new Telem({
|
|
48
48
|
apiKey: "tlm_...",
|
|
@@ -176,7 +176,7 @@ Do not expect a shorter list. The options are on the
|
|
|
176
176
|
List the providers the deployment can run:
|
|
177
177
|
|
|
178
178
|
```ts
|
|
179
|
-
for (const provider of await telem.providers
|
|
179
|
+
for (const provider of await telem.providers) {
|
|
180
180
|
console.log(provider.name, provider.activeByDefault, provider.tiers)
|
|
181
181
|
}
|
|
182
182
|
```
|
|
@@ -187,7 +187,7 @@ Every search belongs to a session. The response carries its id as `sessionId`. R
|
|
|
187
187
|
your sessions back to see what an agent searched for. Both methods require an API key:
|
|
188
188
|
|
|
189
189
|
```ts
|
|
190
|
-
for (const session of await telem.sessions.list
|
|
190
|
+
for (const session of await telem.sessions.list) {
|
|
191
191
|
console.log(session.id, session.interactionCount, session.latestInteractionAt)
|
|
192
192
|
}
|
|
193
193
|
|
|
@@ -210,7 +210,7 @@ import { generateText } from "ai"
|
|
|
210
210
|
import Telem from "@telemai/sdk"
|
|
211
211
|
import { createTelemVercelTools } from "@telemai/sdk/vercel"
|
|
212
212
|
|
|
213
|
-
const telem = new Telem
|
|
213
|
+
const telem = new Telem
|
|
214
214
|
const tools = createTelemVercelTools({ telem, harness: "my-app" })
|
|
215
215
|
|
|
216
216
|
const result = await generateText({ model, tools, prompt: "Is the Nintendo Museum open over New Year?" })
|
|
@@ -222,7 +222,7 @@ then appear in the console under the tool call that started it. `ai` version 5
|
|
|
222
222
|
or later is an optional peer dependency, used by this subpath only. The full
|
|
223
223
|
guide, subagents, your own tools, and the options, is on the
|
|
224
224
|
[Vercel AI SDK page](https://docs.telem.ai/integrations/vercel-ai/). The runnable example is `examples/vercel-ai-agents.mjs`
|
|
225
|
-
in the SDK source, first in the [examples list](https://github.com/TelemAI/
|
|
225
|
+
in the SDK source, first in the [examples list](https://github.com/TelemAI/telem-js-sdk/tree/main/examples).
|
|
226
226
|
|
|
227
227
|
## Query lineage
|
|
228
228
|
|
|
@@ -251,8 +251,8 @@ Node SDK, where the completion id is the turn and each tool call has its own id:
|
|
|
251
251
|
|
|
252
252
|
```ts
|
|
253
253
|
|
|
254
|
-
const telem = new Telem
|
|
255
|
-
const openai = new OpenAI
|
|
254
|
+
const telem = new Telem
|
|
255
|
+
const openai = new OpenAI
|
|
256
256
|
const messages = [{ role: "user" as const, content: "Is the Nintendo Museum open over New Year?" }]
|
|
257
257
|
const tools = [
|
|
258
258
|
{
|
|
@@ -269,7 +269,7 @@ const tools = [
|
|
|
269
269
|
},
|
|
270
270
|
]
|
|
271
271
|
|
|
272
|
-
const conversationId = crypto.randomUUID
|
|
272
|
+
const conversationId = crypto.randomUUID // once, when the conversation starts
|
|
273
273
|
const windowId = await windowAnchor(messages) // once, from the first message
|
|
274
274
|
|
|
275
275
|
const completion = await openai.chat.completions.create({ model: "gpt-4o", messages, tools })
|
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.
|
|
62
|
+
var VERSION = "0.2.3";
|
|
63
63
|
|
|
64
64
|
// src/config.ts
|
|
65
65
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -594,7 +594,7 @@ function searchBlock(defaults, options) {
|
|
|
594
594
|
if (options.rerank !== void 0) block.rerank = options.rerank;
|
|
595
595
|
if (includeFullContent !== void 0) block.include_full_content = includeFullContent;
|
|
596
596
|
const autoRouting = options.autoRouting ?? defaults.autoRouting;
|
|
597
|
-
if (autoRouting !== void 0) block.auto_routing = autoRouting;
|
|
597
|
+
if (autoRouting !== void 0 && autoRouting.toLowerCase() !== "off") block.auto_routing = autoRouting;
|
|
598
598
|
const maxRoutingProviders = options.maxRoutingProviders ?? defaults.maxRoutingProviders;
|
|
599
599
|
if (maxRoutingProviders !== void 0) block.max_routing_providers = maxRoutingProviders;
|
|
600
600
|
const topic = options.topic ?? defaults.topic;
|
|
@@ -767,7 +767,7 @@ var Telem = class {
|
|
|
767
767
|
timeoutMs;
|
|
768
768
|
/** Resolved retry budget (attempts after the first). */
|
|
769
769
|
maxRetries;
|
|
770
|
-
/** The session read surface: `list
|
|
770
|
+
/** The session read surface: `list` and `results(id)`. */
|
|
771
771
|
sessions;
|
|
772
772
|
#config;
|
|
773
773
|
/**
|
package/dist/index.d.cts
CHANGED
|
@@ -190,7 +190,7 @@ type ProviderInfo = {
|
|
|
190
190
|
normalized: boolean;
|
|
191
191
|
tiers: string[];
|
|
192
192
|
};
|
|
193
|
-
/** One session as `sessions.list
|
|
193
|
+
/** One session as `sessions.list` reports it. */
|
|
194
194
|
type SessionSummary = {
|
|
195
195
|
id: string;
|
|
196
196
|
createdAt: string | null;
|
|
@@ -333,7 +333,7 @@ declare function withTrajectory(options: FetchOptions, envelope: TrajectoryEnvel
|
|
|
333
333
|
*
|
|
334
334
|
* @example
|
|
335
335
|
* ```ts
|
|
336
|
-
* const telem = new Telem
|
|
336
|
+
* const telem = new Telem // env / credentials-file resolution
|
|
337
337
|
* const telem = new Telem("tlm_...") // bare API-key shorthand
|
|
338
338
|
* const telem = new Telem({ apiKey, baseUrl, tier: "max" })
|
|
339
339
|
* ```
|
|
@@ -348,7 +348,7 @@ declare class Telem {
|
|
|
348
348
|
readonly timeoutMs: number;
|
|
349
349
|
/** Resolved retry budget (attempts after the first). */
|
|
350
350
|
readonly maxRetries: number;
|
|
351
|
-
/** The session read surface: `list
|
|
351
|
+
/** The session read surface: `list` and `results(id)`. */
|
|
352
352
|
readonly sessions: SessionsResource;
|
|
353
353
|
/**
|
|
354
354
|
* @param options - An API key string, or an options object. Anything left unset
|
package/dist/index.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ type ProviderInfo = {
|
|
|
190
190
|
normalized: boolean;
|
|
191
191
|
tiers: string[];
|
|
192
192
|
};
|
|
193
|
-
/** One session as `sessions.list
|
|
193
|
+
/** One session as `sessions.list` reports it. */
|
|
194
194
|
type SessionSummary = {
|
|
195
195
|
id: string;
|
|
196
196
|
createdAt: string | null;
|
|
@@ -333,7 +333,7 @@ declare function withTrajectory(options: FetchOptions, envelope: TrajectoryEnvel
|
|
|
333
333
|
*
|
|
334
334
|
* @example
|
|
335
335
|
* ```ts
|
|
336
|
-
* const telem = new Telem
|
|
336
|
+
* const telem = new Telem // env / credentials-file resolution
|
|
337
337
|
* const telem = new Telem("tlm_...") // bare API-key shorthand
|
|
338
338
|
* const telem = new Telem({ apiKey, baseUrl, tier: "max" })
|
|
339
339
|
* ```
|
|
@@ -348,7 +348,7 @@ declare class Telem {
|
|
|
348
348
|
readonly timeoutMs: number;
|
|
349
349
|
/** Resolved retry budget (attempts after the first). */
|
|
350
350
|
readonly maxRetries: number;
|
|
351
|
-
/** The session read surface: `list
|
|
351
|
+
/** The session read surface: `list` and `results(id)`. */
|
|
352
352
|
readonly sessions: SessionsResource;
|
|
353
353
|
/**
|
|
354
354
|
* @param options - An API key string, or an options object. Anything left unset
|
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.
|
|
25
|
+
var VERSION = "0.2.3";
|
|
26
26
|
|
|
27
27
|
// src/config.ts
|
|
28
28
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -229,7 +229,7 @@ function searchBlock(defaults, options) {
|
|
|
229
229
|
if (options.rerank !== void 0) block.rerank = options.rerank;
|
|
230
230
|
if (includeFullContent !== void 0) block.include_full_content = includeFullContent;
|
|
231
231
|
const autoRouting = options.autoRouting ?? defaults.autoRouting;
|
|
232
|
-
if (autoRouting !== void 0) block.auto_routing = autoRouting;
|
|
232
|
+
if (autoRouting !== void 0 && autoRouting.toLowerCase() !== "off") block.auto_routing = autoRouting;
|
|
233
233
|
const maxRoutingProviders = options.maxRoutingProviders ?? defaults.maxRoutingProviders;
|
|
234
234
|
if (maxRoutingProviders !== void 0) block.max_routing_providers = maxRoutingProviders;
|
|
235
235
|
const topic = options.topic ?? defaults.topic;
|
|
@@ -402,7 +402,7 @@ var Telem = class {
|
|
|
402
402
|
timeoutMs;
|
|
403
403
|
/** Resolved retry budget (attempts after the first). */
|
|
404
404
|
maxRetries;
|
|
405
|
-
/** The session read surface: `list
|
|
405
|
+
/** The session read surface: `list` and `results(id)`. */
|
|
406
406
|
sessions;
|
|
407
407
|
#config;
|
|
408
408
|
/**
|
package/dist/vercel/index.d.cts
CHANGED
|
@@ -121,7 +121,7 @@ type TelemVercelAgentOptions = {
|
|
|
121
121
|
* several HTTP requests must pass a stable id (the chat id), or every request
|
|
122
122
|
* becomes its own session. */
|
|
123
123
|
conversationId?: string;
|
|
124
|
-
/** The root-first chain this agent hangs under; `child
|
|
124
|
+
/** The root-first chain this agent hangs under; `child` fills it. */
|
|
125
125
|
ancestors?: readonly TrajectorySnapshot[];
|
|
126
126
|
/** `ancestors` (phase 1, the default), `history` (both phases) or `off`.
|
|
127
127
|
* Unset reads `TELEM_INCREMENTAL` per call. */
|
|
@@ -133,7 +133,7 @@ type TelemVercelAgentOptions = {
|
|
|
133
133
|
* without replacing a tool. A throw or a rejection here is swallowed; it
|
|
134
134
|
* never fails the call. */
|
|
135
135
|
onResponse?: (event: TelemVercelCallEvent) => void | Promise<void>;
|
|
136
|
-
/** Advanced: the ledgers to share. `child
|
|
136
|
+
/** Advanced: the ledgers to share. `child` passes its parent's, so a child
|
|
137
137
|
* never re-sends what the parent already proved delivered. */
|
|
138
138
|
incrementalState?: IncrementalState;
|
|
139
139
|
};
|
package/dist/vercel/index.d.ts
CHANGED
|
@@ -121,7 +121,7 @@ type TelemVercelAgentOptions = {
|
|
|
121
121
|
* several HTTP requests must pass a stable id (the chat id), or every request
|
|
122
122
|
* becomes its own session. */
|
|
123
123
|
conversationId?: string;
|
|
124
|
-
/** The root-first chain this agent hangs under; `child
|
|
124
|
+
/** The root-first chain this agent hangs under; `child` fills it. */
|
|
125
125
|
ancestors?: readonly TrajectorySnapshot[];
|
|
126
126
|
/** `ancestors` (phase 1, the default), `history` (both phases) or `off`.
|
|
127
127
|
* Unset reads `TELEM_INCREMENTAL` per call. */
|
|
@@ -133,7 +133,7 @@ type TelemVercelAgentOptions = {
|
|
|
133
133
|
* without replacing a tool. A throw or a rejection here is swallowed; it
|
|
134
134
|
* never fails the call. */
|
|
135
135
|
onResponse?: (event: TelemVercelCallEvent) => void | Promise<void>;
|
|
136
|
-
/** Advanced: the ledgers to share. `child
|
|
136
|
+
/** Advanced: the ledgers to share. `child` passes its parent's, so a child
|
|
137
137
|
* never re-sends what the parent already proved delivered. */
|
|
138
138
|
incrementalState?: IncrementalState;
|
|
139
139
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telemai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Telem web search and fetch for JavaScript and TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,14 +42,10 @@
|
|
|
42
42
|
"node": ">=20.16"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"pretest": "npm run build",
|
|
46
|
-
"test": "node --test 'test/**/*.test.ts'",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"gen-version": "node scripts/gen-version.mjs",
|
|
49
|
-
"prebuild": "node scripts/gen-version.mjs",
|
|
50
45
|
"build": "tsup",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
51
47
|
"prepack": "npm run build",
|
|
52
|
-
"
|
|
48
|
+
"test": "node scripts/smoke.mjs"
|
|
53
49
|
},
|
|
54
50
|
"devDependencies": {
|
|
55
51
|
"@types/node": "^22.20.1",
|
|
@@ -71,5 +67,13 @@
|
|
|
71
67
|
"./dist/vercel/index.d.ts"
|
|
72
68
|
]
|
|
73
69
|
}
|
|
70
|
+
},
|
|
71
|
+
"repository": {
|
|
72
|
+
"type": "git",
|
|
73
|
+
"url": "git+https://github.com/TelemAI/telem-js-sdk.git"
|
|
74
|
+
},
|
|
75
|
+
"homepage": "https://docs.telem.ai/sdks/javascript/",
|
|
76
|
+
"bugs": {
|
|
77
|
+
"url": "https://github.com/TelemAI/telem-js-sdk/issues"
|
|
74
78
|
}
|
|
75
79
|
}
|