@tabstack/sdk 2.0.0 → 2.2.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.
Files changed (62) hide show
  1. package/CHANGELOG.md +55 -0
  2. package/README.md +2 -2
  3. package/client.d.mts +3 -2
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +3 -2
  6. package/client.d.ts.map +1 -1
  7. package/client.js +8 -2
  8. package/client.js.map +1 -1
  9. package/client.mjs +9 -3
  10. package/client.mjs.map +1 -1
  11. package/core/streaming.js.map +1 -1
  12. package/core/streaming.mjs.map +1 -1
  13. package/internal/parse.d.mts.map +1 -1
  14. package/internal/parse.d.ts.map +1 -1
  15. package/internal/parse.js +5 -0
  16. package/internal/parse.js.map +1 -1
  17. package/internal/parse.mjs +5 -0
  18. package/internal/parse.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/resources/agent.d.mts +83 -3
  21. package/resources/agent.d.mts.map +1 -1
  22. package/resources/agent.d.ts +83 -3
  23. package/resources/agent.d.ts.map +1 -1
  24. package/resources/agent.js +45 -2
  25. package/resources/agent.js.map +1 -1
  26. package/resources/agent.mjs +45 -2
  27. package/resources/agent.mjs.map +1 -1
  28. package/resources/extract.d.mts +90 -1
  29. package/resources/extract.d.mts.map +1 -1
  30. package/resources/extract.d.ts +90 -1
  31. package/resources/extract.d.ts.map +1 -1
  32. package/resources/extract.js +25 -1
  33. package/resources/extract.js.map +1 -1
  34. package/resources/extract.mjs +25 -1
  35. package/resources/extract.mjs.map +1 -1
  36. package/resources/generate.d.mts +35 -1
  37. package/resources/generate.d.mts.map +1 -1
  38. package/resources/generate.d.ts +35 -1
  39. package/resources/generate.d.ts.map +1 -1
  40. package/resources/generate.js +19 -1
  41. package/resources/generate.js.map +1 -1
  42. package/resources/generate.mjs +19 -1
  43. package/resources/generate.mjs.map +1 -1
  44. package/resources/index.d.mts +1 -1
  45. package/resources/index.d.mts.map +1 -1
  46. package/resources/index.d.ts +1 -1
  47. package/resources/index.d.ts.map +1 -1
  48. package/resources/index.js.map +1 -1
  49. package/resources/index.mjs +1 -1
  50. package/resources/index.mjs.map +1 -1
  51. package/src/client.ts +19 -4
  52. package/src/core/streaming.ts +2 -2
  53. package/src/internal/parse.ts +6 -0
  54. package/src/resources/agent.ts +104 -3
  55. package/src/resources/extract.ts +102 -1
  56. package/src/resources/generate.ts +37 -1
  57. package/src/resources/index.ts +7 -1
  58. package/src/version.ts +1 -1
  59. package/version.d.mts +1 -1
  60. package/version.d.ts +1 -1
  61. package/version.js +1 -1
  62. package/version.mjs +1 -1
