@stackfactor/agent-utils 1.11.0 → 1.13.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.
@@ -17,6 +17,8 @@ export interface KnowledgeChunk {
17
17
  knowledgeBaseId?: string;
18
18
  documentId: string;
19
19
  documentName?: string | null;
20
+ /** The title taken from the document itself (its front matter or first heading); null when it has none. */
21
+ documentTitle?: string | null;
20
22
  /** The document's page at its source (sent by the platform's search since backend-core #630). */
21
23
  documentUrl?: string | null;
22
24
  sectionTitle?: string | null;
@@ -50,6 +52,8 @@ export interface GroundingPassage {
50
52
  knowledgeBaseId: string;
51
53
  documentId: string;
52
54
  documentName: string | null;
55
+ /** The title taken from the document itself; null when it has none. */
56
+ documentTitle?: string | null;
53
57
  /** The document's page at its source, an http(s) address; null when the platform has none. */
54
58
  documentUrl?: string | null;
55
59
  sectionTitle: string | null;
@@ -67,7 +71,10 @@ export interface SkippedSource {
67
71
  knowledgeBaseId: string;
68
72
  /** The HTTP status, when the platform answered one. */
69
73
  status: number | null;
70
- /** True when the person may not read it (or it is gone): expected, not a fault. */
74
+ /**
75
+ * True when the platform refused the person (401, 403) or does not have the
76
+ * knowledge base (404); false when the search failed otherwise.
77
+ */
71
78
  noAccess: boolean;
72
79
  message: string;
73
80
  }
@@ -86,6 +93,8 @@ export interface StackFactorReference {
86
93
  knowledgeBase: {
87
94
  knowledgeBaseId: string;
88
95
  documentId: string;
96
+ /** The document's name at its source (GitHub: `<repo>/<path>`); absent when the passage has none. */
97
+ documentName?: string;
89
98
  chunkId: string;
90
99
  sectionTitle: string | null;
91
100
  };
@@ -116,9 +125,11 @@ export declare const sourcesFromCoverage: (coverage: unknown) => KnowledgeSource
116
125
  * model to cite. A source with documents is searched within them (in batches of
117
126
  * SEARCH_DOCUMENT_IDS_MAX); one without, whole. A source the person may not
118
127
  * read (401, 403, 404) is skipped: none of its passages are used and no more of
119
- * its searches are made. A search that fails otherwise is reported and the
120
- * passages its other searches found stand. Either way it is in `skipped`, once
121
- * per knowledge base, and the passages of the others stand.
128
+ * its searches are made. A search that fails otherwise is tried once more; when
129
+ * that fails too it is reported and the passages its other searches found
130
+ * stand. A refusal is never tried again. Either way it is in `skipped`, once
131
+ * per knowledge base, and the passages of the others stand; whether a skip is
132
+ * an error is the caller's to say.
122
133
  * @param options `sources`, `queries`, `search` (client-api
123
134
  * `knowledgeBaseAgent.search`), `token` (the run's AGENT token), `topK`
124
135
  * per search (default DEFAULT_TOP_K)
@@ -149,7 +160,9 @@ export declare const passagesForPrompt: (passages: GroundingPassage[]) => {
149
160
  * STACKFACTOR references for passages: one per passage, in their order, with no
150
161
  * cap. With `tags`, only the passages the model cited by tag (any tag it made
151
162
  * up is passed over); without, every passage. Each links to its document's
152
- * page at the source (`url`) when the passage has one.
163
+ * page at the source (`url`) when the passage has one. Each is titled by its
164
+ * document's title, else its name, else its section; its pointer keeps the
165
+ * document's name (`knowledgeBase.documentName`) when the passage has one.
153
166
  * @param passages From `retrievePassages`
154
167
  * @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
155
168
  * @returns The references, ready for a skill's, a microskill's or a question's `references`
@@ -1 +1 @@
1
- {"version":3,"file":"stackfactorKnowledge.d.ts","sourceRoot":"","sources":["../../src/stackfactorKnowledge.ts"],"names":[],"mappings":"AAgCA,kGAAkG;AAClG,eAAO,MAAM,qBAAqB;;;;;EAKhC,CAAC;AAEH,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB,MAAM,CAAC;AAE3C,0EAA0E;AAC1E,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAErC,0EAA0E;AAC1E,eAAO,MAAM,aAAa,IAAI,CAAC;AAQ/B,iFAAiF;AACjF,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAC;IACZ,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,iGAAi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,gBAAgB,EAAE,EAC5B,OAAO,OAAO,EAAE,KACf,oBAAoB,EA+BtB,CAAC;;;;;;;;;;;kCAtDU,gBAAgB,EAAE,KAC3B;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAAE;8BAoBvE,gBAAgB,EAAE,SACrB,OAAO,EAAE,KACf,oBAAoB,EAAE;gCAhIuB;QAC9C,OAAO,EAAE,eAAe,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;QAClB,MAAM,EAAE,eAAe,CAAC;QACxB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,KAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC;QAAC,OAAO,EAAE,aAAa,EAAE,CAAA;KAAE,CAAC;oCAjEzB,OAAO,KAAG,eAAe,EAAE;wCA5BvB,OAAO,KAAG,eAAe,EAAE;;AAwP7E,wBAUE"}
@@ -15,13 +15,19 @@
15
15
  // microskill;
16
16
  // - access: the platform's search judges the person the run acts for, so a
17
17
  // run reads only what that person may open. A knowledge base the person
18
- // cannot read is skipped and reported, never an error: the agent
19
- // generates without it.
18
+ // cannot read is skipped and reported (`retrievePassages`): grounding from
19
+ // skill coverage generates without it. A knowledge base that references
20
+ // cite is another matter (Candin, 2026-10-13): the references reader
21
+ // (referenceContext `gatherReferenceContext`) stops the run with a
22
+ // KnowledgeAccessError instead.
20
23
  //
21
24
  // A reference points at the content and never copies it: the passage is
22
25
  // searched again, under the reader's own access, whenever it is used. Its
23
26
  // `url` is the document's page at its source (GitHub, Confluence…), when the
24
- // platform knows it, so a person can open what was cited. It is
27
+ // platform knows it, so a person can open what was cited. Its title is the
28
+ // title taken from the document itself, when ingestion found one, and its
29
+ // pointer keeps the document's name at the source (`documentName`), so a
30
+ // person can still see where the titled document lives. It is
25
31
  // EDIT-only (`visibility: "EDIT"`): the platform strips it from what is
26
32
  // published, so a knowledge base's titles never reach a learner; agents read
27
33
  // it from the draft.
@@ -49,6 +55,8 @@ exports.DEFAULT_TOP_K = 8;
49
55
  const CONCURRENCY = 4;
50
56
  /** Statuses that mean the person may not read the knowledge base, or it is gone. */
51
57
  const NO_ACCESS = new Set([401, 403, 404]);
58
+ /** How long a search that failed for another reason waits before it is tried once more. */
59
+ const RETRY_DELAY_MS = 200;
52
60
  const text = (value) => (typeof value === "string" ? value.trim() : "");
53
61
  /** An http(s) address, or null: a reference's url lands in an `href`. */
54
62
  const webUrl = (value) => (/^https?:\/\//i.test(text(value)) ? text(value) : null);
@@ -130,15 +138,18 @@ const statusOf = (error) => {
130
138
  const status = error?.response?.status ?? error?.status;
131
139
  return typeof status === "number" ? status : null;
132
140
  };
141
+ const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
133
142
  /**
134
143
  * Searches every source for every query, under the person's access, and hands
135
144
  * back the passages found, best first, each once, tagged "k1", "k2"… for the
136
145
  * model to cite. A source with documents is searched within them (in batches of
137
146
  * SEARCH_DOCUMENT_IDS_MAX); one without, whole. A source the person may not
138
147
  * read (401, 403, 404) is skipped: none of its passages are used and no more of
139
- * its searches are made. A search that fails otherwise is reported and the
140
- * passages its other searches found stand. Either way it is in `skipped`, once
141
- * per knowledge base, and the passages of the others stand.
148
+ * its searches are made. A search that fails otherwise is tried once more; when
149
+ * that fails too it is reported and the passages its other searches found
150
+ * stand. A refusal is never tried again. Either way it is in `skipped`, once
151
+ * per knowledge base, and the passages of the others stand; whether a skip is
152
+ * an error is the caller's to say.
142
153
  * @param options `sources`, `queries`, `search` (client-api
143
154
  * `knowledgeBaseAgent.search`), `token` (the run's AGENT token), `topK`
144
155
  * per search (default DEFAULT_TOP_K)
@@ -167,8 +178,24 @@ const retrievePassages = async (options) => {
167
178
  await inPool(searches, CONCURRENCY, async ({ source, query, documentIds, order }) => {
168
179
  if (skipped.get(source.knowledgeBaseId)?.noAccess)
169
180
  return;
181
+ const searchOnce = () => options.search(source.knowledgeBaseId, query, documentIds ? { topK, documentIds } : { topK }, options.token);
170
182
  try {
171
- const answer = await options.search(source.knowledgeBaseId, query, documentIds ? { topK, documentIds } : { topK }, options.token);
183
+ let answer;
184
+ try {
185
+ answer = await searchOnce();
186
+ }
187
+ catch (error) {
188
+ // A refusal is the platform's answer and is not asked again. Any other
189
+ // failure may pass (a dropped connection, a 5xx), and one failed search
190
+ // would skip its whole knowledge base, so it is tried once more —
191
+ // unless the base refused the person meanwhile.
192
+ if (NO_ACCESS.has(statusOf(error)))
193
+ throw error;
194
+ await delay(RETRY_DELAY_MS);
195
+ if (skipped.get(source.knowledgeBaseId)?.noAccess)
196
+ return;
197
+ answer = await searchOnce();
198
+ }
172
199
  (Array.isArray(answer?.chunks) ? answer.chunks : []).forEach((chunk, rank) => {
173
200
  const chunkId = id(chunk?._id);
174
201
  if (!chunkId || !id(chunk?.documentId))
@@ -204,6 +231,7 @@ const retrievePassages = async (options) => {
204
231
  chunkId,
205
232
  documentId: id(chunk.documentId),
206
233
  documentName: text(chunk.documentName) || null,
234
+ documentTitle: text(chunk.documentTitle) || null,
207
235
  documentUrl: webUrl(chunk.documentUrl),
208
236
  knowledgeBaseId: id(chunk.knowledgeBaseId) || knowledgeBaseId,
209
237
  pageNumber: typeof chunk.pageNumber === "number" ? chunk.pageNumber : null,
@@ -235,7 +263,9 @@ exports.passagesForPrompt = passagesForPrompt;
235
263
  * STACKFACTOR references for passages: one per passage, in their order, with no
236
264
  * cap. With `tags`, only the passages the model cited by tag (any tag it made
237
265
  * up is passed over); without, every passage. Each links to its document's
238
- * page at the source (`url`) when the passage has one.
266
+ * page at the source (`url`) when the passage has one. Each is titled by its
267
+ * document's title, else its name, else its section; its pointer keeps the
268
+ * document's name (`knowledgeBase.documentName`) when the passage has one.
239
269
  * @param passages From `retrievePassages`
240
270
  * @param tags The tags the model cited ("k3", "K3" and " k3 " alike)
241
271
  * @returns The references, ready for a skill's, a microskill's or a question's `references`
@@ -249,12 +279,14 @@ const referencesFor = (passages, tags) => {
249
279
  .filter((passage) => !cited || cited.has(passage.tag.toLowerCase()))
250
280
  .map((passage) => {
251
281
  const url = webUrl(passage.documentUrl);
282
+ const documentName = text(passage.documentName);
252
283
  return {
253
284
  description: passage.sectionTitle,
254
285
  kind: exports.STACKFACTOR_REFERENCE.KIND,
255
286
  knowledgeBase: {
256
287
  chunkId: passage.chunkId,
257
288
  documentId: passage.documentId,
289
+ ...(documentName ? { documentName } : {}),
258
290
  knowledgeBaseId: passage.knowledgeBaseId,
259
291
  sectionTitle: passage.sectionTitle,
260
292
  },
@@ -264,7 +296,7 @@ const referencesFor = (passages, tags) => {
264
296
  elementType: exports.STACKFACTOR_REFERENCE.TARGET_ELEMENT_TYPE,
265
297
  parentId: passage.knowledgeBaseId,
266
298
  },
267
- title: passage.documentName || passage.sectionTitle || "Knowledge base document",
299
+ title: text(passage.documentTitle) || documentName || passage.sectionTitle || "Knowledge base document",
268
300
  ...(url ? { url } : {}),
269
301
  visibility: exports.STACKFACTOR_REFERENCE.VISIBILITY,
270
302
  };
@@ -46,6 +46,14 @@ export type TavilyConfig = {
46
46
  * for the tabular documents this is usually pointed at.
47
47
  */
48
48
  format?: "markdown" | "text";
49
+ /**
50
+ * The only URLs `web_extract` may read (matched trimmed, without case or a
51
+ * trailing slash, and sent as listed). Any other URL is never sent to
52
+ * Tavily: the tool answers the model with an error line for it and never
53
+ * throws. Unset, any URL may be read. Only `web_extract` reads it, so a run
54
+ * kept to its pages enables `extract` alone (referenceContext `toolsFor`).
55
+ */
56
+ allowedUrls?: string[];
49
57
  };
50
58
  /**
51
59
  * Normalizes `config.tavily` into an options object, returning `null` when the
@@ -1 +1 @@
1
- {"version":3,"file":"tavily.d.ts","sourceRoot":"","sources":["../../src/tavily.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAg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E,MAAM,CAAA;KAAE,EAAE,KACzC,IAAI;;AA8hBP,wBAME"}
@@ -60,6 +60,10 @@ const assertTavilyUsable = (config, options) => {
60
60
  if (!config?.tavilyAPIKey) {
61
61
  throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.INTERNAL_SERVER_ERROR, "Tavily tools are enabled but config.tavilyAPIKey is missing.");
62
62
  }
63
+ if (options.allowedUrls !== undefined &&
64
+ !(Array.isArray(options.allowedUrls) && options.allowedUrls.every((url) => typeof url === "string"))) {
65
+ throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.BAD_REQUEST, "config.tavily.allowedUrls must be a list of URLs.");
66
+ }
63
67
  const unknown = (options.tools || []).filter((name) => !["search", "extract", "crawl", "map"].includes(name));
64
68
  if (unknown.length > 0) {
65
69
  throw errorHandling_js_1.default.create(const_js_1.default.HTTP_CODES.BAD_REQUEST, `Unknown Tavily tool(s): ${unknown.join(", ")}. Valid values are search, extract, crawl, map.`);
@@ -168,6 +172,52 @@ const recordTavilyUsage = (tracker, _config, credits, sources) => {
168
172
  }
169
173
  }
170
174
  };
175
+ /**
176
+ * Adds the URLs `web_extract` is about to ask Tavily for to
177
+ * `tracker.attemptedUrls`, each once across the run. Recorded before the call,
178
+ * so a URL the call then fails on is still there.
179
+ * @param tracker - The caller's usage accumulator, when it passed one
180
+ * @param urls - The URLs sent
181
+ */
182
+ const recordAttemptedUrls = (tracker, urls) => {
183
+ if (!tracker || urls.length === 0)
184
+ return;
185
+ const attempted = tracker.attemptedUrls || (tracker.attemptedUrls = []);
186
+ for (const url of urls) {
187
+ if (!attempted.includes(url))
188
+ attempted.push(url);
189
+ }
190
+ };
191
+ /**
192
+ * How a URL is matched, against Tavily's answer or `allowedUrls`: trimmed,
193
+ * lowercased, no trailing slash.
194
+ */
195
+ const urlMatchKey = (url) => url.trim().replace(/\/+$/, "").toLowerCase();
196
+ /** What `web_extract` answers for each URL `allowedUrls` refused. */
197
+ const REFUSED_HEADING = "Refused, not read (only the referenced pages may be read):";
198
+ /**
199
+ * Splits the URLs the model asked `web_extract` for into those it may read —
200
+ * as `allowedUrls` lists them — and those it may not, each once. With no
201
+ * `allowedUrls`, every URL may be read, as asked.
202
+ * @param urls - The URLs the model asked for
203
+ * @param allowed - `allowedUrls` by match key, or `null` when unset
204
+ */
205
+ const screenUrls = (urls, allowed) => {
206
+ if (!allowed)
207
+ return { read: urls, refused: [] };
208
+ const read = [];
209
+ const refused = [];
210
+ for (const url of urls) {
211
+ const listed = allowed.get(urlMatchKey(url));
212
+ if (listed === undefined) {
213
+ if (!refused.includes(url))
214
+ refused.push(url);
215
+ }
216
+ else if (!read.includes(listed))
217
+ read.push(listed);
218
+ }
219
+ return { read, refused };
220
+ };
171
221
  /**
172
222
  * Trims one document to whatever the per-URL and per-call budgets allow,
173
223
  * appending a note when anything was cut.
@@ -238,6 +288,9 @@ const buildTavilyTools = (config, options, usageTracker = null) => {
238
288
  const maxCharsPerUrl = options.maxCharsPerUrl ?? DEFAULT_MAX_CHARS_PER_URL;
239
289
  const maxCharsTotal = options.maxCharsTotal ?? DEFAULT_MAX_CHARS_TOTAL;
240
290
  const crawlLimit = options.crawlLimit ?? DEFAULT_CRAWL_LIMIT;
291
+ const allowed = Array.isArray(options.allowedUrls)
292
+ ? new Map(options.allowedUrls.map((url) => [urlMatchKey(url), url.trim()]))
293
+ : null;
241
294
  const newBudget = () => ({
242
295
  remaining: maxCharsTotal,
243
296
  perUrl: maxCharsPerUrl,
@@ -285,8 +338,22 @@ const buildTavilyTools = (config, options, usageTracker = null) => {
285
338
  }
286
339
  if (enabled.includes("extract")) {
287
340
  tools.push((0, langchain_1.tool)(async ({ urls, query }) => {
341
+ // Outside `allowedUrls` nothing is sent: the model is told per URL,
342
+ // and the run goes on with what it may read.
343
+ const { read, refused } = screenUrls(urls, allowed);
344
+ const refusal = refused.length
345
+ ? `${REFUSED_HEADING}\n${refused
346
+ .map((url) => `- ${url}: not one of the referenced pages`)
347
+ .join("\n")}`
348
+ : "";
349
+ if (refused.length > 0) {
350
+ logger_js_1.default.log(null, logger_js_1.default.levels.warn, `Tavily extract refused ${refused.length} URL(s) not among the allowed pages: ${refused.join(", ")}`);
351
+ }
352
+ if (read.length === 0)
353
+ return refusal;
354
+ recordAttemptedUrls(usageTracker, read);
288
355
  const data = await callTavily("extract", {
289
- urls,
356
+ urls: read,
290
357
  extract_depth: options.extractDepth,
291
358
  format,
292
359
  // `query` switches the API from whole-document extraction to
@@ -317,10 +384,14 @@ const buildTavilyTools = (config, options, usageTracker = null) => {
317
384
  .join("\n");
318
385
  rendered += `\n\n---\n\nFailed to extract:\n${lines}`;
319
386
  }
387
+ if (refusal)
388
+ rendered += `\n\n---\n\n${refusal}`;
320
389
  return rendered;
321
390
  }, {
322
391
  name: "web_extract",
323
- description: "Read the content of specific URLs. Pass a query to get back only the passages relevant to it — much cheaper and usually sufficient. Omit the query to retrieve the whole document, which is appropriate when you need its full structure. Long documents are truncated, and the result says so when that happens.",
392
+ description: `Read the content of specific URLs. Pass a query to get back only the passages relevant to it — much cheaper and usually sufficient. Omit the query to retrieve the whole document, which is appropriate when you need its full structure. Long documents are truncated, and the result says so when that happens.${allowed
393
+ ? " Only the referenced pages can be read; any other URL is refused."
394
+ : ""}`,
324
395
  schema: zod_1.z.object({
325
396
  urls: zod_1.z
326
397
  .array(zod_1.z.string())
@@ -399,8 +470,6 @@ exports.buildTavilyTools = buildTavilyTools;
399
470
  const EXTRACT_MAX_URLS = 20;
400
471
  /** Seconds. A reachability check needs the page fetched, not rendered at length. */
401
472
  const REACHABILITY_TIMEOUT_SECONDS = 20;
402
- /** How a URL is matched against Tavily's answer: trimmed, lowercased, no trailing slash. */
403
- const urlMatchKey = (url) => url.trim().replace(/\/+$/, "").toLowerCase();
404
473
  /** True for an `http:` or `https:` URL; false for anything else, unparsable included. */
405
474
  const isWebUrl = (url) => {
406
475
  try {
@@ -7,7 +7,7 @@ import { callAgent, checkAgent } from "./client.js";
7
7
  import * as runtimeContext from "./runtimeContext.js";
8
8
  import { recordUsage, USAGE_UNITS } from "./usage.js";
9
9
  import stackfactorKnowledge from "./stackfactorKnowledge.js";
10
- import referenceContext from "./referenceContext.js";
10
+ import referenceContext, { KnowledgeAccessError } from "./referenceContext.js";
11
11
  import { checkUrlsReachable } from "./tavily.js";
12
12
  export { constants };
13
13
  export { errorHandling, AppError };
@@ -24,7 +24,7 @@ export type { AgentExecuteRequest, CallAgentOptions, CheckAgentOptions, AgentHea
24
24
  export { runtimeContext };
25
25
  export { recordUsage, USAGE_UNITS };
26
26
  export type { UsageEntry, UsageUnit } from "./usage.js";
27
- export { stackfactorKnowledge, referenceContext };
27
+ export { stackfactorKnowledge, referenceContext, KnowledgeAccessError };
28
28
  export type { GroundingPassage, KnowledgeChunk, KnowledgeSearch, KnowledgeSource, SkippedSource, StackFactorReference, } from "./stackfactorKnowledge.js";
29
29
  export type { ReferenceContext, ReferencePage, ReferencePassage, SourceGuidance, StoredReference, } from "./referenceContext.js";
30
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,SAAS,MAAM,gBAAgB,CAAC;AACvC,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,oBAAoB,MAAM,2BAA2B,CAAC;AAC7D,OAAO,gBAAgB,MAAM,uBAAuB,CAAC;AACrD,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AC;AAExD,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,CAAC;AAExE,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,oBAAoB,GACrB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,eAAe,GAChB,MAAM,uBAAuB,CAAC"}
package/dist/esm/index.js CHANGED
@@ -7,7 +7,7 @@ import { callAgent, checkAgent } from "./client.js";
7
7
  import * as runtimeContext from "./runtimeContext.js";
8
8
  import { recordUsage, USAGE_UNITS } from "./usage.js";
9
9
  import stackfactorKnowledge from "./stackfactorKnowledge.js";
10
- import referenceContext from "./referenceContext.js";
10
+ import referenceContext, { KnowledgeAccessError } from "./referenceContext.js";
11
11
  import { checkUrlsReachable } from "./tavily.js";
12
12
  export { constants };
13
13
  export { errorHandling, AppError };
@@ -19,4 +19,4 @@ export { callAgent };
19
19
  export { checkAgent };
20
20
  export { runtimeContext };
21
21
  export { recordUsage, USAGE_UNITS };
22
- export { stackfactorKnowledge, referenceContext };
22
+ export { stackfactorKnowledge, referenceContext, KnowledgeAccessError };
@@ -31,6 +31,14 @@ export type UsageTracker = {
31
31
  url: string;
32
32
  title?: string;
33
33
  }[];
34
+ /**
35
+ * Every URL `web_extract` asked Tavily for, each once, in the order first
36
+ * asked, whether Tavily could read it or not (a failed URL, a failed call).
37
+ * A URL refused by `allowedUrls` was never asked for and is not here. What
38
+ * Tavily answered is `webSearchSources`, under the address it answered with
39
+ * (after a redirect); this is what the run actually tried to read.
40
+ */
41
+ attemptedUrls?: string[];
34
42
  };
35
43
  /**
36
44
  * Instantiates and returns the appropriate LangChain chat model based on the model
@@ -1 +1 @@
1
- {"version":3,"file":"langChain.d.ts","sourceRoot":"","sources":["../../src/langChain.ts"],"names":[],"mappings":"AAoGA,KAAK,UAAU,GAAG;IAChB,YAAY,EAAE,MAAM,CAA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Y,GAAG,IAAI,GAAG,SAAS,aAC7B,MAAM,WACR,MAAM,YACL,GAAG,KACZ,IAAI;mCAyuBU,MAAM,mBACJ,MAAM,EAAE,KACxB,MAAM;;AA48CT,wBAkBE"}
@@ -1203,8 +1203,9 @@ const parseAgenticJsonResponse = (rawContent, schema) => {
1203
1203
  *
1204
1204
  * Setting `config.tavily` adds the Tavily web tools (`web_search`, `web_extract`, and
1205
1205
  * optionally `web_map` / `web_crawl`). They execute in this process, so they require
1206
- * `config.agentic` to be `true`; the credits spent and the URLs returned are recorded
1207
- * on `usageTracker`.
1206
+ * `config.agentic` to be `true`; the credits spent, the URLs returned and the URLs
1207
+ * `web_extract` asked for are recorded on `usageTracker`. `tavily.allowedUrls` keeps
1208
+ * `web_extract` to those URLs.
1208
1209
  * @param modelName - The model identifier, e.g. `"gpt-4o"`, `"claude-3-5-sonnet"`,
1209
1210
  * `"gemini-1.5-pro"`
1210
1211
  * @param config - Configuration object with API keys, `temperature`, optional `agentic`
@@ -10,7 +10,10 @@ export interface ReferencePage {
10
10
  }
11
11
  /** A passage of a document that references cite. */
12
12
  export interface ReferencePassage {
13
- /** The short ids of every STACKFACTOR reference that cites this passage's document. */
13
+ /**
14
+ * The short ids of the STACKFACTOR references that cite this passage's chunk
15
+ * (`knowledgeBase.chunkId`); when none does, of every one citing its document.
16
+ */
14
17
  references: string[];
15
18
  document: string | null;
16
19
  section: string | null;
@@ -23,21 +26,56 @@ export interface ReferencePassage {
23
26
  export interface ReferenceContext {
24
27
  pages: ReferencePage[];
25
28
  passages: ReferencePassage[];
29
+ /**
30
+ * Always empty from `gatherReferenceContext`: a cited knowledge base that
31
+ * cannot be read throws KnowledgeAccessError, which carries the skips.
32
+ */
26
33
  skipped: SkippedSource[];
27
- /** True when the references cite at least one knowledge base document, whether or not it could be read. */
34
+ /** True when the references cite at least one knowledge base document (all of them readable, or it would have thrown). */
28
35
  citesKnowledge: boolean;
29
36
  }
37
+ /**
38
+ * The knowledge base documents a run's references cite could not be read: the
39
+ * run has no token, the person may not open a cited knowledge base (401, 403,
40
+ * 404), or its search failed. The agent answers with it — `code` and `message`
41
+ * are what the person sees — and generates nothing.
42
+ */
43
+ export declare class KnowledgeAccessError extends Error {
44
+ /** 403 when every skipped knowledge base refused the person (or there was no token), else 502. */
45
+ readonly code: 403 | 502;
46
+ /** The knowledge bases that could not be searched, and why; empty when there was no token. */
47
+ readonly skipped: SkippedSource[];
48
+ /** The titles of the STACKFACTOR references citing those knowledge bases, each once. */
49
+ readonly documents: string[];
50
+ /**
51
+ * @param details `skipped` (from the search) and `documents` (titles); the
52
+ * code and the message follow from them
53
+ */
54
+ constructor(details?: {
55
+ skipped?: SkippedSource[];
56
+ documents?: unknown[];
57
+ });
58
+ }
30
59
  /**
31
60
  * What a list of references points at: its pages, and the passages of the
32
61
  * documents its STACKFACTOR references cite. One search per knowledge base per
33
- * query (per batch of 500 documents), however many references there are. With
34
- * no token no search is made and the pages are still listed. A knowledge base
35
- * the person cannot open is in `skipped`; the other passages stand.
62
+ * query (per batch of 500 documents), however many references there are.
63
+ *
64
+ * References that cite a knowledge base the run cannot read stop it: with no
65
+ * token, or when any cited knowledge base is skipped (refused or failed), it
66
+ * throws a KnowledgeAccessError naming the documents. A search that works and
67
+ * finds nothing is not an error. With no knowledge cited, no token is needed.
68
+ *
69
+ * A passage is attributed to the references citing its chunk, else to every
70
+ * reference citing its document. The best-ranked `maxPassages` are kept, and
71
+ * the first `maxPages` pages in reference order.
36
72
  * @param options `references` (a skill's, a microskill's…), `queries` to
37
73
  * search the cited documents with, `search` (client-api
38
74
  * `knowledgeBaseAgent.search`), `token` (the run's AGENT token), `topK` per
39
- * search (default 5)
40
- * @returns `{ pages, passages, skipped, citesKnowledge }`
75
+ * search (default 5), `maxPassages` (default 40), `maxPages` (default: all)
76
+ * @returns `{ pages, passages, skipped, citesKnowledge }`; `skipped` is always
77
+ * empty, since a skip throws
78
+ * @throws KnowledgeAccessError When cited knowledge bases cannot be read
41
79
  */
42
80
  export declare const gatherReferenceContext: (options: {
43
81
  references: unknown;
@@ -45,6 +83,8 @@ export declare const gatherReferenceContext: (options: {
45
83
  search: KnowledgeSearch;
46
84
  token: string | null | undefined;
47
85
  topK?: number;
86
+ maxPassages?: number;
87
+ maxPages?: number;
48
88
  }) => Promise<ReferenceContext>;
49
89
  /**
50
90
  * The passages as a prompt shows them: who cites each, where it came from, and
@@ -86,29 +126,33 @@ export interface StoredReference {
86
126
  knowledgeBase?: {
87
127
  knowledgeBaseId: string;
88
128
  documentId: string;
129
+ documentName?: string;
89
130
  chunkId?: string;
90
131
  sectionTitle?: string | null;
91
132
  };
92
133
  }
93
134
  /**
94
135
  * The tools a run is given. Never `search`, `map` or `crawl`: a run reads what
95
- * its references point at and discovers nothing. `extract` only, and only when
96
- * there are pages to open.
136
+ * its references point at and discovers nothing. `extract` only, only when
137
+ * there are pages to open, and kept to those pages: any other url the model
138
+ * asks for is refused (`allowedUrls`).
97
139
  * @param context From `gatherReferenceContext`
98
- * @returns `{ tavily: { tools: ["extract"] } }` with pages, else `{}`. With no
99
- * pages it returns `{}`, so a caller spreading it over a config that already
100
- * has a `tavily` key keeps that key (and `tavily: true` means search plus
101
- * extract): callers must not carry a base `tavily` key.
140
+ * @returns `{ tavily: { tools: ["extract"], allowedUrls } }` with pages, else
141
+ * `{}`. With no pages it returns `{}`, so a caller spreading it over a config
142
+ * that already has a `tavily` key keeps that key (and `tavily: true` means
143
+ * search plus extract): callers must not carry a base `tavily` key.
102
144
  */
103
145
  export declare const toolsFor: (context: ReferenceContext) => {
104
146
  tavily?: {
105
147
  tools: string[];
148
+ allowedUrls: string[];
106
149
  };
107
150
  };
108
151
  /**
109
152
  * The stage prompt followed by the guidance for each kind of source the run
110
- * has: pages, then passages; when it has neither, the `none` guidance. An empty
111
- * guidance adds nothing.
153
+ * has: pages, then passages; when it has neither (knowledge cited and readable
154
+ * but no passage found included), the `none` guidance. An empty guidance adds
155
+ * nothing.
112
156
  * @param stagePrompt The stage's own prompt
113
157
  * @param context From `gatherReferenceContext`
114
158
  * @param guidance From `sourceGuidanceFrom`
@@ -159,6 +203,7 @@ export declare const citedReferences: (ids: unknown, supplied: unknown, origin?:
159
203
  */
160
204
  export declare const sourceGuidanceFrom: (config: Record<string, unknown>) => SourceGuidance;
161
205
  declare const _default: {
206
+ KnowledgeAccessError: typeof KnowledgeAccessError;
162
207
  REFERENCE_PASSAGES_KEY: string;
163
208
  citedReferences: (ids: unknown, supplied: unknown, origin?: string) => StoredReference[];
164
209
  composeSourceInstructions: (stagePrompt: string, context: ReferenceContext, guidance: SourceGuidance) => string;
@@ -168,6 +213,8 @@ declare const _default: {
168
213
  search: KnowledgeSearch;
169
214
  token: string | null | undefined;
170
215
  topK?: number;
216
+ maxPassages?: number;
217
+ maxPages?: number;
171
218
  }) => Promise<ReferenceContext>;
172
219
  referenceForModel: <T extends {
173
220
  kind?: string;
@@ -184,6 +231,7 @@ declare const _default: {
184
231
  toolsFor: (context: ReferenceContext) => {
185
232
  tavily?: {
186
233
  tools: string[];
234
+ allowedUrls: string[];
187
235
  };
188
236
  };
189
237
  };
@@ -1 +1 @@
1
- {"version":3,"file":"referenceContext.d.ts","sourceRoot":"","sources":["../../src/referenceContext.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,eAAe,EACf,aAAa,EAId,MAAM,2BAA2B,CAAC;AAKnC,iEAAiE;AACjE,eAAO,MAAM,sBAAsB,4BAA4B,CAAC;AAEhE,uDAAuD;AACvD,MAAM,WAAW,aAAa;IAC5B,sCAAsC;IACtC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED,oDAAoD;AACpD,MAAM,WAAW,gBAAgB;IAC/B,uFAAuF;IACvF,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,IAAI,EAAE,MAA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