@pablopunk/tau 0.0.0-stage → 0.1.1

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 (69) hide show
  1. package/dist/auth-storage-Dk3CUY3q.js +1814 -0
  2. package/dist/bin.js +23 -0
  3. package/dist/cli-entry-DcDpQ30L.js +13 -0
  4. package/dist/client-C91-b2CL.js +1 -0
  5. package/dist/client-y2WkNuZj.js +7977 -0
  6. package/dist/dist-BFP19NOO.js +432 -0
  7. package/dist/dist-Bh1bQHZA.js +38890 -0
  8. package/dist/dist-Cq73_r65.js +3 -0
  9. package/dist/esm-CMGh_WhC.js +9446 -0
  10. package/dist/execute-BeGXhU1O.js +1757 -0
  11. package/dist/fake-claude-connectors-DSP9UC8d.js +1 -0
  12. package/dist/fake-claude-connectors-sDLeP10T.js +107 -0
  13. package/dist/fake-claude-sdk-CvqW_1iQ.js +571 -0
  14. package/dist/fake-claude-thread-script-2iHHwUZM.js +48 -0
  15. package/dist/last-exit-write-ksHeHGrC.js +9 -0
  16. package/dist/latest-version-di9hD7cY.js +106 -0
  17. package/dist/lib-DIX7q_HJ.js +1460 -0
  18. package/dist/machines-behind-BjGgmSs_.js +257 -0
  19. package/dist/main-D-Tg9b5Y.js +1610 -0
  20. package/dist/manager-B_WHbb1U.js +589 -0
  21. package/dist/names-cTrEXB6w.js +35 -0
  22. package/dist/node-BpwblPFP.js +56269 -0
  23. package/dist/pdfjs-nTcHjDPT.js +69856 -0
  24. package/dist/photon_rs-DBr7W_rK.js +4252 -0
  25. package/dist/promise.try-CAAOYvMP.js +1426 -0
  26. package/dist/readability-DsDNO63a.js +1670 -0
  27. package/dist/real-deps-f96UmLBz.js +89 -0
  28. package/dist/rolldown-runtime-1p2KPIdQ.js +44 -0
  29. package/dist/runtime-i-oEtgAl.js +2721 -0
  30. package/dist/sdk-missing-CHbVbY1G.js +10 -0
  31. package/dist/sdk-port-BGw9ORUR.js +215 -0
  32. package/dist/serve-Cmy0rUWr.js +2932 -0
  33. package/dist/serve-Dmzn5V0l.js +1 -0
  34. package/dist/service-command-C74K0saj.js +34 -0
  35. package/dist/service-command-DqcstJ8e.js +1 -0
  36. package/dist/shell-CQa4e7rx.js +643 -0
  37. package/dist/skills/builtin/tau/SKILL.md +51 -0
  38. package/dist/src-DO9LUlhi.js +44088 -0
  39. package/dist/streamableHttp-BBaRYV9h.js +1 -0
  40. package/dist/streamableHttp-DPAoMlJd.js +1931 -0
  41. package/dist/tool-DBZK2lci.js +14335 -0
  42. package/dist/tool-server-BjP37EJg.js +40 -0
  43. package/dist/turndown.cjs-Bo1xLg2S.js +15620 -0
  44. package/dist/turndown.cjs-jpUF50AR.js +3 -0
  45. package/dist/types-C4M3CRp2.js +7592 -0
  46. package/dist/undici-8cI97lnP.js +27110 -0
  47. package/dist/wait-for-lock-B1Qx8GWg.js +1 -0
  48. package/dist/wait-for-lock-CrSl2mi1.js +25 -0
  49. package/dist/watchdog.js +47 -0
  50. package/dist/web/dist/assets/addon-fit-DIOBYJe3.js +1 -0
  51. package/dist/web/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  52. package/dist/web/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  53. package/dist/web/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  54. package/dist/web/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  55. package/dist/web/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  56. package/dist/web/dist/assets/index-BktLKZHR.js +108 -0
  57. package/dist/web/dist/assets/index-D_Aa3Oou.css +2 -0
  58. package/dist/web/dist/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  59. package/dist/web/dist/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  60. package/dist/web/dist/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  61. package/dist/web/dist/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  62. package/dist/web/dist/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  63. package/dist/web/dist/assets/wght-DMLdVLkb.css +1 -0
  64. package/dist/web/dist/assets/xterm-BrP-ENHg.css +1 -0
  65. package/dist/web/dist/assets/xterm-CerOhKYV.js +16 -0
  66. package/dist/web/dist/favicon.svg +14 -0
  67. package/dist/web/dist/index.html +25 -0
  68. package/package.json +53 -4
  69. package/README.md +0 -3
