lurqrun 0.1.6 → 0.1.7

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 (206) hide show
  1. package/README.md +18 -10
  2. package/dist/auditHandler-JCOJSUYW.js +23 -0
  3. package/dist/bin/lurq.js +3090 -23306
  4. package/dist/browserAuth-B6G27USY.js +95 -0
  5. package/dist/cache-DKI34SVS.js +12 -0
  6. package/dist/check-2FDGUOV7.js +192 -0
  7. package/dist/checkUpgrade-F2WESBPM.js +103 -0
  8. package/dist/chunk-2VMOWSRY.js +300 -0
  9. package/dist/chunk-3GHJR7XR.js +2049 -0
  10. package/dist/chunk-3N3Q3DSW.js +214 -0
  11. package/dist/chunk-4ESO33J6.js +34 -0
  12. package/dist/chunk-4F7ZESPO.js +132 -0
  13. package/dist/chunk-4KCPOMG6.js +68 -0
  14. package/dist/chunk-4ZYCIMY4.js +155 -0
  15. package/dist/chunk-63MUJNZL.js +318 -0
  16. package/dist/chunk-6AAEVQ7I.js +6336 -0
  17. package/dist/chunk-6EQ3ARXA.js +304 -0
  18. package/dist/chunk-6L3U7DZ5.js +23 -0
  19. package/dist/chunk-AHBP533R.js +220 -0
  20. package/dist/chunk-B43LCXBM.js +223 -0
  21. package/dist/chunk-BCANRN5B.js +33 -0
  22. package/dist/chunk-BUALU27S.js +123 -0
  23. package/dist/chunk-BULZAX2U.js +1554 -0
  24. package/dist/chunk-BV32UNLL.js +154 -0
  25. package/dist/chunk-C6GLE626.js +160 -0
  26. package/dist/chunk-CIDWNUAP.js +145 -0
  27. package/dist/chunk-CUP36ND3.js +2126 -0
  28. package/dist/chunk-CW5HJ3LX.js +96 -0
  29. package/dist/chunk-DB2VF5UD.js +315 -0
  30. package/dist/chunk-DWAGCNEL.js +210 -0
  31. package/dist/chunk-EA3DP5HG.js +293 -0
  32. package/dist/chunk-ELGCAM7P.js +184 -0
  33. package/dist/chunk-FW6BD2NO.js +1915 -0
  34. package/dist/chunk-GE37NVLN.js +15 -0
  35. package/dist/chunk-GPTKSNR6.js +171 -0
  36. package/dist/chunk-GRJXQBQZ.js +793 -0
  37. package/dist/chunk-HWBBVLOT.js +92 -0
  38. package/dist/chunk-I2JUKN6Z.js +24 -0
  39. package/dist/chunk-I3M2KJXB.js +56 -0
  40. package/dist/chunk-IQ4SDKKY.js +733 -0
  41. package/dist/chunk-J5FZYN4A.js +116 -0
  42. package/dist/chunk-L6N4JFW2.js +263 -0
  43. package/dist/chunk-LBFGSSF2.js +126 -0
  44. package/dist/chunk-LEGPB7DO.js +81 -0
  45. package/dist/chunk-LO35HLQZ.js +219 -0
  46. package/dist/chunk-LRD4GBYE.js +73 -0
  47. package/dist/chunk-LUAKDHLZ.js +40 -0
  48. package/dist/chunk-LYMPYETA.js +965 -0
  49. package/dist/chunk-M6NYEXCW.js +38 -0
  50. package/dist/chunk-MHUEVBVO.js +35 -0
  51. package/dist/chunk-MYGSLK44.js +37 -0
  52. package/dist/chunk-NH5I4KHH.js +201 -0
  53. package/dist/chunk-OQS4GUSI.js +1391 -0
  54. package/dist/chunk-PSX3GIAN.js +176 -0
  55. package/dist/chunk-Q5VPF4WI.js +26 -0
  56. package/dist/chunk-QKGYDMWB.js +7409 -0
  57. package/dist/chunk-QSL6QN5X.js +115 -0
  58. package/dist/chunk-SHCEBP3J.js +107 -0
  59. package/dist/chunk-SJOVFF7B.js +201 -0
  60. package/dist/chunk-ST2X2GYN.js +373 -0
  61. package/dist/chunk-TNTXWSYA.js +19 -0
  62. package/dist/chunk-U5AT3TD4.js +2128 -0
  63. package/dist/chunk-UDVNA7EA.js +483 -0
  64. package/dist/chunk-VL2E5T2A.js +109 -0
  65. package/dist/chunk-VLRHFMGJ.js +58 -0
  66. package/dist/chunk-WHX2ZFCG.js +4048 -0
  67. package/dist/chunk-WQ23REYT.js +37 -0
  68. package/dist/chunk-XBIDMHSK.js +15425 -0
  69. package/dist/chunk-Y5GI7RL3.js +66 -0
  70. package/dist/client-IRKAMDYZ.js +15 -0
  71. package/dist/commands-FIL5ET6P.js +911 -0
  72. package/dist/compat-R3UTFQ5Q.js +201 -0
  73. package/dist/dashboardIssue-WYYMBFIB.js +192 -0
  74. package/dist/diff-GZA2774U.js +13 -0
  75. package/dist/dist-4XXIXHHZ.js +12945 -0
  76. package/dist/e2b-FVPHDULZ.js +172 -0
  77. package/dist/extract-NKGKLIVT.js +444 -0
  78. package/dist/fetch-QYTUJVG2.js +22 -0
  79. package/dist/firstTouch-QQTJH4QX.js +55 -0
  80. package/dist/handlers-GEJAVZDK.js +53 -0
  81. package/dist/http-ETPYMBGD.js +5360 -0
  82. package/dist/ingestQueue-VKN4KBIF.js +35 -0
  83. package/dist/install-EK3W2COX.js +20 -0
  84. package/dist/installSkill-VQJWJVCL.js +52 -0
  85. package/dist/inventory-5AWSLJYU.js +31 -0
  86. package/dist/local-XPZMRH5R.js +13 -0
  87. package/dist/mcp-3JHD5SUZ.js +472 -0
  88. package/dist/mcpHandlers-QFN4MCFL.js +22 -0
  89. package/dist/mcpScan-QZHWENIP.js +1871 -0
  90. package/dist/mcpScanWorkflow-JPYCBGC4.js +81 -0
  91. package/dist/mcpStack-BYJCZNIV.js +20 -0
  92. package/dist/packages-THVFMWFP.js +42 -0
  93. package/dist/plan-V4OEI3J4.js +463 -0
  94. package/dist/planView-JRXGCG2N.js +79 -0
  95. package/dist/policy-3P6BGRDN.js +115 -0
  96. package/dist/references-6N7VEPHT.js +14 -0
  97. package/dist/release-4U4ABNSJ.js +128 -0
  98. package/dist/remote-YGCXYI4V.js +32 -0
  99. package/dist/reportRuns-CKQQYLY4.js +64 -0
  100. package/dist/sandbox-MEZLAODF.js +39 -0
  101. package/dist/server-KFUD5X57.js +55 -0
  102. package/dist/surface-V62GE554.js +141 -0
  103. package/dist/surface-YL6O67W3.js +36 -0
  104. package/dist/surfaceHandlers-X2IZKA3E.js +20 -0
  105. package/dist/typecheck-X7U5ELMR.js +268 -0
  106. package/dist/types-M5JP2W3D.js +10 -0
  107. package/dist/uninstall-P7RGBX6G.js +174 -0
  108. package/dist/upgrade-NQ5IWFZB.js +596 -0
  109. package/dist/upgradePlan-A4LRKLEG.js +146 -0
  110. package/dist/userConfig-Z3GQE776.js +20 -0
  111. package/dist/watch-DGFMWUDL.js +214 -0
  112. package/package.json +26 -21
  113. package/templates/agent-rules.md +4 -4
  114. package/templates/skill-instructions.md +13 -14
  115. package/dist/bin/lurq.js.map +0 -1
  116. package/dist/index.d.ts +0 -805
  117. package/dist/index.js +0 -23570
  118. package/dist/index.js.map +0 -1
  119. package/drizzle/0000_confused_fabian_cortez.sql +0 -54
  120. package/drizzle/0001_aspiring_timeslip.sql +0 -15
  121. package/drizzle/0002_lyrical_lila_cheney.sql +0 -14
  122. package/drizzle/0003_violet_giant_girl.sql +0 -14
  123. package/drizzle/0004_slim_valeria_richards.sql +0 -15
  124. package/drizzle/0005_petite_luke_cage.sql +0 -12
  125. package/drizzle/0006_calm_nighthawk.sql +0 -3
  126. package/drizzle/0007_slimy_naoko.sql +0 -1
  127. package/drizzle/0008_peaceful_tigra.sql +0 -1
  128. package/drizzle/0009_smooth_harrier.sql +0 -10
  129. package/drizzle/0010_curved_amphibian.sql +0 -2
  130. package/drizzle/0011_compat_provenance_closures.sql +0 -11
  131. package/drizzle/0012_api_surfaces.sql +0 -9
  132. package/drizzle/0013_nice_thanos.sql +0 -1
  133. package/drizzle/0014_luxuriant_malcolm_colcord.sql +0 -10
  134. package/drizzle/0015_past_fat_cobra.sql +0 -11
  135. package/drizzle/0016_futuristic_junta.sql +0 -50
  136. package/drizzle/0017_absent_grandmaster.sql +0 -20
  137. package/drizzle/0018_rainy_proemial_gods.sql +0 -1
  138. package/drizzle/0019_dashing_korvac.sql +0 -11
  139. package/drizzle/0020_normal_vulture.sql +0 -3
  140. package/drizzle/0021_dazzling_blue_shield.sql +0 -17
  141. package/drizzle/0022_massive_ghost_rider.sql +0 -24
  142. package/drizzle/0023_next_shatterstar.sql +0 -1
  143. package/drizzle/0024_dusty_maelstrom.sql +0 -15
  144. package/drizzle/0025_gifted_harpoon.sql +0 -5
  145. package/drizzle/0026_awesome_mordo.sql +0 -1
  146. package/drizzle/0027_charming_ulik.sql +0 -2
  147. package/drizzle/0028_romantic_loners.sql +0 -2
  148. package/drizzle/0029_busy_korvac.sql +0 -16
  149. package/drizzle/0030_steady_mathemanic.sql +0 -6
  150. package/drizzle/0031_redundant_maginty.sql +0 -2
  151. package/drizzle/0032_stack_resolutions.sql +0 -14
  152. package/drizzle/0033_graceful_tyger_tiger.sql +0 -3
  153. package/drizzle/0034_uneven_thunderbird.sql +0 -1
  154. package/drizzle/0035_api_key_scopes.sql +0 -1
  155. package/drizzle/0036_policy_audit.sql +0 -21
  156. package/drizzle/0037_subscription_seats.sql +0 -1
  157. package/drizzle/0038_symbol_offsets.sql +0 -2
  158. package/drizzle/0039_mcp_runtime_scans.sql +0 -80
  159. package/drizzle/0040_subscription_overage_and_interval.sql +0 -4
  160. package/drizzle/0041_account_email.sql +0 -38
  161. package/drizzle/0042_alert_channels.sql +0 -21
  162. package/drizzle/meta/0000_snapshot.json +0 -370
  163. package/drizzle/meta/0001_snapshot.json +0 -482
  164. package/drizzle/meta/0002_snapshot.json +0 -575
  165. package/drizzle/meta/0003_snapshot.json +0 -667
  166. package/drizzle/meta/0004_snapshot.json +0 -769
  167. package/drizzle/meta/0005_snapshot.json +0 -864
  168. package/drizzle/meta/0006_snapshot.json +0 -882
  169. package/drizzle/meta/0007_snapshot.json +0 -876
  170. package/drizzle/meta/0008_snapshot.json +0 -882
  171. package/drizzle/meta/0009_snapshot.json +0 -948
  172. package/drizzle/meta/0010_snapshot.json +0 -969
  173. package/drizzle/meta/0011_snapshot.json +0 -1049
  174. package/drizzle/meta/0012_snapshot.json +0 -1115
  175. package/drizzle/meta/0013_snapshot.json +0 -1121
  176. package/drizzle/meta/0014_snapshot.json +0 -1190
  177. package/drizzle/meta/0015_snapshot.json +0 -1280
  178. package/drizzle/meta/0016_snapshot.json +0 -1683
  179. package/drizzle/meta/0017_snapshot.json +0 -1834
  180. package/drizzle/meta/0018_snapshot.json +0 -1834
  181. package/drizzle/meta/0019_snapshot.json +0 -1909
  182. package/drizzle/meta/0020_snapshot.json +0 -1921
  183. package/drizzle/meta/0021_snapshot.json +0 -2045
  184. package/drizzle/meta/0022_snapshot.json +0 -2246
  185. package/drizzle/meta/0023_snapshot.json +0 -2252
  186. package/drizzle/meta/0024_snapshot.json +0 -2375
  187. package/drizzle/meta/0025_snapshot.json +0 -2407
  188. package/drizzle/meta/0026_snapshot.json +0 -2413
  189. package/drizzle/meta/0027_snapshot.json +0 -2425
  190. package/drizzle/meta/0028_snapshot.json +0 -2438
  191. package/drizzle/meta/0029_snapshot.json +0 -2546
  192. package/drizzle/meta/0030_snapshot.json +0 -2586
  193. package/drizzle/meta/0031_snapshot.json +0 -2598
  194. package/drizzle/meta/0032_snapshot.json +0 -2699
  195. package/drizzle/meta/0033_snapshot.json +0 -2712
  196. package/drizzle/meta/0034_snapshot.json +0 -2719
  197. package/drizzle/meta/0035_snapshot.json +0 -2726
  198. package/drizzle/meta/0036_snapshot.json +0 -2876
  199. package/drizzle/meta/0037_snapshot.json +0 -2883
  200. package/drizzle/meta/0038_snapshot.json +0 -2895
  201. package/drizzle/meta/0039_snapshot.json +0 -3501
  202. package/drizzle/meta/0040_snapshot.json +0 -3527
  203. package/drizzle/meta/0041_snapshot.json +0 -3824
  204. package/drizzle/meta/0042_snapshot.json +0 -3960
  205. package/drizzle/meta/_journal.json +0 -307
  206. package/src/data/seed.json +0 -253
