@radicaltools/mcp 0.3.4 → 0.4.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.
package/README.md CHANGED
@@ -49,7 +49,13 @@ The server binds to one folder at launch, then reads it afresh for every tool ca
49
49
 
50
50
  - `get_model_summary` (counts, views, sequences, milestones, presentations, the modelling rules Studio's chat and Forge follow, and the metamodel rules) and `search_model` (a small query language, including `LIST SEQUENCES` and `GET SEQUENCE`);
51
51
  - the `forge_*` tools: a Radical Forge run with the agent's model, ending with a Review stage over the whole model. Each stage may fill gaps in earlier stages, but only by asking: `forge_propose_refinement` checks a proposal and returns exactly what it would write, for the agent to show the user, and `forge_answer_refinement` writes it only if the user accepts (while a stage is open the server refuses direct writes to earlier stages, and every write while a proposal waits for its answer). `forge_complete_stage` lists what the stage refined, with the gaps the completeness rules still find. In a folder with no base from git, `forge_start` saves the model as it was before the run to `.state/base.json`, so Studio's Changes on branch shows the run. After every step the server writes where the run stands to `.state/forge-run.json` (next to the selection, also out of git), and marks it closed when the client goes away, so Studio open on the folder can show it on its Forge button;
52
- - `get_issues`: every rule the model breaks now, as the Validation list in Studio's metamodel editor shows it. A write is refused when it brings in a new error; the warnings it brings in (a state machine without an initial state, a reference to no node, …) come back with its result, since a model is often incomplete while it is being built;
52
+ - An Access file (.mdb, .accdb) a unit uses is read for its tables, columns and relations (with `mdb-reader`, a dependency of this package); the CLI reads none.
53
+ - A VB6 application's forms are screens of the run (`assay_facts` kind `screens`): a plan's mockups of them get a wireframe drawn from the form and `navigates-to` where its code opens another form. `assay_explore_act` takes `expect` (a text the screen shows; the path's test asserts it). A requirement may name the `processes` that meet it. A transition's evidence is marked `sets` or `quoted` in `run.json`, and a test that asserts nothing rests no scenario.
54
+ - `assay_apply` also takes `entities`, `processes` and `stateMachines`: entities written observed on the table facts they are (columns and foreign keys from SQL and ORM classes), joined only where a foreign key states it and realised by every element whose code names their table; processes and state machines written directly as inferred, each step and transition on the entry points (routes, VB6 forms and menus, jobs, handlers), paths, status values or code it rests on. A requirement's scenario may rest on the code it is drawn from (`citations`); accepted, a pending test of it is written where the unit that builds its element has a test framework, and bound in `.radical/radical.json`.
55
+ - `assay_search`: the lines of a run's repository or source that hold a text or match a regular expression, with their files and lines, to find what to read with `assay_read`.
56
+ - `assay_explore` and `assay_explore_act`: Radical Assay's Explore stage. The server opens a web application running on this machine in a browser it drives (the user's Chrome, else Playwright's Chromium: `npx playwright install chromium`; `RADICAL_ASSAY_BROWSER` picks one) and records the agent's actions as named paths, each screen with its controls and a screenshot in `.radical/assay/explore/`. Other hosts and controls that pay or delete an account are refused. A plan's `mockups` and a scenario's `paths` use them; an accepted path becomes a Playwright test in the application repository's `e2e/assay/`.
57
+ - the `assay_*` tools: a Radical Assay run, finding the model in existing code, with this folder as the central model. `assay_start` reads the facts of the code in the directories given (a directory holding repositories stands for each; a folder of code with no `.git`, or a `.zip` file of code, unpacked without its `.git` folders, is one too; a folder of code is left as it was, its facts kept in `.radical/assay/facts/`), each with its file and line, writes them to each repository's `.radical/assay/facts.json`, links their units and answers in brief (at most about 20 KB: the counts, each repository's first units, services and databases, the links counted by kind); `assay_procedure` gives the steps, stage by stage; `assay_facts` lists the facts and links a page at a time (at most 200 and about 20 KB, with where the next starts). `assay_apply` takes a plan of elements and relations, each citing the facts it rests on and marked observed or inferred: it refuses the whole plan, naming every problem, when something cites no fact or a fact the run lacks, an observed claim cites nothing that states it, or the metamodel forbids it; otherwise it writes it, maps the elements built from units in each code repository's `.radical/radical.json` (with a `"model"` entry naming the central model) and keeps the evidence in `.radical/assay/run.json`, not in the model. For a repository Assay reads no units of (VB6, COBOL, Delphi, …), an inferred item may rest on code the agent quotes instead (`citations`: repository, file, lines and the text, which the server checks is in those lines, spacing aside), and an element names the folders it is built in (`paths`); only facts back an observed claim. The plan's requirements, each with the scenarios that verify it from the tests, come back as proposals; `assay_answer` writes one only when the user accepts it (derived from a need *Found in the code*, its tests bound in `.radical/radical.json`), and `assay_finish` says what the run wrote. Documentation is a source of hypotheses: `assay_start`'s `sources` and `assay_add_sources` take folders, files, `.zip` files and public links (no credentials: a link that asks for a login is refused, to be exported by hand; links to loopback, link-local or private addresses are refused unless the server runs with `RADICAL_ASSAY_PRIVATE_LINKS=1`), kept as text in `.radical/assay/sources/` (HTML as Markdown, a PDF's text) and listed as document facts with their headings, as each repository's README, docs and ADR records are; `assay_read` returns a file's lines of the run, numbered, or lists a folder's files. A requirement from documents that no code builds names no element and is written unsatisfied; `assay_answer` can name the need a requirement derives from (`changes.need`). A plan's `needs` and `decisions` drawn from documents, and requirements with no scenarios that cite them, come back as proposals too; a document never backs an observed claim. The `assay` prompt starts a run;
58
+ - `get_issues`: every rule the model breaks now, as the Validation list in Studio's metamodel editor shows it. On a large model the open concerns run long: `concerns: "brief"` lists each in one line, `concept` gives one in full, `concerns: "none"` leaves them out. A write is refused when it brings in a new error; the warnings it brings in (a state machine without an initial state, a reference to no node, …) come back with its result, since a model is often incomplete while it is being built;
53
59
  - `get_selection`: what is selected on Studio's canvas for this folder (the view on screen, each selected node in full, selected relations), so you can say "fix the selected mockup" instead of naming it. Studio writes it to `.state/selection.json` in the model folder whenever the selection or the view changes, and clears it when you switch to another model; `.state/` carries its own `.gitignore`, and the file is not part of the model, so writing it never conflicts with model edits;