@@ -0,0 +1,432 @@
1
+ //#region ../../node_modules/.pnpm/unpdf@1.9.0/node_modules/unpdf/dist/index.mjs
2
+ function polyfillDOMMatrix() {
3
+ if (typeof globalThis.DOMMatrix !== "undefined") return;
4
+ globalThis.DOMMatrix = class DOMMatrix {
5
+ constructor(init) {
6
+ if (Array.isArray(init) && init.length === 6) {
7
+ this.a = init[0];
8
+ this.b = init[1];
9
+ this.c = init[2];
10
+ this.d = init[3];
11
+ this.e = init[4];
12
+ this.f = init[5];
13
+ } else {
14
+ this.a = 1;
15
+ this.b = 0;
16
+ this.c = 0;
17
+ this.d = 1;
18
+ this.e = 0;
19
+ this.f = 0;
20
+ }
21
+ }
22
+ translateSelf(tx, ty = 0) {
23
+ this.e = this.a * tx + this.c * ty + this.e;
24
+ this.f = this.b * tx + this.d * ty + this.f;
25
+ return this;
26
+ }
27
+ scaleSelf(sx, sy = sx) {
28
+ this.a *= sx;
29
+ this.b *= sx;
30
+ this.c *= sy;
31
+ this.d *= sy;
32
+ return this;
33
+ }
34
+ };
35
+ }
36
+ /**
37
+ * Stubs browser globals that PDF.js expects at the module level
38
+ * in non-browser environments.
39
+ *
40
+ * @remarks
41
+ * Must be called before importing any PDF.js module, since PDF.js
42
+ * accesses these globals at parse time (top-level constants).
43
+ */
44
+ function stubBrowserGlobals() {
45
+ polyfillDOMMatrix();
46
+ }
47
+ let resolvedModule;
48
+ const isNode = globalThis.process?.release?.name === "node";
49
+ const isBrowser = typeof window !== "undefined";
50
+ /**
51
+ * Returns a `PDFDocumentProxy` instance from a given binary data.
52
+ *
53
+ * Applies the following defaults:
54
+ * - `useSystemFonts: true`
55
+ *
56
+ * In Node.js environments, additionally applies:
57
+ * - `disableFontFace: true`
58
+ * - `standardFontDataUrl` resolved from the local `pdfjs-dist` package
59
+ * - `cMapUrl` and `cMapPacked` resolved from the local `pdfjs-dist` package
60
+ */
61
+ async function getDocumentProxy(data, options = {}) {
62
+ const { getDocument } = await getResolvedPDFJS();
63
+ let nodeDefaults = {};
64
+ if (isNode) try {
65
+ const base = import.meta.resolve("pdfjs-dist/package.json");
66
+ nodeDefaults = {
67
+ disableFontFace: true,
68
+ standardFontDataUrl: new URL("./standard_fonts/", base).href,
69
+ cMapUrl: new URL("./cmaps/", base).href,
70
+ cMapPacked: true
71
+ };
72
+ } catch {}
73
+ return await getDocument({
74
+ data,
75
+ useSystemFonts: true,
76
+ ...nodeDefaults,
77
+ ...options
78
+ }).promise;
79
+ }
80
+ /**
81
+ * Runs an operation on a `PDFDocumentProxy` resolved from either binary data
82
+ * or an existing proxy. Documents created here are destroyed once the
83
+ * operation settles – caller-supplied proxies keep their lifecycle with the
84
+ * caller.
85
+ */
86
+ async function withDocument(data, operation, options) {
87
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data, options);
88
+ try {
89
+ return await operation(pdf);
90
+ } finally {
91
+ if (pdf !== data) await pdf.loadingTask.destroy();
92
+ }
93
+ }
94
+ async function getResolvedPDFJS() {
95
+ if (!resolvedModule) await resolvePDFJSImport();
96
+ return resolvedModule;
97
+ }
98
+ async function resolvePDFJSImport(pdfjsResolver, { reload = false } = {}) {
99
+ if (resolvedModule && !reload) return;
100
+ stubBrowserGlobals();
101
+ if (pdfjsResolver) try {
102
+ resolvedModule = await interopDefault(pdfjsResolver());
103
+ return;
104
+ } catch (error) {
105
+ throw new Error(`PDF.js could not be resolved: ${error}`);
106
+ }
107
+ try {
108
+ resolvedModule = await import("./pdfjs-nTcHjDPT.js");
109
+ } catch (error) {
110
+ throw new Error(`Serverless PDF.js bundle could not be resolved: ${error}`);
111
+ }
112
+ }
113
+ function isPDFDocumentProxy(data) {
114
+ return typeof data === "object" && data !== null && "_pdfInfo" in data;
115
+ }
116
+ async function interopDefault(m) {
117
+ const resolved = await m;
118
+ return resolved.default || resolved;
119
+ }
120
+ let resolvedCanvasModule;
121
+ /**
122
+ * Derived from the PDF.js project by the Mozilla Foundation.
123
+ * @see https://github.com/mozilla/pdf.js/blob/b8de9a372f9bbf7e33adb362eeae5ef1919dba73/src/display/canvas_factory.js#L18
124
+ * @license Apache-2.0
125
+ */
126
+ var BaseCanvasFactory = class {
127
+ #enableHWA = false;
128
+ constructor({ enableHWA = false } = {}) {
129
+ this.#enableHWA = enableHWA;
130
+ }
131
+ create(width, height) {
132
+ const canvas = this._createCanvas(width, height);
133
+ return {
134
+ canvas,
135
+ context: canvas.getContext("2d", { willReadFrequently: !this.#enableHWA })
136
+ };
137
+ }
138
+ reset({ canvas }, width, height) {
139
+ if (!canvas) throw new Error("Canvas is not specified");
140
+ canvas.width = width;
141
+ canvas.height = height;
142
+ }
143
+ destroy(context) {
144
+ if (!context.canvas) throw new Error("Canvas is not specified");
145
+ context.canvas.width = 0;
146
+ context.canvas.height = 0;
147
+ context.canvas = void 0;
148
+ context.context = void 0;
149
+ }
150
+ _createCanvas(width, height) {
151
+ throw new Error("Not implemented");
152
+ }
153
+ };
154
+ /**
155
+ * Derived from the PDF.js project by the Mozilla Foundation.
156
+ * @see https://github.com/mozilla/pdf.js/blob/b8de9a372f9bbf7e33adb362eeae5ef1919dba73/src/display/canvas_factory.js#L18
157
+ * @license Apache-2.0
158
+ */
159
+ var DOMCanvasFactory = class extends BaseCanvasFactory {
160
+ constructor({ ownerDocument = globalThis.document, enableHWA = false } = {}) {
161
+ super({ enableHWA });
162
+ this._document = ownerDocument;
163
+ }
164
+ _createCanvas(width, height) {
165
+ const canvas = this._document.createElement("canvas");
166
+ canvas.width = width;
167
+ canvas.height = height;
168
+ return canvas;
169
+ }
170
+ };
171
+ var NodeCanvasFactory = class extends BaseCanvasFactory {
172
+ constructor({ enableHWA = false } = {}) {
173
+ super({ enableHWA });
174
+ }
175
+ _createCanvas(width, height) {
176
+ if (!resolvedCanvasModule) throw new Error("@napi-rs/canvas module is not resolved");
177
+ return resolvedCanvasModule.createCanvas(width, height);
178
+ }
179
+ };
180
+ async function resolveCanvasModule(canvasImport) {
181
+ resolvedCanvasModule ??= await interopDefault(canvasImport());
182
+ globalThis[Symbol.for("unpdf.canvasModule")] = resolvedCanvasModule;
183
+ }
184
+ /**
185
+ * Injects `DOMMatrix`, `ImageData` and `Path2D` constructors from the
186
+ * `@napi-rs/canvas` package into the global scope. This is necessary for
187
+ * Node.js environments that do not support these constructors natively.
188
+ *
189
+ * @remarks
190
+ * `DOMMatrix` is always set because {@link stubBrowserGlobals} may have
191
+ * installed a minimal stub to allow PDF.js to import – the real
192
+ * `@napi-rs/canvas` implementation must take precedence for rendering.
193
+ */
194
+ function injectCanvasConstructors() {
195
+ if (!resolvedCanvasModule) return;
196
+ globalThis.DOMMatrix = resolvedCanvasModule.DOMMatrix;
197
+ if (typeof globalThis.ImageData === "undefined") globalThis.ImageData = resolvedCanvasModule.ImageData;
198
+ if (typeof globalThis.Path2D === "undefined") globalThis.Path2D = resolvedCanvasModule.Path2D;
199
+ }
200
+ /**
201
+ * Extracts images from a specific page of a PDF document, including necessary metadata,
202
+ * such as width, height, and calculated color channels.
203
+ *
204
+ * @example
205
+ * const imagesData = await extractImages(pdf, pageNum)
206
+ *
207
+ * for (const imgData of imagesData) {
208
+ * const imageIndex = totalImagesProcessed + 1
209
+ * await sharp(imgData.data, {
210
+ * raw: { width: imgData.width, height: imgData.height, channels: imgData.channels }
211
+ * })
212
+ * .png()
213
+ * .toFile(`${imageIndex}.png`)
214
+ * }
215
+ */
216
+ async function extractImages$1(data, pageNumber) {
217
+ return await withDocument(data, async (pdf) => {
218
+ if (pageNumber < 1 || pageNumber > pdf.numPages) throw new Error(`Invalid page number. Must be between 1 and ${pdf.numPages}.`);
219
+ const page = await pdf.getPage(pageNumber);
220
+ const operatorList = await page.getOperatorList();
221
+ const { OPS } = await getResolvedPDFJS();
222
+ const images = [];
223
+ for (let i = 0; i < operatorList.fnArray.length; i++) {
224
+ if (operatorList.fnArray[i] !== OPS.paintImageXObject) continue;
225
+ const imageKey = operatorList.argsArray[i][0];
226
+ const image = await new Promise((resolve) => (imageKey.startsWith("g_") ? page.commonObjs : page.objs).get(imageKey, resolve));
227
+ if (!image || !image.data || !image.width || !image.height) continue;
228
+ const { width, height, data } = image;
229
+ const calculatedChannels = data.length / (width * height);
230
+ if (![
231
+ 1,
232
+ 3,
233
+ 4
234
+ ].includes(calculatedChannels)) continue;
235
+ const channels = calculatedChannels;
236
+ images.push({
237
+ data,
238
+ width,
239
+ height,
240
+ channels,
241
+ key: imageKey
242
+ });
243
+ }
244
+ return images;
245
+ });
246
+ }
247
+ async function renderPageAsImage$1(data, pageNumber, options = {}) {
248
+ const CanvasFactory = await createIsomorphicCanvasFactory(options.canvasImport);
249
+ return await withDocument(data, async (pdf) => {
250
+ if (pageNumber < 1 || pageNumber > pdf.numPages) throw new Error(`Invalid page number. Must be between 1 and ${pdf.numPages}.`);
251
+ const page = await pdf.getPage(pageNumber);
252
+ const defaultViewport = page.getViewport({ scale: 1 });
253
+ let scale = options.scale || 1;
254
+ if (options.width) scale = options.width / defaultViewport.width;
255
+ else if (options.height) scale = options.height / defaultViewport.height;
256
+ const viewport = page.getViewport({ scale: Math.max(0, scale) });
257
+ const canvasFactory = new CanvasFactory();
258
+ const drawingContext = canvasFactory.create(viewport.width, viewport.height);
259
+ try {
260
+ await page.render({
261
+ canvas: drawingContext.canvas,
262
+ canvasContext: drawingContext.context,
263
+ viewport
264
+ }).promise;
265
+ const { canvas } = drawingContext;
266
+ if (options.toDataURL) return canvas.toDataURL();
267
+ if ("encode" in canvas) {
268
+ const buffer = await canvas.encode("png");
269
+ return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
270
+ }
271
+ const blob = await new Promise((resolve) => {
272
+ canvas.toBlob(resolve);
273
+ });
274
+ if (!blob) throw new Error("Failed to encode canvas to a PNG blob.");
275
+ return await blob.arrayBuffer();
276
+ } finally {
277
+ canvasFactory.destroy(drawingContext);
278
+ }
279
+ }, { CanvasFactory });
280
+ }
281
+ async function createIsomorphicCanvasFactory(canvasImport) {
282
+ if (isBrowser) return DOMCanvasFactory;
283
+ if (isNode) {
284
+ if (!canvasImport) throw new Error("Parameter \"canvasImport\" is required in Node.js environment.");
285
+ await resolveCanvasModule(canvasImport);
286
+ injectCanvasConstructors();
287
+ return NodeCanvasFactory;
288
+ }
289
+ throw new Error("Unsupported environment for canvas creation.");
290
+ }
291
+ async function extractLinks$1(data) {
292
+ return await withDocument(data, async (pdf) => {
293
+ const pageLinks = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageLinks(pdf, i + 1)));
294
+ return {
295
+ totalPages: pdf.numPages,
296
+ links: pageLinks.flat()
297
+ };
298
+ });
299
+ }
300
+ async function getPageLinks(document, pageNumber) {
301
+ const annotations = await (await document.getPage(pageNumber)).getAnnotations();
302
+ const links = [];
303
+ for (const annotation of annotations) if (annotation.subtype === "Link" && annotation.url) links.push(annotation.url);
304
+ return links;
305
+ }
306
+ const XMP_DATE_PROPERTIES = [
307
+ "xmp:createdate",
308
+ "xmp:modifydate",
309
+ "xmp:metadatadate",
310
+ "xap:createdate",
311
+ "xap:modifydate",
312
+ "xap:metadatadate"
313
+ ];
314
+ async function getMeta$1(data, options = {}) {
315
+ return await withDocument(data, async (pdf) => {
316
+ const meta = await pdf.getMetadata();
317
+ const info = meta?.info || {};
318
+ if (options.parseDates) {
319
+ const { PDFDateString } = await getResolvedPDFJS();
320
+ if (info?.CreationDate) info.CreationDate = PDFDateString.toDateObject(info?.CreationDate);
321
+ if (info?.ModDate) info.ModDate = PDFDateString.toDateObject(info?.ModDate);
322
+ if (meta.metadata) meta.metadata = new Proxy(meta.metadata, { get(target, prop) {
323
+ if (prop === "get") return (name) => {
324
+ const value = target.get(name);
325
+ if (XMP_DATE_PROPERTIES.includes(name) && value) return parseISODateString(value);
326
+ return value;
327
+ };
328
+ return target[prop];
329
+ } });
330
+ }
331
+ return {
332
+ info,
333
+ metadata: meta?.metadata || {}
334
+ };
335
+ });
336
+ }
337
+ function parseISODateString(isoDateString) {
338
+ if (!isoDateString) return;
339
+ const parsedDate = Date.parse(isoDateString);
340
+ if (!Number.isNaN(parsedDate)) return new Date(parsedDate);
341
+ }
342
+ async function extractTextItems$1(data) {
343
+ return await withDocument(data, async (pdf) => {
344
+ const items = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageTextItems(pdf, i + 1)));
345
+ return {
346
+ totalPages: pdf.numPages,
347
+ items
348
+ };
349
+ });
350
+ }
351
+ async function getPageTextItems(document, pageNumber) {
352
+ const content = await (await document.getPage(pageNumber)).getTextContent();
353
+ const styles = content.styles;
354
+ return content.items.filter((item) => item.str != null).map((item) => {
355
+ const [_a, _b, c, d, e, f] = item.transform;
356
+ return {
357
+ str: item.str,
358
+ x: e,
359
+ y: f,
360
+ width: item.width,
361
+ height: item.height,
362
+ fontSize: Math.hypot(c, d),
363
+ fontFamily: styles[item.fontName]?.fontFamily ?? "",
364
+ dir: item.dir,
365
+ hasEOL: item.hasEOL
366
+ };
367
+ });
368
+ }
369
+ async function extractText$1(data, options = {}) {
370
+ const { mergePages = false } = options;
371
+ return await withDocument(data, async (pdf) => {
372
+ const texts = await Promise.all(Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1)));
373
+ return {
374
+ totalPages: pdf.numPages,
375
+ text: mergePages ? normalizeMergedText(texts) : texts
376
+ };
377
+ });
378
+ }
379
+ async function getPageText(document, pageNumber) {
380
+ return (await (await document.getPage(pageNumber)).getTextContent()).items.filter((item) => item.str != null).map((item) => item.str + (item.hasEOL ? "\n" : "")).join("");
381
+ }
382
+ /**
383
+ * Collapses whitespace without destroying the line structure: `hasEOL` and
384
+ * page-join line breaks survive, but at most one blank line remains.
385
+ */
386
+ function normalizeMergedText(texts) {
387
+ return texts.join("\n").replace(/[^\S\n]+/g, " ").replace(/ ?\n ?/g, "\n").replace(/\n{3,}/g, "\n\n");
388
+ }
389
+ /**
390
+ * By default, unpdf will use the latest version of PDF.js compiled for
391
+ * serverless environments. If you want to use a different version, you can
392
+ * provide a custom resolver function.
393
+ *
394
+ * @example
395
+ * // Use the official PDF.js build (make sure to install it first)
396
+ * import { definePDFJSModule } from 'unpdf'
397
+ *
398
+ * await definePDFJSModule(() => import('pdfjs-dist'))
399
+ */
400
+ async function definePDFJSModule(pdfjs) {
401
+ await resolvePDFJSImport(pdfjs, { reload: true });
402
+ }
403
+ /** @deprecated Use `definePDFJSModule` instead. Will be removed in v2. */
404
+ async function configureUnPDF(options) {
405
+ await resolvePDFJSImport(options.pdfjs, { reload: true });
406
+ }
407
+ const getMeta = async (...args) => {
408
+ await resolvePDFJSImport();
409
+ return await getMeta$1(...args);
410
+ };
411
+ const extractText = async (...args) => {
412
+ await resolvePDFJSImport();
413
+ return await extractText$1(...args);
414
+ };
415
+ const extractTextItems = async (...args) => {
416
+ await resolvePDFJSImport();
417
+ return await extractTextItems$1(...args);
418
+ };
419
+ const extractImages = async (...args) => {
420
+ await resolvePDFJSImport();
421
+ return await extractImages$1(...args);
422
+ };
423
+ const renderPageAsImage = async (...args) => {
424
+ await resolvePDFJSImport();
425
+ return await renderPageAsImage$1(...args);
426
+ };
427
+ const extractLinks = async (...args) => {
428
+ await resolvePDFJSImport();
429
+ return await extractLinks$1(...args);
430
+ };
431
+ //#endregion
432
+ export { configureUnPDF, createIsomorphicCanvasFactory, definePDFJSModule, extractImages, extractLinks, extractText, extractTextItems, getDocumentProxy, getMeta, getResolvedPDFJS, renderPageAsImage, resolvePDFJSImport };