@telemai/sdk 0.2.1 → 0.2.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 +8 -8
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/vercel/index.cjs +11 -2
- package/dist/vercel/index.d.cts +3 -2
- package/dist/vercel/index.d.ts +3 -2
- package/dist/vercel/index.js +11 -2
- package/package.json +7 -11
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 // environment, then ~/.telem/credentials.json
|
|
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/TelemSDK/tree/main/js-sdk/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 // once, when the conversation starts
|
|
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.2";
|
|
63
63
|
|
|
64
64
|
// src/config.ts
|
|
65
65
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -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` and `results(id)`. */
|
|
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` reports it. */
|
|
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 // env / credentials-file resolution
|
|
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` and `results(id)`. */
|
|
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` reports it. */
|
|
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 // env / credentials-file resolution
|
|
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` and `results(id)`. */
|
|
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.2";
|
|
26
26
|
|
|
27
27
|
// src/config.ts
|
|
28
28
|
var DEFAULT_BASE_URL = "https://router.telem.ai";
|
|
@@ -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` and `results(id)`. */
|
|
405
|
+
/** The session read surface: `list()` and `results(id)`. */
|
|
406
406
|
sessions;
|
|
407
407
|
#config;
|
|
408
408
|
/**
|
package/dist/vercel/index.cjs
CHANGED
|
@@ -473,6 +473,10 @@ var SEARCH_SCHEMA = (0, import_ai.jsonSchema)({
|
|
|
473
473
|
context: {
|
|
474
474
|
type: "string",
|
|
475
475
|
description: "Two or three sentences of your reasoning: what you want to find out and why, given what you already know. Not a restatement of the query."
|
|
476
|
+
},
|
|
477
|
+
topic: {
|
|
478
|
+
type: "string",
|
|
479
|
+
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."
|
|
476
480
|
}
|
|
477
481
|
},
|
|
478
482
|
required: ["query"],
|
|
@@ -563,7 +567,7 @@ function createTelemVercelAgent(options) {
|
|
|
563
567
|
const opts = { ...searchOptions ?? {}, signal: signalFor(execution, searchOptions?.signal) };
|
|
564
568
|
const { envelope, plan } = await lineage(execution, {
|
|
565
569
|
name: SEARCH_TOOL,
|
|
566
|
-
input: { query, goal: opts.goal, context: opts.context }
|
|
570
|
+
input: { query, goal: opts.goal, context: opts.context, topic: opts.topic }
|
|
567
571
|
});
|
|
568
572
|
const response = await state.sendWithOmissionRetry(
|
|
569
573
|
plan,
|
|
@@ -622,7 +626,12 @@ function createTelemVercelAgent(options) {
|
|
|
622
626
|
telem_search: {
|
|
623
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.",
|
|
624
628
|
inputSchema: SEARCH_SCHEMA,
|
|
625
|
-
execute: async (input, execution) =>
|
|
629
|
+
execute: async (input, execution) => {
|
|
630
|
+
const topic = input.topic?.trim() || void 0;
|
|
631
|
+
return renderSearch(
|
|
632
|
+
await search(input.query, { goal: input.goal, context: input.context, topic }, execution)
|
|
633
|
+
);
|
|
634
|
+
}
|
|
626
635
|
},
|
|
627
636
|
telem_fetch: {
|
|
628
637
|
description: "Read the text of one web page by URL. telem_search returns snippets; this returns the page.",
|
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` fills it. */
|
|
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` passes its parent's, so a 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
|
};
|
|
@@ -141,6 +141,7 @@ type TelemVercelSearchInput = {
|
|
|
141
141
|
query: string;
|
|
142
142
|
goal?: string;
|
|
143
143
|
context?: string;
|
|
144
|
+
topic?: string;
|
|
144
145
|
};
|
|
145
146
|
type TelemVercelFetchInput = {
|
|
146
147
|
url: string;
|
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` fills it. */
|
|
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` passes its parent's, so a 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
|
};
|
|
@@ -141,6 +141,7 @@ type TelemVercelSearchInput = {
|
|
|
141
141
|
query: string;
|
|
142
142
|
goal?: string;
|
|
143
143
|
context?: string;
|
|
144
|
+
topic?: string;
|
|
144
145
|
};
|
|
145
146
|
type TelemVercelFetchInput = {
|
|
146
147
|
url: string;
|
package/dist/vercel/index.js
CHANGED
|
@@ -311,6 +311,10 @@ var SEARCH_SCHEMA = jsonSchema({
|
|
|
311
311
|
context: {
|
|
312
312
|
type: "string",
|
|
313
313
|
description: "Two or three sentences of your reasoning: what you want to find out and why, given what you already know. Not a restatement of the query."
|
|
314
|
+
},
|
|
315
|
+
topic: {
|
|
316
|
+
type: "string",
|
|
317
|
+
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."
|
|
314
318
|
}
|
|
315
319
|
},
|
|
316
320
|
required: ["query"],
|
|
@@ -401,7 +405,7 @@ function createTelemVercelAgent(options) {
|
|
|
401
405
|
const opts = { ...searchOptions ?? {}, signal: signalFor(execution, searchOptions?.signal) };
|
|
402
406
|
const { envelope, plan } = await lineage(execution, {
|
|
403
407
|
name: SEARCH_TOOL,
|
|
404
|
-
input: { query, goal: opts.goal, context: opts.context }
|
|
408
|
+
input: { query, goal: opts.goal, context: opts.context, topic: opts.topic }
|
|
405
409
|
});
|
|
406
410
|
const response = await state.sendWithOmissionRetry(
|
|
407
411
|
plan,
|
|
@@ -460,7 +464,12 @@ function createTelemVercelAgent(options) {
|
|
|
460
464
|
telem_search: {
|
|
461
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.",
|
|
462
466
|
inputSchema: SEARCH_SCHEMA,
|
|
463
|
-
execute: async (input, execution) =>
|
|
467
|
+
execute: async (input, execution) => {
|
|
468
|
+
const topic = input.topic?.trim() || void 0;
|
|
469
|
+
return renderSearch(
|
|
470
|
+
await search(input.query, { goal: input.goal, context: input.context, topic }, execution)
|
|
471
|
+
);
|
|
472
|
+
}
|
|
464
473
|
},
|
|
465
474
|
telem_fetch: {
|
|
466
475
|
description: "Read the text of one web page by URL. telem_search returns snippets; this returns the page.",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telemai/sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Telem web search and fetch for JavaScript and TypeScript.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -42,10 +42,14 @@
|
|
|
42
42
|
"node": ">=20.16"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
|
-
"
|
|
45
|
+
"pretest": "npm run build",
|
|
46
|
+
"test": "node --test 'test/**/*.test.ts'",
|
|
46
47
|
"typecheck": "tsc --noEmit",
|
|
48
|
+
"gen-version": "node scripts/gen-version.mjs",
|
|
49
|
+
"prebuild": "node scripts/gen-version.mjs",
|
|
50
|
+
"build": "tsup",
|
|
47
51
|
"prepack": "npm run build",
|
|
48
|
-
"
|
|
52
|
+
"smoke:vercel": "node scripts/vercel-live.mjs"
|
|
49
53
|
},
|
|
50
54
|
"devDependencies": {
|
|
51
55
|
"@types/node": "^22.20.1",
|
|
@@ -67,13 +71,5 @@
|
|
|
67
71
|
"./dist/vercel/index.d.ts"
|
|
68
72
|
]
|
|
69
73
|
}
|
|
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"
|
|
78
74
|
}
|
|
79
75
|
}
|