@@ -8,7 +8,31 @@ export declare class Extract extends APIResource {
8
8
  * @example
9
9
  * ```ts
10
10
  * const response = await client.extract.json({
11
- * json_schema: {},
11
+ * json_schema: {
12
+ * properties: {
13
+ * stories: {
14
+ * items: {
15
+ * properties: {
16
+ * author: {
17
+ * description: 'Author username',
18
+ * type: 'string',
19
+ * },
20
+ * points: {
21
+ * description: 'Story points',
22
+ * type: 'number',
23
+ * },
24
+ * title: {
25
+ * description: 'Story title',
26
+ * type: 'string',
27
+ * },
28
+ * },
29
+ * type: 'object',
30
+ * },
31
+ * type: 'array',
32
+ * },
33
+ * },
34
+ * type: 'object',
35
+ * },
12
36
  * url: 'https://news.ycombinator.com',
13
37
  * });
14
38
  * ```
@@ -53,6 +77,14 @@ export declare namespace ExtractMarkdownResponse {
53
77
  * Author information from HTML metadata
54
78
  */
55
79
  author?: string;
80
+ /**
81
+ * Document creation date (ISO 8601)
82
+ */
83
+ created_at?: string;
84
+ /**
85
+ * Creator application (e.g., "Microsoft Word")
86
+ */
87
+ creator?: string;
56
88
  /**
57
89
  * Page description from Open Graph or HTML
58
90
  */
@@ -61,6 +93,26 @@ export declare namespace ExtractMarkdownResponse {
61
93
  * Featured image URL from Open Graph
62
94
  */
63
95
  image?: string;
96
+ /**
97
+ * PDF keywords as array
98
+ */
99
+ keywords?: Array<string>;
100
+ /**
101
+ * Document modification date (ISO 8601)
102
+ */
103
+ modified_at?: string;
104
+ /**
105
+ * Number of pages (PDF documents)
106
+ */
107
+ page_count?: number;
108
+ /**
109
+ * PDF version (e.g., "1.5")
110
+ */
111
+ pdf_version?: string;
112
+ /**
113
+ * PDF producer software (e.g., "Adobe PDF Library")
114
+ */
115
+ producer?: string;
64
116
  /**
65
117
  * Publisher information from Open Graph
66
118
  */
@@ -69,6 +121,11 @@ export declare namespace ExtractMarkdownResponse {
69
121
  * Site name from Open Graph
70
122
  */
71
123
  site_name?: string;
124
+ /**
125
+ * PDF-specific metadata fields (populated for PDF documents) PDF subject or
126
+ * summary
127
+ */
128
+ subject?: string;
72
129
  /**
73
130
  * Page title from Open Graph or HTML
74
131
  */
@@ -92,16 +149,36 @@ export interface ExtractJsonParams {
92
149
  * URL to fetch and extract data from
93
150
  */
94
151
  url: string;
152
+ /**
153
+ * Optional geotargeting parameters for proxy requests
154
+ */
155
+ geo_target?: ExtractJsonParams.GeoTarget;
95
156
  /**
96
157
  * Bypass cache and force fresh data retrieval
97
158
  */
98
159
  nocache?: boolean;
99
160
  }
161
+ export declare namespace ExtractJsonParams {
162
+ /**
163
+ * Optional geotargeting parameters for proxy requests
164
+ */
165
+ interface GeoTarget {
166
+ /**
167
+ * Country code using ISO 3166-1 alpha-2 standard (2 letters, e.g., "US", "GB",
168
+ * "JP"). See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
169
+ */
170
+ country?: string;
171
+ }
172
+ }
100
173
  export interface ExtractMarkdownParams {
101
174
  /**
102
175
  * URL to fetch and convert to markdown
103
176
  */
104
177
  url: string;
178
+ /**
179
+ * Optional geotargeting parameters for proxy requests
180
+ */
181
+ geo_target?: ExtractMarkdownParams.GeoTarget;
105
182
  /**
106
183
  * Include extracted metadata (Open Graph and HTML metadata) as a separate field in
107
184
  * the response
@@ -112,6 +189,18 @@ export interface ExtractMarkdownParams {
112
189
  */
113
190
  nocache?: boolean;
114
191
  }
192
+ export declare namespace ExtractMarkdownParams {
193
+ /**
194
+ * Optional geotargeting parameters for proxy requests
195
+ */
196
+ interface GeoTarget {
197
+ /**
198
+ * Country code using ISO 3166-1 alpha-2 standard (2 letters, e.g., "US", "GB",
199
+ * "JP"). See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
200
+ */
201
+ country?: string;
202
+ }
203
+ }
115
204
  export declare namespace Extract {
116
205
  export { type ExtractJsonResponse as ExtractJsonResponse, type ExtractMarkdownResponse as ExtractMarkdownResponse, type ExtractJsonParams as ExtractJsonParams, type ExtractMarkdownParams as ExtractMarkdownParams, };
117
206
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extract.d.ts","sourceRoot":"","sources":["../src/resources/extract.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,mBAAmB,CAAC;IAIxF;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAAI,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,uBAAuB,CAAC;CAGrG;AAED,MAAM,MAAM,mBAAmB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,QAAQ,CAAC,EAAE,uBAAuB,CAAC,QAAQ,CAAC;CAC7C;AAED,yBAAiB,uBAAuB,CAAC;IACvC;;OAEG;IACH,UAAiB,QAAQ;QACvB;;WAEG;QACH,MAAM,CAAC,EAAE,MAAM,CAAC;QAEhB;;WAEG;QACH,WAAW,CAAC,EAAE,MAAM,CAAC;QAErB;;WAEG;QACH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iBAAiB;IAChC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC,SAAS,CAAC;IAEzC;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yBAAiB,iBAAiB,CAAC;IACjC;;OAEG;IACH,UAAiB,SAAS;QACxB;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,UAAU,CAAC,EAAE,qBAAqB,CAAC,SAAS,CAAC;IAE7C;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yBAAiB,qBAAqB,CAAC;IACrC;;OAEG;IACH,UAAiB,SAAS;QACxB;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,CAAC,OAAO,WAAW,OAAO,CAAC;IAC/B,OAAO,EACL,KAAK,mBAAmB,IAAI,mBAAmB,EAC/C,KAAK,uBAAuB,IAAI,uBAAuB,EACvD,KAAK,iBAAiB,IAAI,iBAAiB,EAC3C,KAAK,qBAAqB,IAAI,qBAAqB,GACpD,CAAC;CACH"}
@@ -10,7 +10,31 @@ class Extract extends resource_1.APIResource {
10
10
  * @example
11
11
  * ```ts
12
12
  * const response = await client.extract.json({
13
- * json_schema: {},
13
+ * json_schema: {
14
+ * properties: {
15
+ * stories: {
16
+ * items: {
17
+ * properties: {
18
+ * author: {
19
+ * description: 'Author username',
20
+ * type: 'string',
21
+ * },
22
+ * points: {
23
+ * description: 'Story points',
24
+ * type: 'number',
25
+ * },
26
+ * title: {
27
+ * description: 'Story title',
28
+ * type: 'string',
29
+ * },
30
+ * },
31
+ * type: 'object',
32
+ * },
33
+ * type: 'array',
34
+ * },
35
+ * },
36
+ * type: 'object',
37
+ * },
14
38
  * url: 'https://news.ycombinator.com',
15
39
  * });
16
40
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/resources/extract.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,OAAQ,SAAQ,sBAAW;IACtC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,IAAuB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAA2B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AA9BD,0BA8BC"}
1
+ {"version":3,"file":"extract.js","sourceRoot":"","sources":["../src/resources/extract.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,OAAQ,SAAQ,sBAAW;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CAAC,IAAuB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAA2B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF;AAtDD,0BAsDC"}
@@ -7,7 +7,31 @@ export class Extract extends APIResource {
7
7
  * @example
8
8
  * ```ts
9
9
  * const response = await client.extract.json({
10
- * json_schema: {},
10
+ * json_schema: {
11
+ * properties: {
12
+ * stories: {
13
+ * items: {
14
+ * properties: {
15
+ * author: {
16
+ * description: 'Author username',
17
+ * type: 'string',
18
+ * },
19
+ * points: {
20
+ * description: 'Story points',
21
+ * type: 'number',
22
+ * },
23
+ * title: {
24
+ * description: 'Story title',
25
+ * type: 'string',
26
+ * },
27
+ * },
28
+ * type: 'object',
29
+ * },
30
+ * type: 'array',
31
+ * },
32
+ * },
33
+ * type: 'object',
34
+ * },
11
35
  * url: 'https://news.ycombinator.com',
12
36
  * });
13
37
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"extract.mjs","sourceRoot":"","sources":["../src/resources/extract.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;OAUG;IACH,IAAI,CAAC,IAAuB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAA2B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF"}
1
+ {"version":3,"file":"extract.mjs","sourceRoot":"","sources":["../src/resources/extract.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,OAAQ,SAAQ,WAAW;IACtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,IAAI,CAAC,IAAuB,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,IAA2B,EAAE,OAAwB;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;CACF"}
@@ -11,7 +11,25 @@ export declare class Generate extends APIResource {
11
11
  * const response = await client.generate.json({
12
12
  * instructions:
13
13
  * "For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
14
- * json_schema: {},
14
+ * json_schema: {
15
+ * properties: {
16
+ * summaries: {
17
+ * items: {
18
+ * properties: {
19
+ * category: {
20
+ * description: 'Story category (tech/business/science/etc)',
21
+ * type: 'string',
22
+ * },
23
+ * summary: { description: 'One-sentence summary of the story', type: 'string' },
24
+ * title: { description: 'Story title', type: 'string' },
25
+ * },
26
+ * type: 'object',
27
+ * },
28
+ * type: 'array',
29
+ * },
30
+ * },
31
+ * type: 'object',
32
+ * },
15
33
  * url: 'https://news.ycombinator.com',
16
34
  * });
17
35
  * ```
@@ -34,11 +52,27 @@ export interface GenerateJsonParams {
34
52
  * URL to fetch content from
35
53
  */
36
54
  url: string;
55
+ /**
56
+ * Optional geotargeting parameters for proxy requests
57
+ */
58
+ geo_target?: GenerateJsonParams.GeoTarget;
37
59
  /**
38
60
  * Bypass cache and force fresh data retrieval
39
61
  */
40
62
  nocache?: boolean;
41
63
  }
64
+ export declare namespace GenerateJsonParams {
65
+ /**
66
+ * Optional geotargeting parameters for proxy requests
67
+ */
68
+ interface GeoTarget {
69
+ /**
70
+ * Country code using ISO 3166-1 alpha-2 standard (2 letters, e.g., "US", "GB",
71
+ * "JP"). See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
72
+ */
73
+ country?: string;
74
+ }
75
+ }
42
76
  export declare namespace Generate {
43
77
  export { type GenerateJsonResponse as GenerateJsonResponse, type GenerateJsonParams as GenerateJsonParams };
44
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.mts","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAG3F;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,oBAAoB,IAAI,oBAAoB,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;CAC7G"}
1
+ {"version":3,"file":"generate.d.mts","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAG3F;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yBAAiB,kBAAkB,CAAC;IAClC;;OAEG;IACH,UAAiB,SAAS;QACxB;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,oBAAoB,IAAI,oBAAoB,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;CAC7G"}
@@ -11,7 +11,25 @@ export declare class Generate extends APIResource {
11
11
  * const response = await client.generate.json({
12
12
  * instructions:
13
13
  * "For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
14
- * json_schema: {},
14
+ * json_schema: {
15
+ * properties: {
16
+ * summaries: {
17
+ * items: {
18
+ * properties: {
19
+ * category: {
20
+ * description: 'Story category (tech/business/science/etc)',
21
+ * type: 'string',
22
+ * },
23
+ * summary: { description: 'One-sentence summary of the story', type: 'string' },
24
+ * title: { description: 'Story title', type: 'string' },
25
+ * },
26
+ * type: 'object',
27
+ * },
28
+ * type: 'array',
29
+ * },
30
+ * },
31
+ * type: 'object',
32
+ * },
15
33
  * url: 'https://news.ycombinator.com',
16
34
  * });
17
35
  * ```
@@ -34,11 +52,27 @@ export interface GenerateJsonParams {
34
52
  * URL to fetch content from
35
53
  */
36
54
  url: string;
55
+ /**
56
+ * Optional geotargeting parameters for proxy requests
57
+ */
58
+ geo_target?: GenerateJsonParams.GeoTarget;
37
59
  /**
38
60
  * Bypass cache and force fresh data retrieval
39
61
  */
40
62
  nocache?: boolean;
41
63
  }
64
+ export declare namespace GenerateJsonParams {
65
+ /**
66
+ * Optional geotargeting parameters for proxy requests
67
+ */
68
+ interface GeoTarget {
69
+ /**
70
+ * Country code using ISO 3166-1 alpha-2 standard (2 letters, e.g., "US", "GB",
71
+ * "JP"). See: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
72
+ */
73
+ country?: string;
74
+ }
75
+ }
42
76
  export declare namespace Generate {
43
77
  export { type GenerateJsonResponse as GenerateJsonResponse, type GenerateJsonParams as GenerateJsonParams };
44
78
  }
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAG3F;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,oBAAoB,IAAI,oBAAoB,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;CAC7G"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,oBAAoB,CAAC;CAG3F;AAED,MAAM,MAAM,oBAAoB,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AAE9D,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IAErB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC,SAAS,CAAC;IAE1C;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,yBAAiB,kBAAkB,CAAC;IAClC;;OAEG;IACH,UAAiB,SAAS;QACxB;;;WAGG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB;CACF;AAED,MAAM,CAAC,OAAO,WAAW,QAAQ,CAAC;IAChC,OAAO,EAAE,KAAK,oBAAoB,IAAI,oBAAoB,EAAE,KAAK,kBAAkB,IAAI,kBAAkB,EAAE,CAAC;CAC7G"}
@@ -13,7 +13,25 @@ class Generate extends resource_1.APIResource {
13
13
  * const response = await client.generate.json({
14
14
  * instructions:
15
15
  * "For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
16
- * json_schema: {},
16
+ * json_schema: {
17
+ * properties: {
18
+ * summaries: {
19
+ * items: {
20
+ * properties: {
21
+ * category: {
22
+ * description: 'Story category (tech/business/science/etc)',
23
+ * type: 'string',
24
+ * },
25
+ * summary: { description: 'One-sentence summary of the story', type: 'string' },
26
+ * title: { description: 'Story title', type: 'string' },
27
+ * },
28
+ * type: 'object',
29
+ * },
30
+ * type: 'array',
31
+ * },
32
+ * },
33
+ * type: 'object',
34
+ * },
17
35
  * url: 'https://news.ycombinator.com',
18
36
  * });
19
37
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,IAAwB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAlBD,4BAkBC"}
1
+ {"version":3,"file":"generate.js","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,QAAS,SAAQ,sBAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,IAAI,CAAC,IAAwB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AApCD,4BAoCC"}
@@ -10,7 +10,25 @@ export class Generate extends APIResource {
10
10
  * const response = await client.generate.json({
11
11
  * instructions:
12
12
  * "For each story, categorize it (tech/business/science/other) and write a one-sentence summary explaining what it's about in simple terms.",
13
- * json_schema: {},
13
+ * json_schema: {
14
+ * properties: {
15
+ * summaries: {
16
+ * items: {
17
+ * properties: {
18
+ * category: {
19
+ * description: 'Story category (tech/business/science/etc)',
20
+ * type: 'string',
21
+ * },
22
+ * summary: { description: 'One-sentence summary of the story', type: 'string' },
23
+ * title: { description: 'Story title', type: 'string' },
24
+ * },
25
+ * type: 'object',
26
+ * },
27
+ * type: 'array',
28
+ * },
29
+ * },
30
+ * type: 'object',
31
+ * },
14
32
  * url: 'https://news.ycombinator.com',
15
33
  * });
16
34
  * ```
@@ -1 +1 @@
1
- {"version":3,"file":"generate.mjs","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;OAaG;IACH,IAAI,CAAC,IAAwB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;CACF"}
1
+ {"version":3,"file":"generate.mjs","sourceRoot":"","sources":["../src/resources/generate.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,QAAS,SAAQ,WAAW;IACvC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BG;IACH,IAAI,CAAC,IAAwB,EAAE,OAAwB;QACrD,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACnE,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- export { Agent, type AutomateEvent, type AgentAutomateParams } from "./agent.mjs";
1
+ export { Agent, type AutomateEvent, type ResearchEvent, type AgentAutomateParams, type AgentResearchParams, } from "./agent.mjs";
2
2
  export { Extract, type ExtractJsonResponse, type ExtractMarkdownResponse, type ExtractJsonParams, type ExtractMarkdownParams, } from "./extract.mjs";
3
3
  export { Generate, type GenerateJsonResponse, type GenerateJsonParams } from "./generate.mjs";
4
4
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE;OACvD,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B;OACM,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE"}
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EACL,KAAK,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB;OACM,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B;OACM,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE"}
@@ -1,4 +1,4 @@
1
- export { Agent, type AutomateEvent, type AgentAutomateParams } from "./agent.js";
1
+ export { Agent, type AutomateEvent, type ResearchEvent, type AgentAutomateParams, type AgentResearchParams, } from "./agent.js";
2
2
  export { Extract, type ExtractJsonResponse, type ExtractMarkdownResponse, type ExtractJsonParams, type ExtractMarkdownParams, } from "./extract.js";
3
3
  export { Generate, type GenerateJsonResponse, type GenerateJsonParams } from "./generate.js";
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EAAE,KAAK,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE;OACvD,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B;OACM,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"OAEO,EACL,KAAK,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB;OACM,EACL,OAAO,EACP,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,GAC3B;OACM,EAAE,QAAQ,EAAE,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oCAA8E;AAArE,8FAAA,KAAK,OAAA;AACd,wCAMmB;AALjB,kGAAA,OAAO,OAAA;AAMT,0CAA0F;AAAjF,oGAAA,QAAQ,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,oCAMiB;AALf,8FAAA,KAAK,OAAA;AAMP,wCAMmB;AALjB,kGAAA,OAAO,OAAA;AAMT,0CAA0F;AAAjF,oGAAA,QAAQ,OAAA"}
@@ -1,5 +1,5 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
- export { Agent } from "./agent.mjs";
2
+ export { Agent, } from "./agent.mjs";
3
3
  export { Extract, } from "./extract.mjs";
4
4
  export { Generate } from "./generate.mjs";
5
5
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,KAAK,EAAgD;OACvD,EACL,OAAO,GAKR;OACM,EAAE,QAAQ,EAAsD"}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/resources/index.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EACL,KAAK,GAKN;OACM,EACL,OAAO,GAKR;OACM,EAAE,QAAQ,EAAsD"}
package/src/client.ts CHANGED
@@ -16,7 +16,13 @@ import * as Errors from './core/error';
16
16
  import * as Uploads from './core/uploads';
17
17
  import * as API from './resources/index';
18
18
  import { APIPromise } from './core/api-promise';
19
- import { Agent, AgentAutomateParams, AutomateEvent } from './resources/agent';
19
+ import {
20
+ Agent,
21
+ AgentAutomateParams,
22
+ AgentResearchParams,
23
+ AutomateEvent,
24
+ ResearchEvent,
25
+ } from './resources/agent';
20
26
  import {
21
27
  Extract,
22
28
  ExtractJsonParams,
@@ -456,7 +462,7 @@ export class Tabstack {
456
462
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
457
463
 
458
464
  const errText = await response.text().catch((err: any) => castToError(err).message);
459
- const errJSON = safeJSON(errText);
465
+ const errJSON = safeJSON(errText) as any;
460
466
  const errMessage = errJSON ? undefined : errText;
461
467
 
462
468
  loggerFor(this).debug(
@@ -497,9 +503,10 @@ export class Tabstack {
497
503
  controller: AbortController,
498
504
  ): Promise<Response> {
499
505
  const { signal, method, ...options } = init || {};
500
- if (signal) signal.addEventListener('abort', () => controller.abort());
506
+ const abort = this._makeAbort(controller);
507
+ if (signal) signal.addEventListener('abort', abort, { once: true });
501
508
 
502
- const timeout = setTimeout(() => controller.abort(), ms);
509
+ const timeout = setTimeout(abort, ms);
503
510
 
504
511
  const isReadableBody =
505
512
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -666,6 +673,12 @@ export class Tabstack {
666
673
  return headers.values;
667
674
  }
668
675
 
676
+ private _makeAbort(controller: AbortController) {
677
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
678
+ // would capture all request options, and cause a memory leak.
679
+ return () => controller.abort();
680
+ }
681
+
669
682
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
670
683
  bodyHeaders: HeadersLike;
671
684
  body: BodyInit | undefined;
@@ -737,7 +750,9 @@ export declare namespace Tabstack {
737
750
  export {
738
751
  Agent as Agent,
739
752
  type AutomateEvent as AutomateEvent,
753
+ type ResearchEvent as ResearchEvent,
740
754
  type AgentAutomateParams as AgentAutomateParams,
755
+ type AgentResearchParams as AgentResearchParams,
741
756
  };
742
757
 
743
758
  export {
@@ -46,7 +46,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
46
46
  try {
47
47
  for await (const sse of _iterSSEMessages(response, controller)) {
48
48
  try {
49
- yield JSON.parse(sse.data);
49
+ yield JSON.parse(sse.data) as Item;
50
50
  } catch (e) {
51
51
  logger.error(`Could not parse message into JSON:`, sse.data);
52
52
  logger.error(`From chunk:`, sse.raw);
@@ -102,7 +102,7 @@ export class Stream<Item> implements AsyncIterable<Item> {
102
102
  try {
103
103
  for await (const line of iterLines()) {
104
104
  if (done) continue;
105
- if (line) yield JSON.parse(line);
105
+ if (line) yield JSON.parse(line) as Item;
106
106
  }
107
107
  done = true;
108
108
  } catch (e) {
@@ -43,6 +43,12 @@ export async function defaultParseResponse<T>(client: Tabstack, props: APIRespon
43
43
  const mediaType = contentType?.split(';')[0]?.trim();
44
44
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
45
45
  if (isJSON) {
46
+ const contentLength = response.headers.get('content-length');
47
+ if (contentLength === '0') {
48
+ // if there is no content we can't do anything
49
+ return undefined as T;
50
+ }
51
+
46
52
  const json = await response.json();
47
53
  return json as T;
48
54
  }