54
60
  - `get_changes`: what changed in the model since its version in git, for an agent asked to implement a change made in the model. It lists the elements and relations added, removed and changed (uncommitted edits included), each changed field with its old and new value, and each element with its place and its relations, such as the component that satisfies a requirement and the scenarios that verify it. Views, positions, sizes and folding are left out. `since` names the branch, tag or commit to compare with; by default it is the merge base with the default branch (`origin/main`), so every model change on the branch counts. `radical diff` prints the same list. Without `since` it also saves that base to `.state/base.json`, for Studio to show the same changes (Changes on branch);
55
61
  - `get_verification` and `set_verification`: which tests check the model's scenarios and fitness functions, in the repository's `.radical/radical.json` ("verifies"; the model names no test). `get_verification` with an `id` lists the tests bound to it; without one, every entry and the scenarios this repository must verify that have nothing checking them. `set_verification` replaces a scenario's or fitness function's tests, or takes it out with `remove: true`, as `radical verify` does; call it for each test you write. It changes no model file;
@@ -1,39 +1,6 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __esm = (fn, res) => function __init() {
8
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
- };
10
- var __commonJS = (cb, mod) => function __require() {
11
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
- };
13
- var __copyProps = (to, from, except, desc) => {
14
- if (from && typeof from === "object" || typeof from === "function") {
15
- for (let key of __getOwnPropNames(from))
16
- if (!__hasOwnProp.call(to, key) && key !== except)
17
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
- }
19
- return to;
20
- };
21
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
- // If the importer is in node compatibility mode or this is not an ESM
23
- // file that has been converted to a CommonJS file using a Babel-
24
- // compatible transform (i.e. "__esModule" has not been set), then set
25
- // "default" to the CommonJS "module.exports" for node compatibility.
26
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
- mod
28
- ));
29
-
30
- // <define:__RADICAL_BUILD__>
31
- var define_RADICAL_BUILD_default;
32
- var init_define_RADICAL_BUILD = __esm({
33
- "<define:__RADICAL_BUILD__>"() {
34
- define_RADICAL_BUILD_default = { version: "0.3.4", commit: "1a00a35", date: "2026-11-06", release: true };
35
- }
36
- });
1
+ import {
2
+ init_define_RADICAL_BUILD
3
+ } from "./chunk-DPGHTQAV.js";
37
4
 