@@ -0,0 +1,172 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ DEFAULT_TARGET
4
+ } from "./chunk-GE37NVLN.js";
5
+ import {
6
+ getConfig
7
+ } from "./chunk-GRJXQBQZ.js";
8
+ import "./chunk-WHX2ZFCG.js";
9
+ import {
10
+ init_esm_shims
11
+ } from "./chunk-I3M2KJXB.js";
12
+
13
+ // src/sandbox/e2b.ts
14
+ init_esm_shims();
15
+ var INSTALL_TIMEOUT_MS = 12e4;
16
+ var SMOKE_TIMEOUT_MS = 3e4;
17
+ var ERROR_MAX = 500;
18
+ var WORKDIR = "/home/user";
19
+ function shQuote(s) {
20
+ return `'${s.replace(/'/g, `'\\''`)}'`;
21
+ }
22
+ function installCommand(specs, allowScripts) {
23
+ const bad = specs.find((s) => s.startsWith("-"));
24
+ if (bad) throw new Error(`Invalid package spec: ${bad}`);
25
+ const flags = ["--no-audit", "--no-fund", "--no-package-lock", "--no-save"];
26
+ if (!allowScripts) flags.push("--ignore-scripts");
27
+ return `npm install ${specs.map(shQuote).join(" ")} ${flags.join(" ")}`;
28
+ }
29
+ function smokeCommand(pkg) {
30
+ return `node --input-type=module -e ${shQuote(`await import(${JSON.stringify(pkg)})`)}`;
31
+ }
32
+ function condense(s) {
33
+ return s.replace(/\s+/g, " ").trim().slice(0, ERROR_MAX);
34
+ }
35
+ function errText(err) {
36
+ if (err && typeof err === "object") {
37
+ const e = err;
38
+ if (typeof e.stderr === "string" && e.stderr.trim()) return e.stderr;
39
+ if (typeof e.message === "string") return e.message;
40
+ }
41
+ return String(err);
42
+ }
43
+ var toSpec = (p) => p.version ? `${p.name}@${p.version}` : p.name;
44
+ var E2BSandbox = class {
45
+ name = "e2b";
46
+ async verify(pkg, version, opts = {}) {
47
+ const set = await this.verifySet([{ name: pkg, version }], opts);
48
+ return {
49
+ driver: this.name,
50
+ moduleSystem: set.moduleSystem,
51
+ installed: set.installed,
52
+ imported: set.loaded[0]?.loaded ?? null,
53
+ ranScripts: opts.allowScripts ?? false,
54
+ durationMs: set.durationMs,
55
+ error: set.error
56
+ };
57
+ }
58
+ async verifySet(packages, opts = {}) {
59
+ const config = getConfig();
60
+ const target = opts.target ?? DEFAULT_TARGET;
61
+ const allowScripts = opts.allowScripts ?? false;
62
+ const specs = packages.map(toSpec);
63
+ const installTimeout = opts.timeoutMs ?? INSTALL_TIMEOUT_MS;
64
+ const started = Date.now();
65
+ const smokeTargets = opts.smokePackages ?? packages;
66
+ const loaded = smokeTargets.map((p) => ({ name: p.name, loaded: null }));
67
+ let installed = false;
68
+ let error = null;
69
+ const install = installCommand(specs, allowScripts);
70
+ const { default: Sandbox } = await import("e2b");
71
+ const createOpts = {
72
+ apiKey: config.E2B_API_KEY,
73
+ timeoutMs: installTimeout + SMOKE_TIMEOUT_MS * packages.length + 3e4
74
+ };
75
+ const sandbox = config.E2B_TEMPLATE ? await Sandbox.create(config.E2B_TEMPLATE, createOpts) : await Sandbox.create(createOpts);
76
+ try {
77
+ await sandbox.files.write(
78
+ `${WORKDIR}/package.json`,
79
+ JSON.stringify({ name: "lurq-sandbox", version: "0.0.0", private: true })
80
+ );
81
+ await sandbox.commands.run(install, { cwd: WORKDIR, timeoutMs: installTimeout });
82
+ installed = true;
83
+ for (let i = 0; i < smokeTargets.length; i++) {
84
+ try {
85
+ await sandbox.commands.run(smokeCommand(smokeTargets[i].name), {
86
+ cwd: WORKDIR,
87
+ timeoutMs: SMOKE_TIMEOUT_MS
88
+ });
89
+ loaded[i].loaded = true;
90
+ } catch (err) {
91
+ loaded[i].loaded = false;
92
+ if (!error) error = condense(errText(err));
93
+ }
94
+ }
95
+ } catch (err) {
96
+ error = condense(errText(err));
97
+ } finally {
98
+ await sandbox.kill().catch(() => {
99
+ });
100
+ }
101
+ return {
102
+ driver: this.name,
103
+ moduleSystem: target.moduleSystem,
104
+ installed,
105
+ loaded,
106
+ durationMs: Date.now() - started,
107
+ error
108
+ };
109
+ }
110
+ async exec(command, opts = {}) {
111
+ const config = getConfig();
112
+ const timeoutMs = opts.timeoutMs ?? SMOKE_TIMEOUT_MS;
113
+ const install = opts.install?.length ? installCommand(opts.install.map(toSpec), opts.allowScripts ?? false) : null;
114
+ const { default: Sandbox } = await import("e2b");
115
+ const createOpts = {
116
+ apiKey: config.E2B_API_KEY,
117
+ timeoutMs: (install ? INSTALL_TIMEOUT_MS : 0) + timeoutMs + 3e4
118
+ };
119
+ const sandbox = config.E2B_TEMPLATE ? await Sandbox.create(config.E2B_TEMPLATE, createOpts) : await Sandbox.create(createOpts);
120
+ try {
121
+ await sandbox.files.write(
122
+ `${WORKDIR}/package.json`,
123
+ JSON.stringify({ name: "lurq-sandbox", version: "0.0.0", private: true })
124
+ );
125
+ if (install) {
126
+ await sandbox.commands.run(install, { cwd: WORKDIR, timeoutMs: INSTALL_TIMEOUT_MS });
127
+ }
128
+ const out = await sandbox.commands.run(command, { cwd: WORKDIR, timeoutMs });
129
+ return { exitCode: out.exitCode ?? 0, stdout: out.stdout ?? "", stderr: out.stderr ?? "" };
130
+ } catch (err) {
131
+ const e = err;
132
+ if (typeof e?.exitCode === "number") {
133
+ return {
134
+ exitCode: e.exitCode,
135
+ stdout: typeof e.stdout === "string" ? e.stdout : "",
136
+ stderr: typeof e.stderr === "string" ? e.stderr : errText(err)
137
+ };
138
+ }
139
+ throw err;
140
+ } finally {
141
+ await sandbox.kill().catch(() => {
142
+ });
143
+ }
144
+ }
145
+ async getRuntimeInfo() {
146
+ let nodeVersion = "unknown";
147
+ let npmVersion = "unknown";
148
+ const config = getConfig();
149
+ try {
150
+ const { default: Sandbox } = await import("e2b");
151
+ const createOpts = { apiKey: config.E2B_API_KEY, timeoutMs: 3e4 };
152
+ const sandbox = config.E2B_TEMPLATE ? await Sandbox.create(config.E2B_TEMPLATE, createOpts) : await Sandbox.create(createOpts);
153
+ try {
154
+ const nodeOut = await sandbox.commands.run("node --version");
155
+ nodeVersion = (nodeOut.stdout ?? "").trim() || "unknown";
156
+ const npmOut = await sandbox.commands.run("npm --version");
157
+ npmVersion = (npmOut.stdout ?? "").trim() || "unknown";
158
+ } finally {
159
+ await sandbox.kill().catch(() => {
160
+ });
161
+ }
162
+ } catch {
163
+ }
164
+ return { nodeVersion, npmVersion };
165
+ }
166
+ };
167
+ export {
168
+ E2BSandbox,
169
+ installCommand,
170
+ shQuote,
171
+ smokeCommand
172
+ };
@@ -0,0 +1,444 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ readManifest,
4
+ resolveEntryCandidates,
5
+ resolveInternal,
6
+ resolvesInsidePackage
7
+ } from "./chunk-ELGCAM7P.js";
8
+ import {
9
+ init_esm_shims
10
+ } from "./chunk-I3M2KJXB.js";
11
+
12
+ // src/surface/extract.ts
13
+ init_esm_shims();
14
+ import { readFileSync } from "fs";
15
+ import { relative } from "path";
16
+ import ts from "typescript";
17
+ var TIER = "shipped_js_ast";
18
+ var MAX_FILES = 400;
19
+ function classify(node) {
20
+ if (ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isFunctionDeclaration(node)) {
21
+ return { kind: "function", arity: arityOf(node), maxArity: maxArityOf(node) };
22
+ }
23
+ if (ts.isClassExpression(node) || ts.isClassDeclaration(node)) return { kind: "class", arity: null };
24
+ if (ts.isObjectLiteralExpression(node)) return { kind: "object", arity: null };
25
+ if (ts.isStringLiteral(node) || ts.isNumericLiteral(node) || node.kind === ts.SyntaxKind.TrueKeyword || node.kind === ts.SyntaxKind.FalseKeyword || node.kind === ts.SyntaxKind.NullKeyword) {
26
+ return { kind: "primitive", arity: null };
27
+ }
28
+ return { kind: "object", arity: null };
29
+ }
30
+ function arityOf(fn) {
31
+ let n = 0;
32
+ for (const p of fn.parameters) {
33
+ if (p.initializer || p.dotDotDotToken) break;
34
+ n++;
35
+ }
36
+ return n;
37
+ }
38
+ function maxArityOf(fn) {
39
+ if (fn.parameters.some((p) => p.dotDotDotToken)) return null;
40
+ let readsArguments = false;
41
+ const visit = (n) => {
42
+ if (readsArguments) return;
43
+ if (ts.isIdentifier(n) && n.text === "arguments") readsArguments = true;
44
+ else if (!(ts.isFunctionLike(n) && !ts.isArrowFunction(n))) ts.forEachChild(n, visit);
45
+ };
46
+ if (fn.body) visit(fn.body);
47
+ return readsArguments ? null : fn.parameters.length;
48
+ }
49
+ function lineOf(sf, node) {
50
+ return sf.getLineAndCharacterOfPosition(node.getStart(sf)).line + 1;
51
+ }
52
+ function put(out, sym) {
53
+ if (!out.has(sym.path)) out.set(sym.path, sym);
54
+ }
55
+ function localBinding(sf, name) {
56
+ let found = null;
57
+ for (const stmt of sf.statements) {
58
+ if (ts.isVariableStatement(stmt)) {
59
+ for (const d of stmt.declarationList.declarations) {
60
+ if (ts.isIdentifier(d.name) && d.name.text === name && d.initializer) found = d.initializer;
61
+ }
62
+ } else if (ts.isFunctionDeclaration(stmt) && stmt.name?.text === name) {
63
+ found = stmt;
64
+ } else if (ts.isClassDeclaration(stmt) && stmt.name?.text === name) {
65
+ found = stmt;
66
+ }
67
+ }
68
+ return found;
69
+ }
70
+ function isModuleExports(e) {
71
+ return ts.isPropertyAccessExpression(e) && ts.isIdentifier(e.expression) && e.expression.text === "module" && e.name.text === "exports";
72
+ }
73
+ function exportTargetName(e) {
74
+ if (!ts.isPropertyAccessExpression(e)) return null;
75
+ if (ts.isIdentifier(e.expression) && e.expression.text === "exports") return e.name.text;
76
+ if (isModuleExports(e.expression)) return e.name.text;
77
+ return null;
78
+ }
79
+ function hasDeprecatedTag(sf, node) {
80
+ const full = node.getFullText(sf);
81
+ const lead = full.slice(0, full.length - node.getText(sf).length);
82
+ return /@deprecated/i.test(lead);
83
+ }
84
+ function flattenStatements(stmts, depth = 0) {
85
+ if (depth > 6) return [...stmts];
86
+ const out = [];
87
+ for (const s of stmts) {
88
+ out.push(s);
89
+ if (ts.isBlock(s)) out.push(...flattenStatements(s.statements, depth + 1));
90
+ else if (ts.isIfStatement(s)) {
91
+ const branches = [s.thenStatement, s.elseStatement].filter(Boolean);
92
+ for (const b of branches) {
93
+ out.push(...flattenStatements(ts.isBlock(b) ? b.statements : [b], depth + 1));
94
+ }
95
+ } else if (ts.isTryStatement(s)) {
96
+ out.push(...flattenStatements(s.tryBlock.statements, depth + 1));
97
+ if (s.catchClause) out.push(...flattenStatements(s.catchClause.block.statements, depth + 1));
98
+ if (s.finallyBlock) out.push(...flattenStatements(s.finallyBlock.statements, depth + 1));
99
+ } else if (ts.isSwitchStatement(s)) {
100
+ for (const c of s.caseBlock.clauses) {
101
+ out.push(...flattenStatements(c.statements, depth + 1));
102
+ }
103
+ }
104
+ }
105
+ return out;
106
+ }
107
+ function walk(file, ctx, out) {
108
+ if (ctx.visited.has(file)) return;
109
+ if (ctx.filesWalked >= MAX_FILES) {
110
+ ctx.truncated = true;
111
+ return;
112
+ }
113
+ ctx.visited.add(file);
114
+ ctx.filesWalked++;
115
+ let text;
116
+ try {
117
+ text = readFileSync(file, "utf8");
118
+ } catch {
119
+ return;
120
+ }
121
+ const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, true, ts.ScriptKind.JS);
122
+ const rel = relative(ctx.pkgDir, file);
123
+ const add = (path, node, over = {}) => {
124
+ const { kind, arity, maxArity } = classify(node);
125
+ put(out, {
126
+ path,
127
+ kind,
128
+ arity,
129
+ ...maxArity !== void 0 ? { maxArity } : {},
130
+ origin: "local",
131
+ deprecated: hasDeprecatedTag(sf, node),
132
+ tier: TIER,
133
+ sourceRef: { file: rel, line: lineOf(sf, node), offset: node.getStart(sf) },
134
+ ...over
135
+ });
136
+ };
137
+ const reExport = (spec, names, picks) => {
138
+ if (resolvesInsidePackage(spec)) {
139
+ const target = resolveInternal(file, spec, ctx.pkgDir);
140
+ if (!target) return;
141
+ if (!picks) {
142
+ walk(target, ctx, out);
143
+ return;
144
+ }
145
+ const sub = /* @__PURE__ */ new Map();
146
+ walk(target, { ...ctx, visited: new Set(ctx.visited) }, sub);
147
+ for (const pick of picks) {
148
+ const found = sub.get(pick.from);
149
+ if (found) put(out, { ...found, path: pick.as });
150
+ else put(out, { path: pick.as, kind: "object", arity: null, origin: "local", deprecated: false, tier: TIER, sourceRef: { file: rel, line: 1 } });
151
+ }
152
+ return;
153
+ }
154
+ ctx.external.add(spec);
155
+ for (const n of names ?? []) {
156
+ put(out, {
157
+ path: n,
158
+ kind: "object",
159
+ arity: null,
160
+ origin: `external:${spec}`,
161
+ deprecated: false,
162
+ tier: TIER,
163
+ sourceRef: { file: rel, line: 1 }
164
+ });
165
+ }
166
+ };
167
+ for (const stmt of flattenStatements(sf.statements)) {
168
+ if (ts.isExportDeclaration(stmt)) {
169
+ const spec = stmt.moduleSpecifier && ts.isStringLiteral(stmt.moduleSpecifier) ? stmt.moduleSpecifier.text : null;
170
+ const isTypeOnly = stmt.isTypeOnly;
171
+ if (stmt.exportClause && ts.isNamedExports(stmt.exportClause)) {
172
+ const names = stmt.exportClause.elements.map((el) => el.name.text);
173
+ if (spec) {
174
+ reExport(
175
+ spec,
176
+ names,
177
+ stmt.exportClause.elements.map((el) => ({
178
+ from: el.propertyName?.text ?? el.name.text,
179
+ as: el.name.text
180
+ }))
181
+ );
182
+ } else {
183
+ for (const el of stmt.exportClause.elements) {
184
+ const local = el.propertyName?.text ?? el.name.text;
185
+ const decl = localBinding(sf, local);
186
+ if (isTypeOnly || el.isTypeOnly) {
187
+ put(out, {
188
+ path: el.name.text,
189
+ kind: "type_only",
190
+ arity: null,
191
+ origin: "local",
192
+ deprecated: false,
193
+ tier: TIER,
194
+ sourceRef: { file: rel, line: lineOf(sf, el) }
195
+ });
196
+ } else if (decl) {
197
+ add(el.name.text, decl);
198
+ } else {
199
+ add(el.name.text, el);
200
+ }
201
+ }
202
+ }
203
+ } else if (spec) {
204
+ reExport(spec, null);
205
+ }
206
+ continue;
207
+ }
208
+ const mods = ts.canHaveModifiers(stmt) ? ts.getModifiers(stmt) : void 0;
209
+ const exported = mods?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword);
210
+ if (exported) {
211
+ if (ts.isVariableStatement(stmt)) {
212
+ for (const d of stmt.declarationList.declarations) {
213
+ if (ts.isIdentifier(d.name)) add(d.name.text, d.initializer ?? d);
214
+ }
215
+ } else if (ts.isFunctionDeclaration(stmt) && stmt.name) {
216
+ add(stmt.name.text, stmt);
217
+ } else if (ts.isClassDeclaration(stmt) && stmt.name) {
218
+ add(stmt.name.text, stmt);
219
+ } else if (ts.isInterfaceDeclaration(stmt) || ts.isTypeAliasDeclaration(stmt)) {
220
+ put(out, {
221
+ path: stmt.name.text,
222
+ kind: "type_only",
223
+ arity: null,
224
+ origin: "local",
225
+ deprecated: false,
226
+ tier: TIER,
227
+ sourceRef: { file: rel, line: lineOf(sf, stmt) }
228
+ });
229
+ }
230
+ continue;
231
+ }
232
+ if (ts.isExportAssignment(stmt)) {
233
+ const target = ts.isIdentifier(stmt.expression) ? localBinding(sf, stmt.expression.text) ?? stmt.expression : stmt.expression;
234
+ add("default", target);
235
+ continue;
236
+ }
237
+ if (ts.isExpressionStatement(stmt)) {
238
+ const e = stmt.expression;
239
+ if (ts.isCallExpression(e) && ts.isPropertyAccessExpression(e.expression) && ts.isIdentifier(e.expression.expression) && e.expression.expression.text === "Object" && e.expression.name.text === "defineProperty" && e.arguments.length >= 2) {
240
+ const targetArg = e.arguments[0];
241
+ const isExportsTarget = ts.isIdentifier(targetArg) && targetArg.text === "exports" || isModuleExports(targetArg);
242
+ const nameArg = e.arguments[1];
243
+ if (isExportsTarget && ts.isStringLiteral(nameArg) && nameArg.text !== "__esModule") {
244
+ put(out, {
245
+ path: nameArg.text,
246
+ kind: "object",
247
+ arity: null,
248
+ origin: "local",
249
+ deprecated: hasDeprecatedTag(sf, stmt),
250
+ tier: TIER,
251
+ sourceRef: { file: rel, line: lineOf(sf, stmt) }
252
+ });
253
+ continue;
254
+ }
255
+ }
256
+ if (ts.isCallExpression(e)) {
257
+ const callee = e.expression;
258
+ const isObjectAssign = ts.isPropertyAccessExpression(callee) && ts.isIdentifier(callee.expression) && callee.expression.text === "Object" && callee.name.text === "assign" && e.arguments.length > 0 && isModuleExports(e.arguments[0]);
259
+ const isExportStar = ts.isIdentifier(callee) && /^_{0,2}(exportStar|reExport|export)$/i.test(callee.text);
260
+ if (isObjectAssign || isExportStar) {
261
+ for (const arg of e.arguments.slice(isObjectAssign ? 1 : 0)) {
262
+ const spec = requireSpecifier(arg);
263
+ if (spec) reExport(spec, null);
264
+ else if (ts.isObjectLiteralExpression(arg)) {
265
+ for (const p of arg.properties) {
266
+ if (p.name && ts.isIdentifier(p.name)) {
267
+ const value = ts.isPropertyAssignment(p) ? p.initializer : p;
268
+ add(p.name.text, isExportStar ? throughGetter(sf, value) : value);
269
+ }
270
+ }
271
+ } else if (ts.isIdentifier(arg)) {
272
+ const b = localBinding(sf, arg.text);
273
+ if (b && ts.isObjectLiteralExpression(b)) {
274
+ for (const p of b.properties) {
275
+ if (p.name && ts.isIdentifier(p.name)) {
276
+ add(p.name.text, ts.isPropertyAssignment(p) ? p.initializer : p);
277
+ }
278
+ }
279
+ }
280
+ }
281
+ }
282
+ continue;
283
+ }
284
+ }
285
+ if (!ts.isBinaryExpression(e) || e.operatorToken.kind !== ts.SyntaxKind.EqualsToken) continue;
286
+ const lhs = e.left;
287
+ const rhs = e.right;
288
+ if (isModuleExports(lhs)) {
289
+ const spec = requireSpecifier(rhs);
290
+ if (spec) {
291
+ reExport(spec, null);
292
+ continue;
293
+ }
294
+ if (ts.isObjectLiteralExpression(rhs)) {
295
+ for (const p of rhs.properties) {
296
+ if (p.name && ts.isIdentifier(p.name)) {
297
+ add(p.name.text, ts.isPropertyAssignment(p) ? p.initializer : p);
298
+ }
299
+ }
300
+ continue;
301
+ }
302
+ if (ts.isIdentifier(rhs)) {
303
+ const b = localBinding(sf, rhs.text);
304
+ if (b && ts.isObjectLiteralExpression(b)) {
305
+ for (const p of b.properties) {
306
+ if (p.name && ts.isIdentifier(p.name)) {
307
+ add(p.name.text, ts.isPropertyAssignment(p) ? p.initializer : p);
308
+ }
309
+ }
310
+ continue;
311
+ }
312
+ if (b) {
313
+ add("default", b);
314
+ continue;
315
+ }
316
+ }
317
+ add("default", rhs);
318
+ continue;
319
+ }
320
+ const name = exportTargetName(lhs);
321
+ if (name) {
322
+ const spec = requireSpecifier(rhs);
323
+ if (spec && !resolvesInsidePackage(spec)) {
324
+ ctx.external.add(spec);
325
+ put(out, {
326
+ path: name,
327
+ kind: "object",
328
+ arity: null,
329
+ origin: `external:${spec}`,
330
+ deprecated: false,
331
+ tier: TIER,
332
+ sourceRef: { file: rel, line: lineOf(sf, stmt) }
333
+ });
334
+ continue;
335
+ }
336
+ const target = ts.isIdentifier(rhs) ? localBinding(sf, rhs.text) ?? rhs : rhs;
337
+ add(name, target, { deprecated: hasDeprecatedTag(sf, stmt) });
338
+ }
339
+ }
340
+ }
341
+ }
342
+ function throughGetter(sf, value) {
343
+ if (!(ts.isArrowFunction(value) || ts.isFunctionExpression(value)) || value.parameters.length) return value;
344
+ let returned;
345
+ if (!ts.isBlock(value.body)) returned = value.body;
346
+ else if (value.body.statements.length === 1 && ts.isReturnStatement(value.body.statements[0])) {
347
+ returned = value.body.statements[0].expression;
348
+ }
349
+ if (!returned) return value;
350
+ return ts.isIdentifier(returned) ? localBinding(sf, returned.text) ?? returned : returned;
351
+ }
352
+ function requireSpecifier(node) {
353
+ let n = node;
354
+ if (ts.isPropertyAccessExpression(n)) n = n.expression;
355
+ if (ts.isCallExpression(n) && ts.isIdentifier(n.expression) && n.expression.text === "require" && n.arguments.length === 1 && ts.isStringLiteral(n.arguments[0])) {
356
+ return n.arguments[0].text;
357
+ }
358
+ return null;
359
+ }
360
+ function isReadable(symbols) {
361
+ if (symbols.length === 0) return false;
362
+ return !(symbols.length === 1 && symbols[0].path === "default");
363
+ }
364
+ function extractSurface(pkgDir, opts = {}) {
365
+ const manifest = opts.manifest ?? readManifest(pkgDir);
366
+ const candidates = resolveEntryCandidates(pkgDir, manifest, opts.subpath);
367
+ const base = {
368
+ package: manifest?.name ?? pkgDir,
369
+ version: manifest?.version ?? null,
370
+ tier: TIER,
371
+ entry: null,
372
+ symbols: [],
373
+ filesWalked: 0,
374
+ externalReExports: []
375
+ };
376
+ if (!candidates.length) {
377
+ return {
378
+ ...base,
379
+ undeclaredReason: opts.subpath ? `no resolvable JS entry point for subpath ./${opts.subpath}` : "no resolvable JS entry point"
380
+ };
381
+ }
382
+ const attempts = [];
383
+ for (const entry of candidates) {
384
+ const ctx = {
385
+ pkgDir,
386
+ visited: /* @__PURE__ */ new Set(),
387
+ filesWalked: 0,
388
+ external: /* @__PURE__ */ new Set(),
389
+ truncated: false
390
+ };
391
+ const out = /* @__PURE__ */ new Map();
392
+ walk(entry, ctx, out);
393
+ attempts.push({
394
+ entry,
395
+ symbols: [...out.values()].sort((a, b) => a.path.localeCompare(b.path)),
396
+ walked: ctx.filesWalked,
397
+ external: [...ctx.external].sort()
398
+ });
399
+ if (isReadable(attempts[attempts.length - 1].symbols)) break;
400
+ }
401
+ const attempt = attempts.find((a) => isReadable(a.symbols)) ?? attempts[0];
402
+ return {
403
+ ...base,
404
+ entry: relative(pkgDir, attempt.entry),
405
+ symbols: attempt.symbols,
406
+ filesWalked: attempt.walked,
407
+ externalReExports: attempt.external,
408
+ ...attempt.symbols.length === 0 ? { undeclaredReason: "entry resolved but no exports found" } : {}
409
+ };
410
+ }
411
+ function usesTopLevelAwait(pkgDir, entry) {
412
+ const seen = /* @__PURE__ */ new Set();
413
+ const queue = [entry];
414
+ while (queue.length && seen.size < MAX_FILES) {
415
+ const file = queue.pop();
416
+ if (seen.has(file)) continue;
417
+ seen.add(file);
418
+ let text;
419
+ try {
420
+ text = readFileSync(file, "utf8");
421
+ } catch {
422
+ continue;
423
+ }
424
+ const sf = ts.createSourceFile(file, text, ts.ScriptTarget.Latest, false, ts.ScriptKind.JS);
425
+ for (const stmt of sf.statements) {
426
+ if (awaitsAtTopLevel(stmt)) return true;
427
+ const spec = ts.isImportDeclaration(stmt) || ts.isExportDeclaration(stmt) ? stmt.moduleSpecifier : void 0;
428
+ if (spec && ts.isStringLiteral(spec) && resolvesInsidePackage(spec.text)) {
429
+ const next = resolveInternal(file, spec.text, pkgDir);
430
+ if (next) queue.push(next);
431
+ }
432
+ }
433
+ }
434
+ return false;
435
+ }
436
+ function awaitsAtTopLevel(node) {
437
+ if (ts.isFunctionLike(node) || ts.isClassLike(node)) return false;
438
+ if (ts.isAwaitExpression(node) || ts.isForOfStatement(node) && node.awaitModifier) return true;
439
+ return ts.forEachChild(node, awaitsAtTopLevel) ?? false;
440
+ }
441
+ export {
442
+ extractSurface,
443
+ usesTopLevelAwait
444
+ };
@@ -0,0 +1,22 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ extractUnpacked,
4
+ fetchAndExtract,
5
+ fetchManifest,
6
+ resolveTarball,
7
+ unpackPackage,
8
+ verifyIntegrity
9
+ } from "./chunk-BV32UNLL.js";
10
+ import "./chunk-AHBP533R.js";
11
+ import "./chunk-SJOVFF7B.js";
12
+ import "./chunk-MYGSLK44.js";
13
+ import "./chunk-GPTKSNR6.js";
14
+ import "./chunk-I3M2KJXB.js";
15
+ export {
16
+ extractUnpacked,
17
+ fetchAndExtract,
18
+ fetchManifest,
19
+ resolveTarball,
20
+ unpackPackage,
21
+ verifyIntegrity
22
+ };
@@ -0,0 +1,55 @@
1
+ import { createRequire as __lurqCreateRequire } from 'node:module'; const require = __lurqCreateRequire(import.meta.url);
2
+ import {
3
+ withBudget
4
+ } from "./chunk-4ESO33J6.js";
5
+ import {
6
+ logger
7
+ } from "./chunk-MYGSLK44.js";
8
+ import {
9
+ init_esm_shims
10
+ } from "./chunk-I3M2KJXB.js";
11
+
12
+ // src/pipeline/firstTouch.ts
13
+ init_esm_shims();
14
+ var SURFACE_FIRST_TOUCH_BUDGET_MS = 4e3;
15
+ var MAX_INFLIGHT = 64;
16
+ var inFlight = /* @__PURE__ */ new Map();
17
+ function extractOnce(db, pkg, version) {
18
+ const key = `${pkg}@${version ?? "latest"}`;
19
+ const existing = inFlight.get(key);
20
+ if (existing) return existing;
21
+ if (inFlight.size >= MAX_INFLIGHT) return Promise.resolve(null);
22
+ const task = (async () => {
23
+ const { extractAndStore } = await import("./surface-V62GE554.js");
24
+ const { outcome, version: resolved } = await extractAndStore(db, pkg, version);
25
+ return outcome === "stored" || outcome === "cached" ? resolved : null;
26
+ })().catch((err) => {
27
+ logger.warn(
28
+ `surface first-touch failed for ${key}: ${err instanceof Error ? err.message : String(err)}`
29
+ );
30
+ return null;
31
+ }).finally(() => {
32
+ inFlight.delete(key);
33
+ });
34
+ inFlight.set(key, task);
35
+ return task;
36
+ }
37
+ function firstTouchSurface(db, pkg, version, budgetMs = SURFACE_FIRST_TOUCH_BUDGET_MS) {
38
+ const task = extractOnce(db, pkg, version);
39
+ return budgetMs <= 0 ? Promise.resolve(null) : withBudget(task, budgetMs).then((v) => v ?? null);
40
+ }
41
+ async function firstTouchPair(db, pkg, fromVersion, toVersion, budgetMs = SURFACE_FIRST_TOUCH_BUDGET_MS) {
42
+ if (budgetMs <= 0) return false;
43
+ const pair = Promise.all([extractOnce(db, pkg, fromVersion), extractOnce(db, pkg, toVersion)]);
44
+ const settled = await withBudget(pair, budgetMs);
45
+ return Boolean(settled && settled[0] && settled[1]);
46
+ }
47
+ function resetSurfaceFirstTouch() {
48
+ inFlight.clear();
49
+ }
50
+ export {
51
+ SURFACE_FIRST_TOUCH_BUDGET_MS,
52
+ firstTouchPair,
53
+ firstTouchSurface,
54
+ resetSurfaceFirstTouch
55
+ };