@howells/fieldwork-sdk 0.12.0 → 0.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.
@@ -1,10 +1,10 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
- import { i as enclosing, n as documentPart, o as refuseLarger, r as documentUrl } from "./document-BSCwJgBM.js";
3
+ import { i as enclosing, n as documentPart, o as refuseLarger, r as documentUrl } from "./document-x9fWsQ1W.js";
3
4
  import { t as FieldworkError } from "./errors-gpxg6Tnh.js";
4
- import { O as withOriginal, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, n as readSigned, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-CJcvTPnE.js";
5
- import { i as startJob, r as runJob, t as jobState } from "./job-JLEpszjr.js";
6
- import { a as compact, c as parseJson, s as meta, t as callSettings } from "./util-LvME_uOj.js";
7
- import * as z$1 from "zod/mini";
5
+ import { O as withOriginal, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, n as readSigned, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-Bg0h3D-t.js";
6
+ import { i as startJob, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
7
+ import { a as compact, c as parseJson, s as meta, t as callSettings } from "./util-BOqd71Om.js";
8
8
  // src/adapters/llamaparse/response.ts
9
9
  /** A box in page points, from the page's top-left corner. */
10
10
  const PointBox = looseObject({
@@ -16,17 +16,17 @@ const PointBox = looseObject({
16
16
  /** A word or a line: `span` is `[start, end)` in UTF-8 bytes of its item's `md`, or of its cell's text in a table. */
17
17
  const Word = looseObject({
18
18
  bbox: PointBox,
19
- span: arrayOf(z$1.number())
19
+ span: arrayOf(z.number())
20
20
  });
21
21
  const Line = looseObject({
22
22
  bbox: PointBox,
23
- span: arrayOf(z$1.number()),
23
+ span: arrayOf(z.number()),
24
24
  words: arrayOf(Word)
25
25
  });
26
- const OneBox = z$1.record(z$1.string(), z$1.unknown());
26
+ const OneBox = z.record(z.string(), z.unknown());
27
27
  const BoxList = arrayOf(PointBox);
28
28
  /** A list of boxes; one box on its own reads as a list of one, and anything else as none. */
29
- const PointBoxes = z$1.prefault(z$1.pipe(z$1.unknown(), z$1.transform((value) => z$1.parse(BoxList, z$1.safeParse(OneBox, value).success ? [value] : value))), []);
29
+ const PointBoxes = z.prefault(z.pipe(z.unknown(), z.transform((value) => z.parse(BoxList, z.safeParse(OneBox, value).success ? [value] : value))), []);
30
30
  const Cell = looseObject({
31
31
  bbox: PointBoxes,
32
32
  lines: arrayOf(Line)
@@ -135,7 +135,7 @@ const tableOf = (item, size) => {
135
135
  /** The page header or footer an item is, if it is one. */
136
136
  const containerOf = (item) => item.type === "header" || item.type === "footer" ? item.type : void 0;
137
137
  const blocksOfItem = (item, page, size, container) => {
138
- if (item.items.length > 0) return item.items.flatMap((child) => blocksOfItem(z$1.parse(Item, child), page, size, container ?? containerOf(item)));
138
+ if (item.items.length > 0) return item.items.flatMap((child) => blocksOfItem(z.parse(Item, child), page, size, container ?? containerOf(item)));
139
139
  const text = item.md ?? item.value ?? "";
140
140
  if (size === void 0) return [compact({
141
141
  container,
@@ -281,7 +281,7 @@ const parsedDocument = async (found, id, o, read, started) => {
281
281
  const grounded = o.wordBoxes === true ? await groundedPages(found, read) : void 0;
282
282
  const images = o.pageImages === true ? pageImageAddresses(found, id, started) : void 0;
283
283
  let laidOut;
284
- if (grounded !== void 0) laidOut = grounded.map((row) => z$1.parse(ItemsPage, row));
284
+ if (grounded !== void 0) laidOut = grounded.map((row) => z.parse(ItemsPage, row));
285
285
  else if (o.blocks === true) laidOut = found.value.items.pages;
286
286
  const sizes = laidOut === void 0 ? void 0 : pageSizes(laidOut);
287
287
  const pages = found.value.markdown.pages.flatMap((page) => {
@@ -324,7 +324,7 @@ const parse = async (raw, document, options, fetchImpl) => {
324
324
  ...o.pageImages === true ? ["images_content_metadata"] : []
325
325
  ].join(",");
326
326
  return await runJob(provider, {
327
- check: async (id, request) => finished(id, z$1.parse(JobResult, await raw.request("GET", `/api/v2/parse/${segment(id)}`, {
327
+ check: async (id, request) => finished(id, z.parse(JobResult, await raw.request("GET", `/api/v2/parse/${segment(id)}`, {
328
328
  ...request,
329
329
  query: { expand }
330
330
  }))),
@@ -84,8 +84,8 @@ interface ParallelReadOptions extends CallOptions {
84
84
  /** Seconds a cached copy may be old. Parallel's minimum is 600; lower values are refused. */
85
85
  maxAge?: number;
86
86
  /**
87
- * Cap on the characters of the page text returned for each URL. Without it,
88
- * or at 0, the full content is requested with no cap.
87
+ * Cap on the characters of the page text returned for each URL, at least 1.
88
+ * Without it, the full content is requested with no cap.
89
89
  */
90
90
  maxContentChars?: number;
91
91
  /** Cap on the characters of excerpts returned for each URL. */
package/dist/parallel.js CHANGED
@@ -1,10 +1,10 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
3
  import { i as withJob, r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
3
- import { C as optionalStructure, D as warnings, O as withOriginal, T as sourceShape, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, w as recordOf, x as optionalString } from "./http-CJcvTPnE.js";
4
- import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-JLEpszjr.js";
5
- import { n as jsonSchemaOf, t as checkOutput } from "./schema-CJXFAZ-x.js";
6
- import { a as compact, c as parseJson, d as refuseTogether, f as requireJobId, i as citationsOf, p as uniqueCitations, s as meta, t as callSettings } from "./util-LvME_uOj.js";
7
- import * as z$1 from "zod/mini";
4
+ import { C as optionalStructure, D as warnings, O as withOriginal, T as sourceShape, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, p as optionalAnyString, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, w as recordOf, x as optionalString } from "./http-Bg0h3D-t.js";
5
+ import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
6
+ import { n as jsonSchemaOf, t as checkOutput } from "./schema-Bfd2E8u2.js";
7
+ import { a as compact, c as parseJson, f as refuseTogether, i as citationsOf, l as positiveWhole, m as uniqueCitations, p as requireJobId, s as meta, t as callSettings } from "./util-BOqd71Om.js";
8
8
  // src/adapters/parallel/parse.ts
9
9
  /** The name this adapter reports in errors and results. */
10
10
  const provider = "parallel";
@@ -292,7 +292,7 @@ const decisionQuestion = (name, question) => {
292
292
  type: "score"
293
293
  };
294
294
  }
295
- const { type } = z$1.parse(UntypedQuestion, question);
295
+ const { type } = z.parse(UntypedQuestion, question);
296
296
  throw invalidRequest(provider, `does not know the question type ${JSON.stringify(type)} for "${name}"`);
297
297
  };
298
298
  /** Parallel's short form of each named schedule. */
@@ -317,20 +317,25 @@ const frequency = (schedule) => {
317
317
  };
318
318
  /**
319
319
  * The `/v1/extract` body that `read` and `readMany` share. It always asks for
320
- * `full_content`, capped only when `maxContentChars` is a non-zero number.
320
+ * `full_content`, capped when `maxContentChars` is set.
321
321
  */
322
- const extractBody = (urls, o) => compact({
323
- advanced_settings: compact({
324
- excerpt_settings: nonEmpty({ max_chars_per_result: o.maxCharsPerResult }),
325
- fetch_policy: fetchPolicy(o.maxAge),
326
- full_content: o.maxContentChars !== void 0 && o.maxContentChars !== 0 ? { max_chars_per_result: o.maxContentChars } : true
327
- }),
328
- max_chars_total: o.maxCharsTotal,
329
- objective: o.query,
330
- search_queries: o.queries,
331
- session_id: o.sessionId,
332
- urls
333
- });
322
+ const extractBody = (urls, o) => {
323
+ const maxContentChars = positiveWhole(provider, "maxContentChars", o.maxContentChars);
324
+ const maxCharsPerResult = positiveWhole(provider, "maxCharsPerResult", o.maxCharsPerResult);
325
+ const maxCharsTotal = positiveWhole(provider, "maxCharsTotal", o.maxCharsTotal);
326
+ return compact({
327
+ advanced_settings: compact({
328
+ excerpt_settings: nonEmpty({ max_chars_per_result: maxCharsPerResult }),
329
+ fetch_policy: fetchPolicy(o.maxAge),
330
+ full_content: maxContentChars === void 0 ? true : { max_chars_per_result: maxContentChars }
331
+ }),
332
+ max_chars_total: maxCharsTotal,
333
+ objective: o.query,
334
+ search_queries: o.queries,
335
+ session_id: o.sessionId,
336
+ urls
337
+ });
338
+ };
334
339
  // src/adapters/parallel/response.ts
335
340
  /** What a result says about the evidence for a field. */
336
341
  const Basis = looseObject({
@@ -345,14 +350,14 @@ const Usage = arrayOf(looseObject({
345
350
  name: optionalString
346
351
  }));
347
352
  /** A string, an object or an array as it arrived, told apart. */
348
- const Content = z$1.pipe(both(optionalAnyString, optionalStructure), z$1.transform(({ first, second }) => ({
353
+ const Content = z.pipe(both(optionalAnyString, optionalStructure), z.transform(({ first, second }) => ({
349
354
  structure: second,
350
355
  text: first
351
356
  })));
352
357
  /** `/v1/search`. */
353
358
  const SearchResponse = looseObject({
354
359
  results: arrayOf(looseObject({
355
- excerpts: arrayOf(z$1.string()),
360
+ excerpts: arrayOf(z.string()),
356
361
  publish_date: optionalString,
357
362
  title: optionalString,
358
363
  url: optionalString
@@ -376,7 +381,7 @@ const ImagesResponse = looseObject({
376
381
  });
377
382
  /** One URL's result in an Extract response. */
378
383
  const ExtractResult = looseObject({
379
- excerpts: arrayOf(z$1.string()),
384
+ excerpts: arrayOf(z.string()),
380
385
  full_content: optionalString,
381
386
  publish_date: optionalString,
382
387
  title: optionalString,
@@ -393,7 +398,7 @@ const ExtractResponse = looseObject({
393
398
  http_status_code: optionalNumber,
394
399
  url: optionalString
395
400
  })),
396
- extract_id: z$1.pipe(both(optionalString, optionalScalar), z$1.transform(({ first, second }) => ({
401
+ extract_id: z.pipe(both(optionalString, optionalScalar), z.transform(({ first, second }) => ({
397
402
  id: second,
398
403
  text: first
399
404
  }))),
@@ -404,7 +409,7 @@ const ExtractResponse = looseObject({
404
409
  /** `/v1/responses`: the ids are read as text (a continuation id) and as a request id. */
405
410
  const AnswerResponse = looseObject({
406
411
  error: looseObject({ message: optionalString }),
407
- id: z$1.pipe(both(optionalString, optionalScalar), z$1.transform(({ first, second }) => ({
412
+ id: z.pipe(both(optionalString, optionalScalar), z.transform(({ first, second }) => ({
408
413
  request: second,
409
414
  text: first
410
415
  }))),
@@ -580,10 +585,10 @@ const stoppedRun = (id, entry) => {
580
585
  */
581
586
  const taskResult = async (raw, id, request) => {
582
587
  try {
583
- return z$1.parse(TaskResult, await raw.request("GET", `/v1/tasks/runs/${segment(id)}/result`, request));
588
+ return z.parse(TaskResult, await raw.request("GET", `/v1/tasks/runs/${segment(id)}/result`, request));
584
589
  } catch (error) {
585
590
  if (error instanceof FieldworkError && error.code === "NotFound") {
586
- const run = z$1.parse(TaskRun, await raw.request("GET", `/v1/tasks/runs/${segment(id)}`, request));
591
+ const run = z.parse(TaskRun, await raw.request("GET", `/v1/tasks/runs/${segment(id)}`, request));
587
592
  if (run.value.status === "failed" || run.value.status === "cancelled") throw stoppedRun(id, run);
588
593
  }
589
594
  throw error;
@@ -597,7 +602,7 @@ const taskResult = async (raw, id, request) => {
597
602
  */
598
603
  const runTask = async (raw, body, settings, finish) => await runJob(provider, {
599
604
  check: async (id, request) => {
600
- const run = z$1.parse(TaskRun, await raw.request("GET", `/v1/tasks/runs/${segment(id)}`, request));
605
+ const run = z.parse(TaskRun, await raw.request("GET", `/v1/tasks/runs/${segment(id)}`, request));
601
606
  const state = jobState(provider, id, TASK_STATES, {
602
607
  original: run.original,
603
608
  value: run.value.status
@@ -659,7 +664,7 @@ const startFindAll = async (raw, objective, o, call) => {
659
664
  * and a status Parallel does not document throws `ProviderError`.
660
665
  */
661
666
  const findAllResult = async (raw, id, request) => {
662
- const run = z$1.parse(FindAllRun, await raw.request("GET", `/v1beta/findall/runs/${segment(id)}`, request));
667
+ const run = z.parse(FindAllRun, await raw.request("GET", `/v1beta/findall/runs/${segment(id)}`, request));
663
668
  const state = jobState(provider, id, FINDALL_STATES, {
664
669
  original: run.original,
665
670
  value: run.value.status.status
@@ -668,7 +673,7 @@ const findAllResult = async (raw, id, request) => {
668
673
  cause: run.original,
669
674
  provider
670
675
  });
671
- return state === "done" ? z$1.parse(FindAllResult, await raw.request("GET", `/v1beta/findall/runs/${segment(id)}/result`, request)) : void 0;
676
+ return state === "done" ? z.parse(FindAllResult, await raw.request("GET", `/v1beta/findall/runs/${segment(id)}/result`, request)) : void 0;
672
677
  };
673
678
  // src/adapters/parallel/monitor.ts
674
679
  /** Refuses a monitor Parallel cannot run, before anything is sent. */
@@ -712,7 +717,7 @@ const monitorBody = (o) => compact({
712
717
  * page forever, so it ends the listing.
713
718
  */
714
719
  const listMonitors = async (raw, call, cursor, seen) => {
715
- const page = z$1.parse(MonitorsPage, await raw.request("GET", "/v1/monitors", {
720
+ const page = z.parse(MonitorsPage, await raw.request("GET", "/v1/monitors", {
716
721
  ...call,
717
722
  query: {
718
723
  cursor,
@@ -734,7 +739,7 @@ const parallelMonitor = (raw) => ({
734
739
  ...call,
735
740
  body: monitorBody(o)
736
741
  });
737
- return monitorInfo(z$1.parse(MonitorEntry, response));
742
+ return monitorInfo(z.parse(MonitorEntry, response));
738
743
  },
739
744
  async delete(id, options) {
740
745
  await raw.request("POST", `/v1/monitors/${segment(id)}/cancel`, options);
@@ -750,7 +755,7 @@ const parallelMonitor = (raw) => ({
750
755
  limit: o.limit
751
756
  }
752
757
  });
753
- const page = z$1.parse(EventsPage, response);
758
+ const page = z.parse(EventsPage, response);
754
759
  return compact({
755
760
  events: page.events.map((entry) => monitorEvent(entry)),
756
761
  next: page.next_cursor,
@@ -758,7 +763,7 @@ const parallelMonitor = (raw) => ({
758
763
  });
759
764
  },
760
765
  async get(id, options) {
761
- return monitorInfo(z$1.parse(MonitorEntry, await raw.request("GET", `/v1/monitors/${segment(id)}`, options)));
766
+ return monitorInfo(z.parse(MonitorEntry, await raw.request("GET", `/v1/monitors/${segment(id)}`, options)));
762
767
  },
763
768
  async list(options = {}) {
764
769
  const { call } = callSettings(options);
@@ -794,7 +799,7 @@ const answering = (raw) => ({ async answer(question, options = {}) {
794
799
  }] : void 0
795
800
  })
796
801
  });
797
- const body = z$1.parse(AnswerResponse, response);
802
+ const body = z.parse(AnswerResponse, response);
798
803
  const failure = body.error.message;
799
804
  if (body.status === "failed" || failure !== void 0) throw new FieldworkError("ProviderError", `parallel could not answer: ${failure ?? "the response failed"}`, {
800
805
  cause: response,
@@ -845,7 +850,7 @@ const judging = (raw) => ({
845
850
  state: context ?? null
846
851
  })
847
852
  });
848
- const body = z$1.parse(DecisionsResponse, response);
853
+ const body = z.parse(DecisionsResponse, response);
849
854
  const result = {};
850
855
  const unanswered = [];
851
856
  for (const [name, question] of entries) {
@@ -959,7 +964,7 @@ const reading = (raw) => ({
959
964
  ...call,
960
965
  body: extractBody([url], o)
961
966
  });
962
- const body = z$1.parse(ExtractResponse, response);
967
+ const body = z.parse(ExtractResponse, response);
963
968
  const [result] = body.results;
964
969
  if (result?.value.url === void 0) {
965
970
  const [failure] = body.errors;
@@ -980,7 +985,7 @@ const reading = (raw) => ({
980
985
  ...call,
981
986
  body: extractBody(urls, o)
982
987
  });
983
- const body = z$1.parse(ExtractResponse, response);
988
+ const body = z.parse(ExtractResponse, response);
984
989
  return compact({
985
990
  failed: body.errors.map((failure) => ({
986
991
  error: extractFailure(failure),
@@ -1010,7 +1015,7 @@ const searching = (raw) => ({
1010
1015
  session_id: o.sessionId
1011
1016
  })
1012
1017
  });
1013
- const body = z$1.parse(ImagesResponse, response);
1018
+ const body = z.parse(ImagesResponse, response);
1014
1019
  return compact({
1015
1020
  meta: meta({
1016
1021
  requestId: body.search_id,
@@ -1029,24 +1034,26 @@ const searching = (raw) => ({
1029
1034
  },
1030
1035
  async search(query, options = {}) {
1031
1036
  const { call, rest: o } = callSettings(options);
1037
+ const maxCharsPerResult = positiveWhole(provider, "maxCharsPerResult", o.maxCharsPerResult);
1038
+ const maxCharsTotal = positiveWhole(provider, "maxCharsTotal", o.maxCharsTotal);
1032
1039
  const response = await raw.request("POST", "/v1/search", {
1033
1040
  ...call,
1034
1041
  body: compact({
1035
1042
  advanced_settings: nonEmpty({
1036
- excerpt_settings: nonEmpty({ max_chars_per_result: o.maxCharsPerResult }),
1043
+ excerpt_settings: nonEmpty({ max_chars_per_result: maxCharsPerResult }),
1037
1044
  fetch_policy: fetchPolicy(o.maxAge),
1038
1045
  location: o.country,
1039
1046
  max_results: o.limit,
1040
1047
  source_policy: sourcePolicy(o)
1041
1048
  }),
1042
- max_chars_total: o.maxCharsTotal,
1049
+ max_chars_total: maxCharsTotal,
1043
1050
  mode: o.mode,
1044
1051
  objective: o.objective ?? query,
1045
1052
  search_queries: o.queries ?? [query],
1046
1053
  session_id: o.sessionId
1047
1054
  })
1048
1055
  });
1049
- const body = z$1.parse(SearchResponse, response);
1056
+ const body = z.parse(SearchResponse, response);
1050
1057
  return compact({
1051
1058
  meta: meta({
1052
1059
  requestId: body.search_id,
@@ -1,4 +1,4 @@
1
- import { _ as isNumber } from "./util-LvME_uOj.js";
1
+ import { v as isNumber } from "./util-BOqd71Om.js";
2
2
  // src/path.ts
3
3
  /** A JSON path, with brackets for indices and keys that are not identifiers. */
4
4
  const joinPath = (segments) => {
@@ -1,10 +1,10 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
3
  import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
3
- import { O as withOriginal, T as sourceShape, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, w as recordOf, x as optionalString } from "./http-CJcvTPnE.js";
4
- import { i as startJob, r as runJob, t as jobState } from "./job-JLEpszjr.js";
5
- import { n as jsonSchemaOf, t as checkOutput } from "./schema-CJXFAZ-x.js";
6
- import { _ as isNumber, a as compact, c as parseJson, d as refuseTogether, m as isFlag, p as uniqueCitations, r as citationOf, s as meta, t as callSettings } from "./util-LvME_uOj.js";
7
- import * as z$1 from "zod/mini";
4
+ import { O as withOriginal, T as sourceShape, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, r as requireKey, s as Source, t as createRawClient, u as both, v as optionalNumber, w as recordOf, x as optionalString } from "./http-Bg0h3D-t.js";
5
+ import { i as startJob, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
6
+ import { n as jsonSchemaOf, t as checkOutput } from "./schema-Bfd2E8u2.js";
7
+ import { a as compact, c as parseJson, f as refuseTogether, h as isFlag, m as uniqueCitations, r as citationOf, s as meta, t as callSettings, v as isNumber } from "./util-BOqd71Om.js";
8
8
  // src/adapters/perplexity/parse.ts
9
9
  /** The name this adapter reports in errors and results. */
10
10
  const provider = "perplexity";
@@ -334,7 +334,7 @@ const search = async (raw, query, options = {}) => {
334
334
  ...filterFields(o)
335
335
  })
336
336
  });
337
- const body = z$1.parse(SearchResponse, response);
337
+ const body = z.parse(SearchResponse, response);
338
338
  return {
339
339
  meta: meta({ requestId: body.id }),
340
340
  raw: response,
@@ -354,7 +354,7 @@ const search = async (raw, query, options = {}) => {
354
354
  */
355
355
  const answer = async (raw, question, options = {}) => {
356
356
  const { call, rest: o } = callSettings(options);
357
- const run = z$1.parse(AgentRun, await raw.request("POST", "/v1/agent", {
357
+ const run = z.parse(AgentRun, await raw.request("POST", "/v1/agent", {
358
358
  ...call,
359
359
  body: compact({
360
360
  effort: o.effort ?? "fast",
@@ -414,7 +414,7 @@ const research = async (raw, question, options = {}) => {
414
414
  const { call, rest: o } = callSettings(options);
415
415
  return await runJob(provider, {
416
416
  check: async (id, request) => {
417
- const found = z$1.parse(AgentRun, await raw.request("GET", `/v1/agent/${segment(id)}`, request));
417
+ const found = z.parse(AgentRun, await raw.request("GET", `/v1/agent/${segment(id)}`, request));
418
418
  return jobState("perplexity", id, RESEARCH_STATES, {
419
419
  original: found.original,
420
420
  value: found.value.status
@@ -457,7 +457,7 @@ const decide = async (raw, context, questions, options = {}) => {
457
457
  state: decisionState(context)
458
458
  }
459
459
  });
460
- const body = z$1.parse(DecisionsResponse, response);
460
+ const body = z.parse(DecisionsResponse, response);
461
461
  const answers = {};
462
462
  const unanswered = [];
463
463
  for (const [name, question] of Object.entries(questions)) {
package/dist/reducto.js CHANGED
@@ -1,10 +1,10 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
- import { n as documentPart, o as refuseLarger, r as documentUrl } from "./document-BSCwJgBM.js";
3
+ import { n as documentPart, o as refuseLarger, r as documentUrl } from "./document-x9fWsQ1W.js";
3
4
  import { t as FieldworkError } from "./errors-gpxg6Tnh.js";
4
- import { O as withOriginal, _ as optionalId, d as looseObject, i as segment, l as arrayOf, n as readSigned, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-CJcvTPnE.js";
5
- import { i as startJob, r as runJob, t as jobState } from "./job-JLEpszjr.js";
6
- import { a as compact, c as parseJson, f as requireJobId, s as meta, t as callSettings } from "./util-LvME_uOj.js";
7
- import * as z$1 from "zod/mini";
5
+ import { O as withOriginal, _ as optionalId, d as looseObject, i as segment, l as arrayOf, n as readSigned, p as optionalAnyString, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-Bg0h3D-t.js";
6
+ import { i as startJob, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
7
+ import { a as compact, c as parseJson, p as requireJobId, s as meta, t as callSettings } from "./util-BOqd71Om.js";
8
8
  // src/adapters/reducto/response.ts
9
9
  /** A box in fractions of the page, from its top-left corner. `page` counts the pages parsed; `original_page` the file's. */
10
10
  const FractionBox = looseObject({
@@ -22,8 +22,8 @@ const Block = looseObject({
22
22
  extra: looseObject({
23
23
  cell_citations: arrayOf(looseObject({
24
24
  bbox: FractionBox,
25
- col_idx: arrayOf(z$1.number()),
26
- row_idx: arrayOf(z$1.number()),
25
+ col_idx: arrayOf(z.number()),
26
+ row_idx: arrayOf(z.number()),
27
27
  text: optionalAnyString
28
28
  })),
29
29
  word_citations: arrayOf(looseObject({
@@ -115,7 +115,7 @@ const startParse = async (raw, document, o, call) => {
115
115
  refuseLarger(provider, document, MAX_UPLOAD_MB);
116
116
  const form = new FormData();
117
117
  form.set("file", documentPart(document), document.name);
118
- const uploaded = z$1.parse(UploadResponse, await raw.request("POST", "/upload", {
118
+ const uploaded = z.parse(UploadResponse, await raw.request("POST", "/upload", {
119
119
  creates: true,
120
120
  ...call,
121
121
  form
@@ -168,14 +168,14 @@ const outputOf = async (found, options) => {
168
168
  });
169
169
  const stored = parseJson(provider, await readSigned(provider, output.url, options));
170
170
  return {
171
- output: z$1.parse(ParseOutput, stored),
171
+ output: z.parse(ParseOutput, stored),
172
172
  stored
173
173
  };
174
174
  };
175
175
  const parse = async (raw, document, options, fetchImpl) => {
176
176
  const { call, rest: o } = callSettings(options);
177
177
  return await runJob(provider, {
178
- check: async (id, request) => finished(id, z$1.parse(JobResponse, await raw.request("GET", `/job/${segment(id)}`, request))),
178
+ check: async (id, request) => finished(id, z.parse(JobResponse, await raw.request("GET", `/job/${segment(id)}`, request))),
179
179
  finish: async (found, id) => {
180
180
  const { output, stored } = await outputOf(found, {
181
181
  fetch: fetchImpl,
@@ -1,6 +1,6 @@
1
1
  import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
2
- import { h as isJsonObject, v as isText } from "./util-LvME_uOj.js";
3
- import { t as joinPath } from "./path-DO2llIdp.js";
2
+ import { g as isJsonObject, y as isText } from "./util-BOqd71Om.js";
3
+ import { t as joinPath } from "./path-tDCyAKK9.js";
4
4
  // src/schema-subset.ts
5
5
  const MAPS = /* @__PURE__ */ new Set([
6
6
  "properties",
package/dist/serpapi.js CHANGED
@@ -1,8 +1,8 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
3
  import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
3
- import { D as warnings, b as optionalScalar, d as looseObject, f as nonEmptyString, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-CJcvTPnE.js";
4
- import { a as compact, d as refuseTogether, s as meta, t as callSettings } from "./util-LvME_uOj.js";
5
- import * as z$1 from "zod/mini";
4
+ import { D as warnings, b as optionalScalar, d as looseObject, f as nonEmptyString, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-Bg0h3D-t.js";
5
+ import { a as compact, f as refuseTogether, s as meta, t as callSettings } from "./util-BOqd71Om.js";
6
6
  // src/adapters/serpapi/parse.ts
7
7
  /** The name this adapter reports in errors and results. */
8
8
  const provider = "serpapi";
@@ -642,10 +642,10 @@ const onlyAllowed = (engine, options, allowed) => {
642
642
  };
643
643
  // src/adapters/serpapi/response.ts
644
644
  /** SerpApi's `error` note: its text when it is a non-empty string, and the warnings it amounts to. */
645
- const ErrorNote = z$1.union([z$1.pipe(nonEmptyString, z$1.transform((message) => ({
645
+ const ErrorNote = z.union([z.pipe(nonEmptyString, z.transform((message) => ({
646
646
  message,
647
647
  warnings: [message]
648
- }))), z$1.pipe(warnings, z$1.transform((entries) => ({
648
+ }))), z.pipe(warnings, z.transform((entries) => ({
649
649
  message: void 0,
650
650
  warnings: entries
651
651
  })))]);
@@ -668,7 +668,7 @@ const storyShape = {
668
668
  iso_date: optionalString,
669
669
  link: optionalString,
670
670
  source: looseObject({
671
- authors: arrayOf(z$1.string()),
671
+ authors: arrayOf(z.string()),
672
672
  icon: optionalString
673
673
  }),
674
674
  thumbnail: optionalString,
@@ -757,7 +757,7 @@ const BingPage = looseObject({
757
757
  width: optionalNumber
758
758
  });
759
759
  /** An image given as a URL, or as Yandex gives it: an object with `link` and the size. Either way, an object. */
760
- const Pictured = z$1.union([z$1.pipe(nonEmptyString, z$1.transform((link) => ({ link }))), looseObject({
760
+ const Pictured = z.union([z.pipe(nonEmptyString, z.transform((link) => ({ link }))), looseObject({
761
761
  height: optionalNumber,
762
762
  link: optionalString,
763
763
  width: optionalNumber
@@ -776,7 +776,7 @@ const ImagePage = looseObject({
776
776
  });
777
777
  /** A `/search` response for any engine; each engine reads only its own sections. */
778
778
  const SearchResponse = looseObject({
779
- answer_box: z$1.union([z$1.pipe(z$1.optional(z$1.null()), z$1.transform(() => void 0)), AnswerBox]),
779
+ answer_box: z.union([z.pipe(z.optional(z.null()), z.transform(() => void 0)), AnswerBox]),
780
780
  answer_box_list: arrayOf(AnswerBox),
781
781
  categorized_shopping_results: arrayOf(looseObject({ shopping_results: arrayOf(ShoppingItem) })),
782
782
  error: ErrorNote,
@@ -812,7 +812,7 @@ const searchCall = async (raw, call, query) => {
812
812
  ...call,
813
813
  query
814
814
  });
815
- const body = z$1.parse(SearchResponse, response);
815
+ const body = z.parse(SearchResponse, response);
816
816
  const failure = searchFailure(body);
817
817
  if (failure !== void 0) throw new FieldworkError("ProviderError", failure, {
818
818
  cause: response,
@@ -903,8 +903,8 @@ const matching = (raw) => ({ async reverseImage(imageUrl, options = {}) {
903
903
  const accounting = (raw) => ({ async usage(options = {}) {
904
904
  const { call } = callSettings(options);
905
905
  const response = await raw.request("GET", "/account", call);
906
- const body = z$1.parse(AccountResponse, response);
907
- const fields = z$1.safeParse(z$1.record(z$1.string(), z$1.unknown()), response);
906
+ const body = z.parse(AccountResponse, response);
907
+ const fields = z.safeParse(z.record(z.string(), z.unknown()), response);
908
908
  const safe = fields.success ? Object.fromEntries(Object.entries(fields.data).filter(([name]) => name !== "api_key")) : response;
909
909
  const breakdown = {};
910
910
  if (body.this_hour_searches !== void 0) breakdown.this_hour_searches = body.this_hour_searches;
package/dist/tavily.js CHANGED
@@ -1,10 +1,10 @@
1
+ import * as z from "zod/mini";
1
2
  import { t as defineAdapter } from "./adapter-CBSAfErv.js";
2
3
  import { r as invalidRequest, t as FieldworkError } from "./errors-gpxg6Tnh.js";
3
- import { O as withOriginal, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-CJcvTPnE.js";
4
- import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-JLEpszjr.js";
5
- import { n as jsonSchemaOf, t as checkOutput } from "./schema-CJXFAZ-x.js";
6
- import { a as compact, o as hours, s as meta, t as callSettings } from "./util-LvME_uOj.js";
7
- import * as z$1 from "zod/mini";
4
+ import { O as withOriginal, _ as optionalId, b as optionalScalar, c as anything, d as looseObject, i as segment, l as arrayOf, r as requireKey, t as createRawClient, v as optionalNumber, x as optionalString } from "./http-Bg0h3D-t.js";
5
+ import { i as startJob, n as requireOutput, r as runJob, t as jobState } from "./job-BsrOrrO1.js";
6
+ import { n as jsonSchemaOf, t as checkOutput } from "./schema-Bfd2E8u2.js";
7
+ import { a as compact, o as hours, s as meta, t as callSettings } from "./util-BOqd71Om.js";
8
8
  // src/adapters/tavily/countries.ts
9
9
  /** Tavily's country names, by ISO 3166-1 alpha-2 code. */
10
10
  const COUNTRIES = new Map(`
@@ -211,10 +211,10 @@ const usageShape = {
211
211
  };
212
212
  looseObject(usageShape);
213
213
  /** An image: a bare URL, or an object with a URL and a description. Anything else, or one without a URL, reads as undefined. */
214
- const Image = z$1.union([z$1.pipe(z$1.string(), z$1.transform((url) => url === "" ? void 0 : { url })), z$1.pipe(looseObject({
214
+ const Image = z.union([z.pipe(z.string(), z.transform((url) => url === "" ? void 0 : { url })), z.pipe(looseObject({
215
215
  description: optionalString,
216
216
  url: optionalString
217
- }), z$1.transform((image) => image.url === void 0 ? void 0 : compact({
217
+ }), z.transform((image) => image.url === void 0 ? void 0 : compact({
218
218
  description: image.description,
219
219
  url: image.url
220
220
  })))]);
@@ -238,7 +238,7 @@ const SearchResponse = looseObject({
238
238
  /** A page from `/extract` or `/crawl`. `raw_content` is the page text, or passages when a query or instructions were given. */
239
239
  const PageResult = looseObject({
240
240
  favicon: optionalString,
241
- images: arrayOf(z$1.string()),
241
+ images: arrayOf(z.string()),
242
242
  raw_content: optionalString,
243
243
  url: optionalString
244
244
  });
@@ -256,7 +256,7 @@ const PagesResponse = looseObject({
256
256
  /** `/map`: the links are bare strings. */
257
257
  const MapResponse = looseObject({
258
258
  ...usageShape,
259
- results: arrayOf(z$1.string())
259
+ results: arrayOf(z.string())
260
260
  });
261
261
  /** The reply to starting a research task. */
262
262
  const ResearchStart = looseObject({ request_id: withOriginal(optionalId) });
@@ -302,7 +302,7 @@ const searching = (raw) => ({
302
302
  include_answer: answerDepth ?? "basic"
303
303
  }
304
304
  });
305
- const body = z$1.parse(SearchResponse, response);
305
+ const body = z.parse(SearchResponse, response);
306
306
  const { answer } = body;
307
307
  if (answer === void 0) throw new FieldworkError("ProviderError", "tavily returned no answer", {
308
308
  cause: response,
@@ -334,7 +334,7 @@ const searching = (raw) => ({
334
334
  topic: o.topic
335
335
  })
336
336
  });
337
- const body = z$1.parse(SearchResponse, response);
337
+ const body = z.parse(SearchResponse, response);
338
338
  return compact({
339
339
  meta: responseMeta(body),
340
340
  raw: response,
@@ -347,7 +347,7 @@ const searching = (raw) => ({
347
347
  ...call,
348
348
  body: searchBody(query, o)
349
349
  });
350
- const body = z$1.parse(SearchResponse, response);
350
+ const body = z.parse(SearchResponse, response);
351
351
  return compact({
352
352
  answer: body.answer,
353
353
  images: imageResults(body.images),
@@ -374,7 +374,7 @@ const reading = (raw) => ({
374
374
  include_images: o.includeImages
375
375
  })
376
376
  });
377
- const body = z$1.parse(PagesResponse, response);
377
+ const body = z.parse(PagesResponse, response);
378
378
  return compact({
379
379
  meta: responseMeta(body),
380
380
  pages: body.results.map((entry) => page(entry, o.instructions !== void 0)),
@@ -390,7 +390,7 @@ const reading = (raw) => ({
390
390
  ...traversal(o)
391
391
  }
392
392
  });
393
- const body = z$1.parse(MapResponse, response);
393
+ const body = z.parse(MapResponse, response);
394
394
  return compact({
395
395
  links: body.results.map((link) => ({ url: link })),
396
396
  meta: responseMeta(body),
@@ -403,7 +403,7 @@ const reading = (raw) => ({
403
403
  ...call,
404
404
  body: extractBody([url], o)
405
405
  });
406
- const body = z$1.parse(PagesResponse, response);
406
+ const body = z.parse(PagesResponse, response);
407
407
  const [result] = body.results;
408
408
  if (result?.value.url === void 0) {
409
409
  const [failure] = failures(body.failed_results);
@@ -426,7 +426,7 @@ const reading = (raw) => ({
426
426
  ...call,
427
427
  body: extractBody(urls, o)
428
428
  });
429
- const body = z$1.parse(PagesResponse, response);
429
+ const body = z.parse(PagesResponse, response);
430
430
  return compact({
431
431
  failed: failures(body.failed_results),
432
432
  meta: responseMeta(body),
@@ -445,7 +445,7 @@ const researching = (raw) => ({ async research(question, options = {}) {
445
445
  ...request,
446
446
  query: { include_usage: true }
447
447
  });
448
- const parsed = z$1.parse(ResearchRun, current);
448
+ const parsed = z.parse(ResearchRun, current);
449
449
  const state = jobState(provider, id, RESEARCH_STATES, {
450
450
  original: current,
451
451
  value: parsed.status
@@ -500,7 +500,7 @@ const researching = (raw) => ({ async research(question, options = {}) {
500
500
  const accounting = (raw) => ({ async usage(options = {}) {
501
501
  const { call } = callSettings(options);
502
502
  const response = await raw.request("GET", "/usage", call);
503
- const { account, key } = z$1.parse(UsageResponse, response);
503
+ const { account, key } = z.parse(UsageResponse, response);
504
504
  const breakdown = Object.fromEntries(Object.entries({
505
505
  crawl: account.crawl_usage,
506
506
  extract: account.extract_usage,