38
5
  // ../../packages/layout/src/elkLayout.ts
39
6
  init_define_RADICAL_BUILD();
@@ -1181,7 +1148,7 @@ function builtInC4Metamodel() {
1181
1148
  person: ["group"],
1182
1149
  system: ["system", "group"],
1183
1150
  container: ["system", "group"],
1184
- component: ["container", "webapp", "group"],
1151
+ component: ["container", "webapp", "database", "group"],
1185
1152
  database: ["system", "group"],
1186
1153
  webapp: ["system", "group"],
1187
1154
  queue: ["system", "group"],
@@ -1233,6 +1200,8 @@ function builtInC4Metamodel() {
1233
1200
  { from: "person", to: "container" },
1234
1201
  { from: "person", to: "webapp" },
1235
1202
  { from: "person", to: "component" },
1203
+ // …and works in a database directly (an analyst's SQL client)
1204
+ { from: "person", to: "database" },
1236
1205
  // System-level dependencies; to a person a relation delivers (Structurizr's
1237
1206
  // delivers(): "Sends e-mails to")
1238
1207
  { from: "system", to: "person", ...DELIVERS },
@@ -1260,6 +1229,13 @@ function builtInC4Metamodel() {
1260
1229
  { from: "webapp", to: "webapp" },
1261
1230
  { from: "webapp", to: "queue" },
1262
1231
  { from: "webapp", to: "component" },
1232
+ // A database's code calls out
1233
+ { from: "database", to: "system" },
1234
+ { from: "database", to: "container" },
1235
+ { from: "database", to: "database" },
1236
+ { from: "database", to: "webapp" },
1237
+ { from: "database", to: "queue" },
1238
+ { from: "database", to: "component" },
1263
1239
  // Queues fan out to consumers
1264
1240
  { from: "queue", to: "container" },
1265
1241
  { from: "queue", to: "webapp" },
@@ -1363,7 +1339,7 @@ function builtInDddC4Metamodel() {
1363
1339
  allowedPairs: [
1364
1340
  { from: "system", to: "domain" },
1365
1341
  { from: "container", to: "domain" },
1366
- ...["system", "container", "component", "webapp"].map((from) => ({ from, to: "entity" }))
1342
+ ...["system", "container", "component", "webapp", "database"].map((from) => ({ from, to: "entity" }))
1367
1343
  ],
1368
1344
  properties: [],
1369
1345
  builtin: true
@@ -2046,7 +2022,7 @@ function builtInGovernanceMetamodel() {
2046
2022
  id: "illustrates",
2047
2023
  layout: { flow: "side" },
2048
2024
  label: "Illustrates",
2049
- description: "The screen shows the requirement being met, the step of the scenario, or what the user sees in the state.",
2025
+ description: "The screen shows the requirement being met, the step of the scenario or the process, or what the user sees in the state.",
2050
2026
  inverseLabel: "Illustrated by",
2051
2027
  allowedPairs: [
2052
2028
  { from: "mockup", to: "requirement" },
@@ -2303,16 +2279,16 @@ function builtInGovernanceMetamodel() {
2303
2279
  label: "Performed by",
2304
2280
  description: "The person or part of the architecture that does the step.",
2305
2281
  inverseLabel: "Performs",
2306
- allowedPairs: ["person", "system", "container", "component", "webapp"].map((to) => ({ from: "step", to })),
2282
+ allowedPairs: ["person", "system", "container", "component", "webapp", "database"].map((to) => ({ from: "step", to })),
2307
2283
  properties: [],
2308
2284
  color: "#0d9488",
2309
2285
  builtin: true
2310
2286
  };
2311
- implements_.allowedPairs.push(...["system", "container", "component", "webapp"].map((from) => ({ from, to: "state-machine" })));
2287
+ implements_.allowedPairs.push(...["system", "container", "component", "webapp", "database"].map((from) => ({ from, to: "state-machine" })));
2312
2288
  satisfies.allowedPairs.push({ from: "state-machine", to: "requirement" }, { from: "entity", to: "requirement" });
2313
2289
  verifies.allowedPairs.push({ from: "scenario", to: "state-machine" }, { from: "scenario", to: "process" });
2314
2290
  satisfies.allowedPairs.push({ from: "process", to: "requirement" });
2315
- illustrates.allowedPairs.push({ from: "mockup", to: "state" });
2291
+ illustrates.allowedPairs.push({ from: "mockup", to: "state" }, { from: "mockup", to: "step" });
2316
2292
  return {
2317
2293
  id: "c4-ddd-governance-builtin",
2318
2294
  name: RADICAL_METAMODEL_NAME,
@@ -2386,6 +2362,7 @@ var CONTAINER_TYPES = /* @__PURE__ */ new Set([
2386
2362
  "system",
2387
2363
  "container",
2388
2364
  "webapp",
2365
+ "database",
2389
2366
  "domain",
2390
2367
  "group",
2391
2368
  "blueprint",
@@ -2593,7 +2570,7 @@ function isVisible(node, allNodes) {
2593
2570
  return isVisible(parent, allNodes);
2594
2571
  }
2595
2572
  function compoundPadding(type) {
2596
- const margin = type === "container" || type === "webapp" ? 20 : 30;
2573
+ const margin = type === "container" || type === "webapp" || type === "database" ? 20 : 30;
2597
2574
  return { top: 120, side: margin, bottom: margin };
2598
2575
  }
2599
2576
  function fittedParentSize(parent, children) {
@@ -3144,10 +3121,6 @@ async function applyTreeLayout(c4Nodes, c4Relations) {
3144
3121
  }
3145
3122
 
3146
3123
  export {
3147
- __commonJS,
3148
- __toESM,
3149
- init_define_RADICAL_BUILD,
3150
- define_RADICAL_BUILD_default,
3151
3124
  isRelationAllowed,
3152
3125
  inferRelationType,
3153
3126
  isParentAllowed,
@@ -0,0 +1,43 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __esm = (fn, res) => function __init() {
8
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
9
+ };
10
+ var __commonJS = (cb, mod) => function __require() {
11
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+
30
+ // <define:__RADICAL_BUILD__>
31
+ var define_RADICAL_BUILD_default;
32
+ var init_define_RADICAL_BUILD = __esm({
33
+ "<define:__RADICAL_BUILD__>"() {
34
+ define_RADICAL_BUILD_default = { version: "0.4.0", commit: "8f1e2cd", date: "2026-11-10", release: true };
35
+ }
36
+ });
37
+
38
+ export {
39
+ __commonJS,
40
+ __toESM,
41
+ init_define_RADICAL_BUILD,
42
+ define_RADICAL_BUILD_default
43
+ };
@@ -0,0 +1,219 @@
1
+ import {
2
+ init_define_RADICAL_BUILD
3
+ } from "./chunk-DPGHTQAV.js";
4
+
5
+ // ../../packages/assay/node_modules/unpdf/dist/index.mjs
6
+ init_define_RADICAL_BUILD();
7
+ var resolvedModule;
8
+ var isNode = globalThis.process?.release?.name === "node";
9
+ var isBrowser = typeof window !== "undefined";
10
+ async function getDocumentProxy(data, options = {}) {
11
+ const { getDocument } = await getResolvedPDFJS();
12
+ const pdf = await getDocument({
13
+ data,
14
+ isEvalSupported: false,
15
+ // See: https://github.com/mozilla/pdf.js/issues/4244#issuecomment-1479534301
16
+ useSystemFonts: true,
17
+ ...options
18
+ }).promise;
19
+ return pdf;
20
+ }
21
+ async function getResolvedPDFJS() {
22
+ if (!resolvedModule) {
23
+ await resolvePDFJSImports();
24
+ }
25
+ return resolvedModule;
26
+ }
27
+ async function resolvePDFJSImports(pdfjsResolver, { force = false } = {}) {
28
+ if (resolvedModule && !force) {
29
+ return;
30
+ }
31
+ if (pdfjsResolver) {
32
+ try {
33
+ resolvedModule = await interopDefault(pdfjsResolver());
34
+ if (resolvedModule && "resolvePDFJS" in resolvedModule) {
35
+ resolvedModule = await resolvedModule.resolvePDFJS();
36
+ }
37
+ return;
38
+ } catch (error) {
39
+ console.error(error);
40
+ throw new Error("Resolving failed. Please check the provided configuration.");
41
+ }
42
+ }
43
+ try {
44
+ const { resolvePDFJS } = await import("./pdfjs-QB56DH5V.js");
45
+ resolvedModule = await resolvePDFJS();
46
+ } catch (error) {
47
+ console.error(error);
48
+ throw new Error("PDF.js is not available. Please add the package as a dependency.");
49
+ }
50
+ }
51
+ function isPDFDocumentProxy(data) {
52
+ return typeof data === "object" && data !== null && "_pdfInfo" in data;
53
+ }
54
+ async function interopDefault(m) {
55
+ const resolved = await m;
56
+ return resolved.default || resolved;
57
+ }
58
+ async function extractImages$1(data, pageNumber) {
59
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
60
+ if (pageNumber < 1 || pageNumber > pdf.numPages) {
61
+ throw new Error(`Invalid page number. Must be between 1 and ${pdf.numPages}.`);
62
+ }
63
+ const page = await pdf.getPage(pageNumber);
64
+ const operatorList = await page.getOperatorList();
65
+ const { OPS } = await getResolvedPDFJS();
66
+ const images = [];
67
+ for (let i = 0; i < operatorList.fnArray.length; i++) {
68
+ const op = operatorList.fnArray[i];
69
+ if (op !== OPS.paintImageXObject) {
70
+ continue;
71
+ }
72
+ const imageKey = operatorList.argsArray[i][0];
73
+ const image = await page.objs.get(imageKey);
74
+ if (!image || !image.data || !image.width || !image.height) {
75
+ continue;
76
+ }
77
+ const { width, height, data: data2 } = image;
78
+ const calculatedChannels = data2.length / (width * height);
79
+ if (![1, 3, 4].includes(calculatedChannels)) {
80
+ continue;
81
+ }
82
+ const channels = calculatedChannels;
83
+ images.push({
84
+ data: data2,
85
+ width,
86
+ height,
87
+ channels,
88
+ key: imageKey
89
+ });
90
+ }
91
+ return images;
92
+ }
93
+ async function renderPageAsImage$1(data, pageNumber, options = {}) {
94
+ const canvasFactory = await createIsomorphicCanvasFactory(options.canvas);
95
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data, { canvasFactory });
96
+ const page = await pdf.getPage(pageNumber);
97
+ if (pageNumber < 1 || pageNumber > pdf.numPages) {
98
+ throw new Error(`Invalid page number. Must be between 1 and ${pdf.numPages}.`);
99
+ }
100
+ let outputScale = options.scale || 1;
101
+ let viewport = page.getViewport({ scale: outputScale });
102
+ if (options.width) {
103
+ outputScale = options.width / viewport.width;
104
+ } else if (options.height) {
105
+ outputScale = options.height / viewport.height;
106
+ }
107
+ if (outputScale !== 1 && outputScale > 0) {
108
+ viewport = page.getViewport({ scale: outputScale });
109
+ }
110
+ const ctx = canvasFactory.create(viewport.width, viewport.height);
111
+ await page.render({
112
+ canvasContext: ctx.context,
113
+ viewport
114
+ }).promise;
115
+ const dataUrl = isBrowser ? ctx.canvas.toDataURL() : ctx.canvas.toDataURL();
116
+ const response = await fetch(dataUrl);
117
+ return await response.arrayBuffer();
118
+ }
119
+ async function createIsomorphicCanvasFactory(canvas) {
120
+ const _canvas = canvas ? await interopDefault(canvas()) : void 0;
121
+ return {
122
+ _createCanvas(width, height) {
123
+ if (isBrowser) {
124
+ const canvas2 = document.createElement("canvas");
125
+ canvas2.width = width;
126
+ canvas2.height = height;
127
+ return canvas2;
128
+ }
129
+ if (isNode) {
130
+ if (!_canvas) {
131
+ throw new Error('Failed to resolve "canvas" package.');
132
+ }
133
+ return _canvas.createCanvas(width, height);
134
+ }
135
+ throw new Error("Unsupported environment for canvas creation.");
136
+ },
137
+ create(width, height) {
138
+ const _canvas2 = this._createCanvas(width, height);
139
+ const context = _canvas2.getContext(
140
+ "2d"
141
+ );
142
+ return {
143
+ canvas: _canvas2,
144
+ context
145
+ };
146
+ },
147
+ reset(ctx, width, height) {
148
+ if (ctx.canvas) {
149
+ ctx.canvas.width = width;
150
+ ctx.canvas.height = height;
151
+ }
152
+ },
153
+ destroy(ctx) {
154
+ if (ctx.canvas) {
155
+ ctx.canvas.width = 0;
156
+ ctx.canvas.height = 0;
157
+ }
158
+ ctx.canvas = void 0;
159
+ ctx.context = void 0;
160
+ }
161
+ };
162
+ }
163
+ async function getMeta$1(data) {
164
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
165
+ const meta = await pdf.getMetadata();
166
+ return {
167
+ info: meta?.info ?? {},
168
+ metadata: meta?.metadata?.getAll() ?? {}
169
+ };
170
+ }
171
+ async function extractText$1(data, options = {}) {
172
+ const { mergePages = false } = { ...options };
173
+ const pdf = isPDFDocumentProxy(data) ? data : await getDocumentProxy(data);
174
+ const texts = await Promise.all(
175
+ Array.from({ length: pdf.numPages }, (_, i) => getPageText(pdf, i + 1))
176
+ );
177
+ return {
178
+ totalPages: pdf.numPages,
179
+ text: mergePages ? texts.join("\n").replace(/\s+/g, " ") : texts
180
+ };
181
+ }
182
+ async function getPageText(document2, pageNumber) {
183
+ const page = await document2.getPage(pageNumber);
184
+ const content = await page.getTextContent();
185
+ return content.items.filter((item) => item.str != null).map((item) => item.str + (item.hasEOL ? "\n" : "")).join("");
186
+ }
187
+ async function configureUnPDF(options) {
188
+ const { pdfjs } = { ...options };
189
+ if (pdfjs) {
190
+ await resolvePDFJSImports(pdfjs, { force: true });
191
+ }
192
+ }
193
+ var getMeta = async (...args) => {
194
+ await resolvePDFJSImports();
195
+ return await getMeta$1(...args);
196
+ };
197
+ var extractText = async (...args) => {
198
+ await resolvePDFJSImports();
199
+ return await extractText$1(...args);
200
+ };
201
+ var extractImages = async (...args) => {
202
+ await resolvePDFJSImports();
203
+ return await extractImages$1(...args);
204
+ };
205
+ var renderPageAsImage = async (...args) => {
206
+ await resolvePDFJSImports();
207
+ return await renderPageAsImage$1(...args);
208
+ };
209
+ export {
210
+ configureUnPDF,
211
+ createIsomorphicCanvasFactory,
212
+ extractImages,
213
+ extractText,
214
+ getDocumentProxy,
215
+ getMeta,
216
+ getResolvedPDFJS,
217
+ renderPageAsImage,
218
+ resolvePDFJSImports
219
+ };
@@ -1,7 +1,8 @@
1
1
  import {
2
2
  applyElkLayout,
3
3
  applyTreeLayout
4
- } from "./chunk-JTRIDVBS.js";
4
+ } from "./chunk-4TBML7BC.js";
5
+ import "./chunk-DPGHTQAV.js";
5
6
  export {
6
7
  applyElkLayout,
7
8
  applyTreeLayout